Re: Image Resizing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i use imageMagick:

<?php

$image_path = "../images/myimage.jpg";       //path to the image from my
script
$thumb_path = "../thumbnails/mymage.jpg";    //path to where i want the
thumbnail to be created

$width = 100;     //greatest allowed width for my thumbnails
$height = 100;     //greatest allowed height for my thumbnails

//make the thumbnail
//imageMagick will automatically adjust for aspect ratio with this command
line
//however, if you want to force a thumbnail to the preset dimensions,
//put an exclamation point after $height

//http://www.imagemagick.org/Magick++/Geometry.html

$command_line = "convert -geometry $width" . "x" . "$height $image_path
$thumb_path";

system($command_line, $return_var);

if ($return_var == 1) {

    echo "Thumbnail creation failed! :(";

} else {

    echo "Thumbnail created. :) <a href='$thumb_path' target='_blank'>View
Thumbnail FFS</a>";

}

?>

if you run into problems, and assuming imageMagick was successfully
installed:

- make sure you have write permission for where you want the thumbnail to be
created

- try replacing convert with the full path to the convert app.
    e.g.
     $command_line = "/usr/bin/convert -geometry ....etc";

- run the script from the command line.  ssh in to your script's directory
and try typing this:

     php thumbscript.php

   you'll see verbose messages to help you pinpoint the problem. depending
on your setup, you might have to put in the full path to php

- if you're still stuck, try putting in this line:

   <?php
   ini_set("display_errors","1");

information like this would have saved me hours of my life




On Sun, Dec 21, 2008 at 3:54 AM, Kevin Waterson <kevin@xxxxxxxxx> wrote:

> This one time, at band camp, Stephen Alistoun <stephenalistoun@xxxxxxxxx>
> wrote:
>
>
> > I want all the images to resize to 100px width but the height adjusts
> > automatically.
>
>
> Two ways, GD or Imagick
>
> http://www.phpro.org/examples/GD-Thumbnail-Based-On-Image-Type.html
>
> http://www.phpro.org/tutorials/Imagick.html#4
>
> Kevin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Crunchmutt Studios
Latest News Headlines: http://www.rssvideonews.com
http://www.imagepoop.com
http://www.crunchmutt.com
http://www.deadjoe.com
http://www.dailymedication.com
http://www.extremesportclips.com
http://www.coolanimalclips.com
http://www.robotclips.com
http://www.newsfinger.com
http://www.postyourimage.com
http://www.nakedalarmclock.com

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux