Re: GD 1.8.3 & PNG Images - Speed
| From: | Web Admin | Date: | Thu, 31 Aug 2000 14:02:55 +0000 |
| Subject: | Re: GD 1.8.3 & PNG Images - Speed | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14607@lists.php.net to get a copy of this message | ||
hi mark,
maybe decompression takes lotsa your time and cpu usage,
try to store your image in gif format [in your sql, am i right?]
and see how much it differs. specially if you have few images
and you have to show those few images several times!
regards,
Ahmad Anvari
----- Original Message -----
From: "Mark Lipscombe" <mark@itgarp.com>
To: <php-general@lists.php.net>
Sent: Thursday, August 31, 2000 7:19 PM
Subject: [PHP] GD 1.8.3 & PNG Images - Speed
> Hi,
>
> I'm using PHP 4.0.2 with GD 1.8.3/TTF support compiled in statically, and
> PHP statically in Apache 1.3.12, using the Zend Optimiser.
>
> I'm retreiving information from a MySQL database to create, from an
original
> PNG template, a image (in this case buttons for a website) with TTF text
> overlaid, which I'm then using ImagePNG to output.
>
> My problem is it's taking approximately 4 seconds to read the PNG file in
> with ImageCreateFromPNG(). The rest of the script takes about 0.03
seconds
> to complete which is quite reasonable (it's on a Linux box of reasonably
> high specifications). It is definately ImageCreateFromPNG which is
stalling
> the script.
>
> If I read in from a JPEG, using ImageCreateFromJPEG(), the script comes
back
> down to taking a total of 0.04 secs to complete (much more reasonable :),
> but JPEGs are no good for non-photographic content, and it screws with the
> colouring.
>
> Anyone know of any speed issues with using ImageCreateFromPNG, or anything
I
> can do to speed it up?
>
> Below is the code which I'm using:
>
> if (@mpf_db_num_rows($image_data)) {
> $image_data_values = mpf_db_fetch_array($image_data);
>
> $imagepath = DIR_BUTTONS . $image_data_values['sites_templates_id'] .
> '.png';
>
> $im = imagecreatefrompng($imagepath); // here is where it takes 4
> seconds.
> $tmpl_size = GetImageSize($imagepath);
> $color = ImageColorAt($im, 0, $tmpl_size[1] - 1);
>
> $size = ImageTTFBBox(12, 0, DIR_FONTS .
> $image_data_values['fonts_filename'], $image_data_values[@'sites_button' .
> $num]);
> $dx = abs($size[2]-$size[0]);
> $dy = abs($size[5]-$size[3]);
> $xpad = abs(($tmpl_size[0] - $dx)/2); // x-axis padding
> $ypad = abs(($tmpl_size[1] - $dy)/2); // y-axis padding
>
> ImageTTFText($im, 12, 0, (int)($xpad), $dy+(int)($ypad), -$color,
> DIR_FONTS . $image_data_values['fonts_filename'],
> $image_data_values[@'sites_button' . $num]);
> ImagePng($im);
> ImageDestroy($im);
> }
>
>
> Thanks very much :)
> Mark
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>