note 112274 added to function.exif-read-data
| From: | hoangvu4000 at gmail dot com | Date: | Sun, 26 May 2013 17:47:43 +0000 |
| Subject: | note 112274 added to function.exif-read-data | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194957@lists.php.net to get a copy of this message | ||
This is function, resize image and don't rotates images have exif info
PHP must be enabled:
extension=php_mbstring.dll
extension=php_exif.dll
function CreateThumbnail($pic,$thumb,$thumbwidth, $quality = 100)
{
$im1=ImageCreateFromJPEG($pic);
//if(function_exists("exif_read_data")){
$exif = exif_read_data($pic);
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$im1 = imagerotate($im1,90,0);
break;
case 3:
$im1 = imagerotate($im1,180,0);
break;
case 6:
$im1 = imagerotate($im1,-90,0);
break;
}
}
//}
$info = @getimagesize($pic);
$width = $info[0];
$w2=ImageSx($im1);
$h2=ImageSy($im1);
$w1 = ($thumbwidth <= $info[0]) ? $thumbwidth : $info[0] ;
$h1=floor($h2*($w1/$w2));
$im2=imagecreatetruecolor($w1,$h1);
imagecopyresampled ($im2,$im1,0,0,0,0,$w1,$h1,$w2,$h2);
$path=addslashes($thumb);
ImageJPEG($im2,$path,$quality);
ImageDestroy($im1);
ImageDestroy($im2);
}
----
Server IP: 69.147.83.199
Probable Submitter: 183.80.108.246
----
Manual Page -- http://php.net/manual/en/function.exif-read-data.php
Edit -- https://master.php.net/note/edit/112274
Del: integrated -- https://master.php.net/note/delete/112274/integrated
Del: useless -- https://master.php.net/note/delete/112274/useless
Del: bad code -- https://master.php.net/note/delete/112274/bad+code
Del: spam -- https://master.php.net/note/delete/112274/spam
Del: non-english -- https://master.php.net/note/delete/112274/non-english
Del: in docs -- https://master.php.net/note/delete/112274/in+docs
Del: other reasons-- https://master.php.net/note/delete/112274
Reject -- https://master.php.net/note/reject/112274
Search -- https://master.php.net/manage/user-notes.php