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


Groups > comp.lang.php > #6745

Re: Batch scale images with PHP/GD?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: Batch scale images with PHP/GD?
Date Wed, 08 Aug 2012 18:18:15 +0200
Lines 32
Message-ID <a8fhq8F6gcU1@mid.individual.net> (permalink)
References <jvtn3a$58j$1@news.albasani.net>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net zM4ltALxtGa2AoG2KFnN4QVVMuJi6mxkvX/E6TbHtoBmlTdBFsYg5Una8f2spMTXnv
Cancel-Lock sha1:7j8Fljls3uG+DucUbX4BlSWAzkY=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120807 Thunderbird/14.0
In-Reply-To <jvtn3a$58j$1@news.albasani.net>
Xref csiph.com comp.lang.php:6745

Show key headers only | 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