Bug #77052 [NEW]: imagescale() rotates image anti-clockwise by 90 degree after scaling
| From: | hyh19962008 at gmail dot com | Date: | Wed, 24 Oct 2018 04:30:32 +0000 |
| Subject: | Bug #77052 [NEW]: imagescale() rotates image anti-clockwise by 90 degree after scaling | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-217671@lists.php.net to get a copy of this message | ||
From: hyh19962008 at gmail dot com
Operating system: Windows Server 2012 R2
PHP version: 7.2.11
Package: GD related
Bug Type: Bug
Bug description:imagescale() rotates image anti-clockwise by 90 degree after scaling
Description:
------------
When scaling an image using the GD function imagescale(), the image is
rotated anti-clockwise by 90 degree automatically.
This happens most frequently when the given image has a greater height
than width, and was shot by camera or mobile.
Test script:
---------------
<?php
$filename="C:\inetpub\wwwroot\\apc\\img\\1.JPG";
$pic=imagecreatefromjpeg($filename);
$ratio=imagesy($pic)/imagesx($pic); //=height/width
$height=136;
$width=136/$ratio;
$pic=imagescale($pic,$width,$height);
imagejpeg($pic,"min//1.jpeg",86);
imagedestroy($pic);
?>
Expected result:
----------------
image with the following w/h
width=136/ratio;
height=136;
height is greater than width, the image should be presented vertically.
Actual result:
--------------
image with the following w/h
width=136;
height=136/ratio;
width is greater than height, the image is presented horizontally,
because it's rotated anti-clockwise by 90 degree comparing to the
original image.
I have uploaded the script and sample picture to my website:
https://www.swuplaf.cn/abc/test.php //script
https://www.swuplaf.cn/abc/img/1.JPG
//original picture
https://www.swuplaf.cn/abc/min/1.jpeg
//scaled picture
--
Edit bug report at https://bugs.php.net/bug.php?id=77052&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77052&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77052&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77052&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77052&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77052&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77052&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77052&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77052&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77052&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77052&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77052&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77052&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77052&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77052&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77052&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77052&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77052&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77052&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77052&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77052&r=mysqlcfg