note 39003 added to function.getimagesize
| From: | yohami dot com-zerodj at hotmail dot com | Date: | Wed, 14 Jan 2004 12:11:12 +0000 |
| Subject: | note 39003 added to function.getimagesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-63513@lists.php.net to get a copy of this message | ||
A cool resize / cropping script for creating thumbnails using mogrify
IMAGETEST.PHP
<?php
include 'mogrify.php';
// variables from flash (my website uses flash and php)
$picture="sample.jpg";
$fixedwidth=300;
$fixedheight=240;
//
cropimage($picture,$fixedwidth,$fixedheight,$mogrify);
?>
MOGRIFY.PHP
<?php
// walking the path
$mogrify="C:/apache/Imagik/mogrify.exe";
// ---------------------------------------- crop function
function cropimage($picture,$fixedwidth,$fixedheight,$mogrify) {
// GET IMG
$img = imagecreatefromjpeg($picture);
$width= imagesx($img);
$height= imagesy($img);
// CROP WIDTH
if($width!=$fixedwidth){
$ratio =$fixedwidth/$width;
$NewHeight=round($height*$ratio);
$NewWidth=round($width*$ratio);
exec( $mogrify." -resize ".$NewWidth."x".$NewHeight."! $picture");
exec( $mogrify." -crop ".$fixedwidth."x".$fixedheight."+0+0
$picture");
// REFRESH
$img = imagecreatefromjpeg($picture);
$width= imagesx($img);
$height= imagesy($img);
}
// CROP HEIGHT
if($height!=$fixedheight){
$ratio =$fixedheight/$height;
$NewHeight=round($height*$ratio);
$NewWidth=round($width*$ratio);
exec( $mogrify." -resize ".$NewWidth."x".$NewHeight."! $picture");
exec( $mogrify." -crop ".$fixedwidth."x".$fixedheight."+0+0
$picture");
}
//
ImageDestroy($img);
}
?>
yeah!
----
Manual Page -- http://www.php.net/manual/en/function.getimagesize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39003
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39003&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39003&report=yes
Search -- http://master.php.net/manage/user-notes.php