Creating thumbnails from jpg's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
malpass
Forum Newbie
Posts: 3
Joined: Fri Mar 19, 2004 7:20 am

Creating thumbnails from jpg's

Post 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?
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Re: Creating thumbnails from jpg's

Post 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.
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Re: Creating thumbnails from jpg's

Post 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
Post Reply