Linux png compression issue

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Myrecs
Posts: 12
Joined: 2017-08-17T15:41:13-07:00
Authentication code: 1151

Linux png compression issue

Post by Myrecs » 2017-08-17T15:48:05-07:00

Two systems: Win10 and CentOs7, same php code, the resulting image is png file. On windows compression works even if i dont specify Image Compression option and the result file size is 400 kb, on CentOs even with Compression params image is not compressed and it's size is about 1,2 mb. How could it be? All versions of IM are the same on both servers.

User avatar
fmw42
Posts: 25403
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Linux png compression issue

Post by fmw42 » 2017-08-17T15:58:36-07:00

What are your IM versions exactly with the dates included? What versions of libpng are being used on both systems? What is the input format and are the delegate libraries for the input format the same on both systems and at what version.

What is your exact command line with values not variables?

Myrecs
Posts: 12
Joined: 2017-08-17T15:41:13-07:00
Authentication code: 1151

Re: Linux png compression issue

Post by Myrecs » 2017-08-18T00:13:21-07:00

At first it was 3.4.3RC4 and then i tried 3.4.3 with the same results. It is what shows phpinfo(), but in convert -version output is

CentOs - Version: ImageMagick 6.7.8-9 2016-06-16 Q16
Windows - Version: ImageMagick 6.9.3-7 Q16 x64 2016-03-27

libpng on CentOs - (libpng 1.5.13)
on Windows - (libpng 1.6.20)
input format - jpg.
how can i check if the delegaye libraries are the same for input format?
i make some transformations in my php script and then standart output

Code: Select all

$shadow2->setImageFormat('png');
$shadow2->setImageCompression(Imagick::[i]*here i've tried all compression constants*[/i]); 
$shadow2->setImageCompressionQuality(75); 
$shadow2->writeImage(.../file.png);
ps. i've tested a simple conversion on 2 servers

Code: Select all

$base_file_path= "../file1.jpg";
$int_file_path= "../file2.png";
$int_im = new Imagick($base_file_path);
$int_im->setImageFormat('png');
$int_im->writeImage($int_file_path);
and the result is 9,2 Mb on CentOs and 6,7 on Windows

ps2. i've also tried to recompress created file with GD (an with IMagick also) and GD works fine (IM still leaves size unchanged)! so the problem is in IMagick?

User avatar
fmw42
Posts: 25403
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Linux png compression issue

Post by fmw42 » 2017-08-18T09:34:41-07:00

In command line or PHP exec(), use

convert -list format

and look at the lines for each format image, JPG and PNG and it will tell you the delegate version.

For me I get

JPG* JPEG rw- Joint Photographic Experts Group JFIF format (90)
PNG* PNG rw- Portable Network Graphics (libpng 1.6.30)

Your reported two PNG versions are quite different, with the CENTOS system having a much older version. I would suggest that you upgrade them both the latest versions.

Note that PNG compression does not work like JPG compression. The quality values mean different things. See http://www.imagemagick.org/script/comma ... hp#quality

User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Linux png compression issue

Post by glennrp » 2017-08-18T11:31:06-07:00

Could you post your two PNG output files somewhere that we can retrieve them
or if you prefer, run "pngcheck -v file.png" on both and post the result here?

Myrecs
Posts: 12
Joined: 2017-08-17T15:41:13-07:00
Authentication code: 1151

Re: Linux png compression issue

Post by Myrecs » 2017-08-18T14:07:25-07:00

script:

Code: Select all

$int_im = new Imagick($base_file_path);
$int_im->scaleImage(1000,1000,true);
$int_im->setImageFormat('png');
$int_im->writeImage($int_file_path);
(by the way, this conversion i made on another win machine with not the latest IM and as for Linux i also tried to do conversion on another CentOs server and results are the same as before)
pngcheck output:

win ver:

Code: Select all

> d:\pngcheck\pngcheck.exe -v D:\OpenServer\domains\localhost\win.png
File: D:\OpenServer\domains\localhost\win.png (1159827 bytes)
  chunk IHDR at offset 0x0000c, length 13
    1000 x 625 image, 24-bit RGB, non-interlaced
  chunk cHRM at offset 0x00025, length 32
    White x = 0.3127 y = 0.329,  Red x = 0.64 y = 0.33
    Green x = 0.3 y = 0.6,  Blue x = 0.15 y = 0.06
  chunk bKGD at offset 0x00051, length 6
    red = 0x00ff, green = 0x00ff, blue = 0x00ff
  chunk pHYs at offset 0x00063, length 9: 3779x3779 pixels/meter (96 dpi)
  chunk tIME at offset 0x00078, length 7: 18 Aug 2017 20:51:20 UTC
  chunk zTXt at offset 0x0008b, length 435, keyword: Raw profile type exif
  chunk zTXt at offset 0x0024a, length 873, keyword: Raw profile type xmp
  chunk IDAT at offset 0x005bf, length 32768
    zlib: deflated, 32K window, maximum compression
  chunk IDAT at offset 0x085cb, length 32768
  chunk IDAT at offset 0x105d7, length 32768
  chunk IDAT at offset 0x185e3, length 32768
  chunk IDAT at offset 0x205ef, length 32768
  chunk IDAT at offset 0x285fb, length 32768
  chunk IDAT at offset 0x30607, length 32768
  chunk IDAT at offset 0x38613, length 32768
  chunk IDAT at offset 0x4061f, length 32768
  chunk IDAT at offset 0x4862b, length 32768
  chunk IDAT at offset 0x50637, length 32768
  chunk IDAT at offset 0x58643, length 32768
  chunk IDAT at offset 0x6064f, length 32768
  chunk IDAT at offset 0x6865b, length 32768
  chunk IDAT at offset 0x70667, length 32768
  chunk IDAT at offset 0x78673, length 32768
  chunk IDAT at offset 0x8067f, length 32768
  chunk IDAT at offset 0x8868b, length 32768
  chunk IDAT at offset 0x90697, length 32768
  chunk IDAT at offset 0x986a3, length 32768
  chunk IDAT at offset 0xa06af, length 32768
  chunk IDAT at offset 0xa86bb, length 32768
  chunk IDAT at offset 0xb06c7, length 32768
  chunk IDAT at offset 0xb86d3, length 32768
  chunk IDAT at offset 0xc06df, length 32768
  chunk IDAT at offset 0xc86eb, length 32768
  chunk IDAT at offset 0xd06f7, length 32768
  chunk IDAT at offset 0xd8703, length 32768
  chunk IDAT at offset 0xe070f, length 32768
  chunk IDAT at offset 0xe871b, length 32768
  chunk IDAT at offset 0xf0727, length 32768
  chunk IDAT at offset 0xf8733, length 32768
  chunk IDAT at offset 0x10073f, length 32768
  chunk IDAT at offset 0x10874b, length 32768
  chunk IDAT at offset 0x110757, length 32768
  chunk IDAT at offset 0x118763, length 9993
  chunk tEXt at offset 0x11ae78, length 65, keyword: comment
  chunk tEXt at offset 0x11aec5, length 37, keyword: date:create
  chunk tEXt at offset 0x11aef6, length 37, keyword: date:modify
  chunk tEXt at offset 0x11af27, length 46, keyword: exif:Artist
  chunk tEXt at offset 0x11af61, length 35, keyword: exif:Copyright
  chunk tEXt at offset 0x11af90, length 20, keyword: exif:ExifOffset
  chunk tEXt at offset 0x11afb0, length 42, keyword: exif:ImageDescription
  chunk tEXt at offset 0x11afe6, length 30, keyword: exif:Make
  chunk tEXt at offset 0x11b010, length 31, keyword: exif:Model
  chunk zTXt at offset 0x11b03b, length 107, keyword: exif:WinXP-Author
  chunk zTXt at offset 0x11b0b2, length 85, keyword: exif:WinXP-Comments
  chunk zTXt at offset 0x11b113, length 109, keyword: exif:WinXP-Keywords
  chunk zTXt at offset 0x11b18c, length 84, keyword: exif:WinXP-Subject
  chunk zTXt at offset 0x11b1ec, length 82, keyword: exif:WinXP-Title
  chunk zTXt at offset 0x11b24a, length 53, keyword: unknown
  chunk IEND at offset 0x11b28b, length 0
No errors detected in D:\OpenServer\domains\localhost\win.png (59 chunks, 38.1% compression).

centos ver:

Code: Select all

> d:\pngcheck\pngcheck.exe -v D:\OpenServer\domains\localhost\cent.png
File: D:\OpenServer\domains\localhost\cent.png (1570201 bytes)
  chunk IHDR at offset 0x0000c, length 13
    1000 x 625 image, 24-bit RGB, non-interlaced
  chunk gAMA at offset 0x00025, length 4: 0.45455
  chunk sRGB at offset 0x00035, length 1
    rendering intent = perceptual
  chunk cHRM at offset 0x00042, length 32
    White x = 0.3127 y = 0.329,  Red x = 0.64 y = 0.33
    Green x = 0.3 y = 0.6,  Blue x = 0.15 y = 0.06
  chunk bKGD at offset 0x0006e, length 6
    red = 0x00ff, green = 0x00ff, blue = 0x00ff
  chunk pHYs at offset 0x00080, length 9: 3779x3779 pixels/meter (96 dpi)
  chunk IDAT at offset 0x00095, length 32768
    zlib: deflated, 32K window, maximum compression
  chunk IDAT at offset 0x080a1, length 32768
  chunk IDAT at offset 0x100ad, length 32768
  chunk IDAT at offset 0x180b9, length 32768
  chunk IDAT at offset 0x200c5, length 32768
  chunk IDAT at offset 0x280d1, length 32768
  chunk IDAT at offset 0x300dd, length 32768
  chunk IDAT at offset 0x380e9, length 32768
  chunk IDAT at offset 0x400f5, length 32768
  chunk IDAT at offset 0x48101, length 32768
  chunk IDAT at offset 0x5010d, length 32768
  chunk IDAT at offset 0x58119, length 32768
  chunk IDAT at offset 0x60125, length 32768
  chunk IDAT at offset 0x68131, length 32768
  chunk IDAT at offset 0x7013d, length 32768
  chunk IDAT at offset 0x78149, length 32768
  chunk IDAT at offset 0x80155, length 32768
  chunk IDAT at offset 0x88161, length 32768
  chunk IDAT at offset 0x9016d, length 32768
  chunk IDAT at offset 0x98179, length 32768
  chunk IDAT at offset 0xa0185, length 32768
  chunk IDAT at offset 0xa8191, length 32768
  chunk IDAT at offset 0xb019d, length 32768
  chunk IDAT at offset 0xb81a9, length 32768
  chunk IDAT at offset 0xc01b5, length 32768
  chunk IDAT at offset 0xc81c1, length 32768
  chunk IDAT at offset 0xd01cd, length 32768
  chunk IDAT at offset 0xd81d9, length 32768
  chunk IDAT at offset 0xe01e5, length 32768
  chunk IDAT at offset 0xe81f1, length 32768
  chunk IDAT at offset 0xf01fd, length 32768
  chunk IDAT at offset 0xf8209, length 32768
  chunk IDAT at offset 0x100215, length 32768
  chunk IDAT at offset 0x108221, length 32768
  chunk IDAT at offset 0x11022d, length 32768
  chunk IDAT at offset 0x118239, length 32768
  chunk IDAT at offset 0x120245, length 32768
  chunk IDAT at offset 0x128251, length 32768
  chunk IDAT at offset 0x13025d, length 32768
  chunk IDAT at offset 0x138269, length 32768
  chunk IDAT at offset 0x140275, length 32768
  chunk IDAT at offset 0x148281, length 32768
  chunk IDAT at offset 0x15028d, length 32768
  chunk IDAT at offset 0x158299, length 32768
  chunk IDAT at offset 0x1602a5, length 32768
  chunk IDAT at offset 0x1682b1, length 32768
  chunk IDAT at offset 0x1702bd, length 32768
  chunk IDAT at offset 0x1782c9, length 29084
  chunk tEXt at offset 0x17f471, length 65, keyword: comment
  chunk tEXt at offset 0x17f4be, length 37, keyword: date:create
  chunk tEXt at offset 0x17f4ef, length 37, keyword: date:modify
  chunk tEXt at offset 0x17f520, length 17, keyword: jpeg:colorspace
  chunk tEXt at offset 0x17f53d, length 32, keyword: jpeg:sampling-factor
  chunk tEXt at offset 0x17f569, length 8, keyword: rdf:Alt
  chunk tEXt at offset 0x17f57d, length 8, keyword: rdf:Bag
  chunk IEND at offset 0x17f591, length 0
No errors detected in D:\OpenServer\domains\localhost\cent.png (62 chunks, 16.3% compression).

different compressions.
fmw42, thanks, i know about png compressions and that they differ from jpeg but none works for me, all compression variants produced no result.
from yum repo it says that libpng is the latest

Code: Select all

convert -list format (centos):
   JPEG* JPEG      rw-   Joint Photographic Experts Group JFIF format (62)
   JPG* JPEG      rw-   Joint Photographic Experts Group JFIF format (62)
    PNG* PNG       rw-   Portable Network Graphics (libpng 1.5.13)
    PNG24* PNG       rw-   opaque 24-bit RGB (zlib 1.2.7)

User avatar
fmw42
Posts: 25403
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Linux png compression issue

Post by fmw42 » 2017-08-18T16:08:27-07:00

That may be the latest your server is providing but not the latest version. As I mentioned above I am at

PNG* PNG rw- Portable Network Graphics (libpng 1.6.30)

Perhaps your hosting provider can upgrade the libpng delegate.

Nevertheless, I will leave it in the hands of glennrp, the PNG expert.

Myrecs
Posts: 12
Joined: 2017-08-17T15:41:13-07:00
Authentication code: 1151

Re: Linux png compression issue

Post by Myrecs » 2017-08-19T14:39:06-07:00

my version of libpng is 2015 (1.5.3) year released, it is not the latest, but i dont think it is so outdated that cant compress png image normally.

Myrecs
Posts: 12
Joined: 2017-08-17T15:41:13-07:00
Authentication code: 1151

Re: Linux png compression issue

Post by Myrecs » 2017-08-20T02:23:48-07:00

and here is zoomed fragment of Alpha Channel Extraction of Imagick object where there is no alpha at all
$alphaChannel->setImageAlphaChannel(Imagick::ALPHACHANNEL_EXTRACT);
result:
Image
artifacts.

and again on Win everything works fine.
sad situation. it wolud be great if someone explain where to dig to solve the problems. what can cause all this troubles?
i dont think it can be something with hardware, i tested it on 2 different vps servers, but the result was the same as both systems were CentOs7 and same versions of IMagick (latest for CentOs).

fmw42, on what system do you work?

User avatar
fmw42
Posts: 25403
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Linux png compression issue

Post by fmw42 » 2017-08-20T11:18:45-07:00

I think you may need to post your input jpg and your two output pngs, so the PNG developer can try to reproduce the problem or some of us can test ourselves. You can upload to some free hosting service that won't change the image and put the URLs here.

Have you tried running your conversion in command line mode or even PHP exec() to see what you get as results. Perhaps it is associate with your environments for Imagick.

Myrecs
Posts: 12
Joined: 2017-08-17T15:41:13-07:00
Authentication code: 1151

Re: Linux png compression issue

Post by Myrecs » 2017-08-21T07:13:53-07:00

yes i tried "convert file.jpg file.png" and result was the same.
as i understand png expert has dissappeared)

Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Linux png compression issue

Post by Bonzo » 2017-08-21T07:30:48-07:00

as i understand png expert has dissappeared)
That might be due to you not answering his question:
Could you post your two PNG output files somewhere that we can retrieve them
or if you prefer, run "pngcheck -v file.png" on both and post the result here?

Myrecs
Posts: 12
Joined: 2017-08-17T15:41:13-07:00
Authentication code: 1151

Re: Linux png compression issue

Post by Myrecs » 2017-08-21T07:32:37-07:00

so the output that i've posted is not an output for you?)

Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Linux png compression issue

Post by Bonzo » 2017-08-21T07:40:04-07:00

Sorry I did not fully take in the output you posted ; I was expecting the images.

Myrecs
Posts: 12
Joined: 2017-08-17T15:41:13-07:00
Authentication code: 1151

Re: Linux png compression issue

Post by Myrecs » 2017-08-21T07:42:24-07:00

if you have some suggestions about what could it be i'll be much appreciated for explanation

Post Reply