Home »
Imported messages »
comp.lang.php »
Batch scale images with PHP/GD?
Re: Batch scale images with PHP/GD? [message #178817 is a reply to message #178809] |
Wed, 08 August 2012 16:18  |
J.O. Aho
Messages: 194 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 08/08/12 14:46, Tuxedo wrote:
> Using PHP/GD, does anyone have an example how to process jpg and png files
> in the current directory to place smaller versions in a specified
> sub-directory (e.g. thumbs/) while retaining original aspect ratio, so that
> only the resized width or height need to be specified on the command line?
I prefer to use imagemagick, has more features and you can use seam
carving if you make some dimension changes when you scale down your image.
Good example on what you can do with imagemagick can be found at
valokuva.org (Mikko's blog, the guy who maintains the imagemagick
extension for PHP).
A seam carving example: http://valokuva.org/?m=200802
If you want it to be saved to a file instead, then remove the
/* Display */
header( 'Content-Type: image/jpg' );
echo $im;
and replace it with
/* Save to file */
$im->writeImage('test.png');
$im->clear();
$im->destroy();
--
//Aho
|
|
|
Goto Forum:
Current Time: Tue Apr 29 08:29:18 GMT 2025
Total time taken to generate the page: 0.04705 seconds