Page 1 of 1

Creating thumbnails from jpg's

Posted: Fri Mar 19, 2004 7:20 am
by malpass
I have made a script that will read a folder containing more folders, each containing more etc... and for each file it finds of .jpg it displays a thumbnail with a src of the jpg's directory/thumbs/jpg's name. If u get me, thats not really important, what is...

I need to create a script that allows a complete novice to add images to the gallery, all they have to do at the mo is upload the image.. but also upload a correctly sized thumbnail of that inside the directories thumbs folder.

Is there a way in Php to dynamically create a thumbnail of a certain size and good compression (IE 10kb max for a 150x150 thumb), or detect if the image has its corresponding thumb image in the thumbs folder, and if not create and upload one itself?

Re: Creating thumbnails from jpg's

Posted: Fri Mar 19, 2004 8:11 am
by TheBentinel.com
malpass wrote: Is there a way in Php to dynamically create a thumbnail of a certain size and good compression (IE 10kb max for a 150x150 thumb), or detect if the image has its corresponding thumb image in the thumbs folder, and if not create and upload one itself?
You can look into imagejpeg(). The man page discusses other image-ish commands native to PHP.
http://us3.php.net/manual/en/function.imagejpeg.php

If they don't do the trick, there's a package called imageMagick that lets you do all sorts of cool stuff to images. You could interface with it via the pass_thru() function.

I use imageMagick to grab comics from the web, flip them sideways, and shrink them so I can view them on my palm. VERY easy to work with.

Re: Creating thumbnails from jpg's

Posted: Fri Mar 19, 2004 8:17 am
by TheBentinel.com
TheBentinel.com wrote:You can look into imagejpeg().
Also take a look at imagecopyresized() http://us3.php.net/manual/en/function.i ... esized.php