note 58061 deleted from function.imagejpeg by jome
| From: | jome@php.net | Date: | Sun, 23 Oct 2005 09:02:20 +0000 |
| Subject: | note 58061 deleted from function.imagejpeg by jome | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-97441@lists.php.net to get a copy of this message | ||
Note Submitter: admin at sellchain dot com
Reason: useless
----
RESIZE AN IMAGE
JPG SUPPORT ONLY (so far). I don't think this supports any others. I know it doesn't
support GIF.
<?
# ONLY WORKS WITH JPG.
# GIF WILL RETURN A BLACK BLOCK!
# They should work on that. This is a really cool tool
$myimage="http://i2.microsoft.com/h/all/i/ms_masthead_8x6a_ltr.jpg";
# Create image directory
mkdir("C:\image_folder");
# Specify Path of Image
$whereto="C:\image_folder\microsoft_thumb.jpg";
$mywidth=245;
$myheight=35;
$myquality=100;
$resized = ResizeImage($myimage,$whereto,$mywidth,$myheight,$myquality);
if ($resized > 0) {
# Imaged created successfully
echo "Success!";
} ELSE {
# Image failed to be created
echo "Fail!";
}
function ResizeImage($path_in,$path_out,$new_width,$new_height,$quality) {
if ($quality<=0) { $quality=100; }
$width = $new_width;
$height = $new_height;
$new = ImageCreateTrueColor($width, $height);
$source = ImageCreateFromJPEG($path_in);
ImageCopyResampled($new, $source, 0, 0, 0, 0, $width, $height,
ImageSX($source), ImageSY($source));
ImageJPEG($new, $path_out, $quality);
return filesize($path_out);
}
?>