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" 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: References: 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: Xref: csiph.com comp.lang.php:6745 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