[php-src] Issue #10351: imageresolution Return incorrect DPI
| From: | ve3 | Date: | Mon, 16 Jan 2023 21:09:04 +0000 |
| Subject: | [php-src] Issue #10351: imageresolution Return incorrect DPI | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243469@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10351
Author: ve3
### Description
The following code:
```php
<?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
Not all images are detected DPI correctly. Only some images are unable to detect and return 96 DPI.
This happens since PHP 7 or older but PHP 8.2 still occur.
If I use Imagick on PHP 8.1 or any version, it returns correct resolution.
```php
$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