-
Notifications
You must be signed in to change notification settings - Fork 8k
imageresolution Return incorrect DPI #10351
Copy link
Copy link
Closed as not planned
Description
Description
The following code:
<?php
$fullPathNewFileName = '772.jpg';
$img = imagecreatefromjpeg($fullPathNewFileName);
$result = imageresolution($img);
var_dump($result);Resulted in this output:
array(96, 96)
But I expected this output instead:
array(240, 240)
You may test with this jpeg file in zip.
https://gofile.io/d/IiGLN1
or alternative link https://fromsmash.com/sample-jpeg-for-php-get-resolution
Not all images are detected DPI correctly. Only some images are unable to detect and return 96 DPI.
This happens since PHP 7 but PHP 8.2 still occur.
If I use Imagick on PHP 8.1 or any version, it returns correct resolution.
$Img = new Imagick($fullPathNewFileName);
$result = $Img->getImageResolution();
var_dump($result);// array('x' => 240, 'y' => 240)PHP Version
PHP 8.2.0
Operating System
Windows 11 x64
Reactions are currently unavailable