|
Posted by Andy Hassall on 10/06/06 17:30
On 6 Oct 2006 09:00:14 -0700, "Alexander Fischer" <happysmithers@hotmail.com>
wrote:
>I am writing a gallery script and use imagecreatefromjpeg and fpassthru
>to output images without any change to them (i.e., no thumbnail
>creation etc. - just deliver the image via the php script). However I
>note that the image creation is quite slow - the user can see that the
>image is created line-by-line, from top to bottom.
Arguably that's the image output rather than creation. The GD library doesn't
stream the image out as it creates it, rather it's all done in memory (which
may take some time, but the browser won't be getting any image data during this
time), then dumped out to the browser in one go.
You'd expect the final output part to be somewhat slower than serving a file
out directly, but no slower than any other large output from PHP - which can
still serve out data quite quickly.
Is all large-ish output from PHP on your server slow? What about compared with
serving static files from the same server?
>Most likely this speed issue comes from PHP, since PHP is simply slower
>than C etc.
>
>However, if I use a "professional" script like e.g. phpThumb, I notice
>that the image display is much, much faster - almost as if I had the
>image displayed directly.
They may well process the image to a temporary location on disk (so it's only
processed once) and then serve it out directly through the webserver, or just
readfile() it (although you mentioned you're using fpassthru which is similar
in purpose).
Looking up phpThumb on Google, it mentions it has the option to process via
ImageMagick, which is less integrated with PHP but can give better performance
for processing photo images (GD is aimed more at generating block graphics
rather than processing photos).
>What can I do to make my images faster? If there's nothing (simple)
>that I can do, is there at least a way to make the images as
>progressive JPGs, i.e. they don't build up from top to bottom
>line-by-line, but the image starts as a blurry image and gets sharper
>with time?
The GD library has an interlacing option, which (according to the docs anyway)
for JPEG it actually interprets as using progressive mode - look up
imageinterlace().
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
[Back to original message]
|