php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75072 imagepng does not produce lossless output when input is lossy
Submitted: 2017-08-13 19:01 UTC Modified: 2017-08-13 22:00 UTC
From: choinnn1 at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: GD related
PHP Version: 7.1.8 OS: Windows 8.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: choinnn1 at gmail dot com
New email:
PHP Version: OS:

 

 [2017-08-13 19:01 UTC] choinnn1 at gmail dot com
Description:
------------
1. Save image: http://www.softaculous.com/blog/wp-content/uploads/2013/04/php-logo.jpeg
as php-logo.jpeg
2. Open php-logo.jpeg in Windows Paint, save as php-logo_paint.png
3. Write a script in PHP to convert php-logo.jpeg into php-logo_php.png

Test script:
---------------
imagepng(imagecreatefromjpeg('C:\php-logo.jpg'), 'C:\php-logo_php.png');

Expected result:
----------------
php-logo_php.png should be visually 100% identical to both php-logo.jpeg and php-logo_paint.png.

Actual result:
--------------
php-logo_php.png contains slightly different colors when compared to php-logo.jpeg and php-logo_paint.png.
See the diff (made with Beyond Compare):
php-logo.jpeg vs php-logo_php.png: http://i.imgur.com/0nY42bF.png
php-logo.jpeg vs php-logo_paint.png: http://i.imgur.com/sjgyHAE.png

Note: php-logo_paint.png is 32-bit PNG image by default for me, but it's not relevant. If I convert it to 24-bit PNG or use Paint.NET instead of Microsoft Paint from the start, the result will be the same.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-13 22:00 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2017-08-13 22:00 UTC] cmb@php.net
> php-logo_php.png should be visually 100% identical to both
> php-logo.jpeg and php-logo_paint.png.

This assumption is not in agreement with the JPEG standard, which
does not require all decoders to produce identical output images.
See also <https://stackoverflow.com/questions/23565889/jpeg-images-have-different-pixel-values-across-multiple-devices#23714501>.
 [2017-08-13 22:28 UTC] choinnn1 at gmail dot com
Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 00:01:32 2024 UTC