Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6745

Re: Batch scale images with PHP/GD?

From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: Batch scale images with PHP/GD?
Date 2012-08-08 18:18 +0200
Message-ID <a8fhq8F6gcU1@mid.individual.net> (permalink)
References <jvtn3a$58j$1@news.albasani.net>

Show all headers | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Batch scale images with PHP/GD? Tuxedo <tuxedo@mailinator.com> - 2012-08-08 14:46 +0200
  Re: Batch scale images with PHP/GD? The Natural Philosopher <tnp@invalid.invalid> - 2012-08-08 14:08 +0100
  Re: Batch scale images with PHP/GD? "J.O. Aho" <user@example.net> - 2012-08-08 18:18 +0200

csiph-web