note 58061 added to function.imagejpeg
| From: | admin at sellchain dot com | Date: | Sat, 22 Oct 2005 20:42:10 +0000 |
| Subject: | note 58061 added to function.imagejpeg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-97422@lists.php.net to get a copy of this message | ||
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);
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagejpeg.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58061
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58061&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58061&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58061&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58061&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58061&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58061&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58061&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58061&report=yes
Search -- http://master.php.net/manage/user-notes.php