Re: Coding Help

From: Date: Wed, 18 Oct 2000 09:54:22 +0000
Subject: Re: Coding Help
Groups: php.general 
Request: Send a blank email to php-general+get-20859@lists.php.net to get a copy of this message
Does anyone have a generalize algorithm for making thumbnails out of a photo of unkown size? That is, I'm not going to know the dimensions of the source photo beforehand, and what I'd like to do is to reduce the photo to about 60-80 pixels high, depending on the aspect ratio . . . . Any tips would be greatly appreciated. =))
(1) If you mean a 'fake' resize (simply giving the image tag fake width and height measurements and letting the browser crush it down): Note the getimagesize() function. Among other things, it returns to you the width and height of the image. You can simply pick a fixed width and fixed height you'd like to work with. Say, 80 and 80. Read both the width and height and check which is higher. Then divide the other one by the longer and multiply it by 80. Then, simply spit out the image tag with 80 in the longer of width and height, and the integer returned in the shorter one. (2) If you mean a 'real' resize (actually saving another copy of the image, in order to save the user download time when looking at thumbnails): In PHP, I don't know. We generally create all our images on Macs, and so we automate this process in Photoshop using PhotoScripter and AppleScripts. Then the files are copied to the Web server over AppleTalk. You would be able to accomplish it in PHP, perhaps with the GD library or ImageMagick, though. Anyone else? Cheers, -- Marc Antony Vose http://www.suzerain.com/ Into every tidy scheme for arranging the pattern of human life, it is necessary to inject a certain dose of anarchism. -- Bertrand Russell

« previous php.general (#20859) next »