Page 1 of 2 12 LastLast
Results 1 to 30 of 31

Thread: CryoPNG short introduction

  1. #1
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts

    cryopng short introduction

    Cryopng is OptiPNG with a dirty hack at the libpng level to actually perform a kind of advanced "Dirty Transparency" cleaning.
    As explained by Sergey Chikuyonok (in this Smashing Magazine article) fully transparent pixels could have any RGB component since they are actually invisible, he suggested to turn them to black (0,0,0) to improve compression. A few tools have since implemented this trick (PunyPNG, PngOptimizer, ImageOptim...), but if you look closely at the PNG specifications you'll notice that images are filtered before being compressed. Cryopng turns fully transparent pixels into something that will be nullified once filtered, and this can positively affect compression.

    For instance the following mouse sample image used by PunyPNG (sizes in bytes):
    228,066 Original
    111,945 PunyPNG
    105,035 Cryogen-x (cryopng script, also uses PNGOUT and DeflOpt)


    For illustration purposes:

    Top left: picture with alpha channel activated.
    Top center: filter 0 (None) is nullified, fully transparent pixels are all black (classic dirty transparency)
    Top right: filter 1 (Sub) is nullified, a fully transparent pixel has the same colour as its left neighbour
    Bottom left: filter 2 (Up) is nullified, a fully transparent pixel has the same colour as its upper neighbour
    Bottom center: filter 3 (Average) is nullified, a fully transparent pixel has the same colour as the average of its left and upper neighbours
    Bottom right: filter 4 (Paeth) is nullified, a fully transparent pixel has the same colour as whether its left, upper or upper left neighbour (Paeth predicator is a powerful mess)
    Attached Files Attached Files
    Last edited by caveman; 28th May 2013 at 17:03. Reason: Added 64-bits Linux binary

  2. #2
    Member
    Join Date
    May 2008
    Location
    England
    Posts
    309
    Thanks
    0
    Thanked 1 Time in 1 Post
    I've been following this for about the last 5 months and it can do some great stuff but have also found images which it removes visible(ie no alpha/trans) pixels from so stopped messing around with it.

    And you're Frédéric Kayser? (yes i frequent the jonof forums ;p) or are you pretending to be him? as on those forums he replies to some of your questions...and you reply to those answers etc...smells fishy to me! at least confusing if you are talking to yourself on those forums lol.

  3. #3
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    Quote Originally Posted by Intrinsic View Post
    I've been following this for about the last 5 months and it can do some great stuff but have also found images which it removes visible(ie no alpha/trans) pixels from so stopped messing around with it.

    And you're Frédéric Kayser? (yes i frequent the jonof forums ;p) or are you pretending to be him? as on those forums he replies to some of your questions...and you reply to those answers etc...smells fishy to me! at least confusing if you are talking to yourself on those forums lol.
    Since JonoF forums closed a few weeks ago I'm moving over to the encode.ru forums.

    Do you still have the images you mentioned? I did not encounter such behaviour, but I have stopped checking perfect match between optimized and non optimized images, visual inspection seemed fine enough. On which operating system did you try CryoPNG?

    And yes, you're right I used two identities (I forgot Caveman's password once and could not access my private email from work so I created "Frederic Kayser" which is indeed my real name and it flattered my ego somewhat, since JonoF's Forum are now read only I just updated my nickname ).
    Last edited by caveman; 4th April 2011 at 22:45.

  4. #4
    Member
    Join Date
    May 2008
    Location
    England
    Posts
    309
    Thanks
    0
    Thanked 1 Time in 1 Post
    This one, at least i think it was CryoPNG, could have been x128's TruePNG though which also had some odd transparency bugs but those were fixed in the most recent version.
    http://uk.riftgame.com/img/classes/c...ing-cleric.png

    And yeah i noticed the forums were closed down which is a shame.

    Edit: And it was the dec 2010 windows version.
    Last edited by Intrinsic; 4th April 2011 at 22:33.

  5. #5
    Member m^2's Avatar
    Join Date
    Sep 2008
    Location
    Ślůnsk, PL
    Posts
    1,422
    Thanks
    6
    Thanked 26 Times in 20 Posts
    Sounds interesting. Any chance that we get sources or binaries?

  6. #6
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    Quote Originally Posted by Intrinsic View Post
    This one, at least i think it was CryoPNG, could have been x128's TruePNG though which also had some odd transparency bugs but those were fixed in the most recent version.
    http://uk.riftgame.com/img/classes/c...ing-cleric.png

    And yeah i noticed the forums were closed down which is a shame.

    Edit: And it was the dec 2010 windows version.
    I will check this on a Linux box, I do not have a Windows system at hand right now.
    By the way, I'm not sure but during my tests I've found that pngslim 1.0 had some problems calling pngoptimizercl when run in Windows Vista or 7 (XP was fine). I think I've found an easy fix for this, line 58 should be modified this way (simply add quotation marks around %1):
    Code:
    pngoptimizercl -file:"%1" >nul
    I have improved the Unix cryogen scripts lately (not released yet), CryoPNG binaries have not changed.

    Quote Originally Posted by m^2 View Post
    Sounds interesting. Any chance that we get sources or binaries?
    I will probably (re)release everything by the end of the week including improved scripts, if you follow the old discussion in JonoF's forum from here, you'll find Linux x86, Mac OS X and Windows binaries.
    Last edited by caveman; 4th April 2011 at 23:36. Reason: to answer m^2

  7. #7
    Member m^2's Avatar
    Join Date
    Sep 2008
    Location
    Ślůnsk, PL
    Posts
    1,422
    Thanks
    6
    Thanked 26 Times in 20 Posts
    Quote Originally Posted by caveman View Post
    I will probably (re)release everything by the end of the week including improved scripts, if you follow the old discussion in JonoF's forum from here, you'll find Linux x86, Mac OS X and Windows binaries.
    OK, thanks.

  8. #8
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    Quote Originally Posted by Intrinsic View Post
    This one, at least i think it was CryoPNG, could have been x128's TruePNG though which also had some odd transparency bugs but those were fixed in the most recent version.
    http://uk.riftgame.com/img/classes/c...ing-cleric.png
    I did not find anything suspicious, I used all filters independently and converted the result using ImageMagick: convert source.png -alpha background target.png this produced exactly the same file each time, I will check on Windows 7 tomorrow.

    calling-cleric.png
    260,770 Original
    242,294 Cryogen-x

    I have enclosed the file produced by cryogen-x.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	calling-cleric-cryox.png 
Views:	173 
Size:	236.6 KB 
ID:	1518  

  9. #9
    Member
    Join Date
    May 2008
    Location
    England
    Posts
    309
    Thanks
    0
    Thanked 1 Time in 1 Post
    Yeah it seems fine so i did some checking and retesting and it turned out to be PNGKT killing off some pixels ;p

    Plus there is another new tool just out, PNGWolf.

    http://bjoern.hoehrmann.de/pngwolf/

    If anyone can knockup a win32 binary that'd be cool ;p

  10. #10
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    Quote Originally Posted by Intrinsic View Post
    Plus there is another new tool just out, PNGWolf.

    http://bjoern.hoehrmann.de/pngwolf/

    If anyone can knockup a win32 binary that'd be cool ;p
    It uses the Deflate implementation from 7-Zip and a genetic algorithm to select filters, really interesting!
    OptiPNG uses the heuristic defined in RFC2083:
    "The following simple heuristic has performed well in early tests: compute the output scanline using all five filters, and select the filter that gives the smallest sum of absolute values of outputs. (Consider the output bytes as signed differences for this test.) This method usually outperforms any single fixed filter choice. However, it is likely that much better heuristics will be found as more experience is gained with PNG."

    I believe that PNGOUT uses different heuristics, pngcheck can be used to display the filter used on each line:
    Code:
    pngcheck -vv twit.png
    
    File: twit.png (2013 bytes)
      chunk IHDR at offset 0x0000c, length 13
        32 x 32 image, 32-bit RGB+alpha, non-interlaced
      chunk IDAT at offset 0x00025, length 1956
        zlib: deflated, 32K window, fast compression
        row filters (0 none, 1 sub, 2 up, 3 avg, 4 paeth):
          1 4 4 4 1 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 2 4 4 1
          1 1 1 1 3 1 1 (32 out of 32)
      chunk IEND at offset 0x007d5, length 0

  11. #11
    Member
    Join Date
    May 2008
    Location
    England
    Posts
    309
    Thanks
    0
    Thanked 1 Time in 1 Post
    PNGOUTs is a lot simpler, basically 0 for indexed and 5 for anything else ;p his tests are a bit iffy though. He uses brute force using his own tool but for example uses pngout without any other options, and only z4 for advpng, where other levels can give better results. But still it has a lot of promise.

    He has a bunch more info here: http://thread.gmane.org/gmane.comp.graphics.png.devel/

    And also plenty of discussion on it.

  12. #12
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    Quote Originally Posted by Intrinsic View Post
    PNGOUTs is a lot simpler, basically 0 for indexed and 5 for anything else ;p
    5 is the "mixed" mode where each line is filtered independently using filter 0, 1, 2, 3 or 4. What Bjoern is trying to do is to find an effective way to choose which filter is the best for each line and the overall image compression.

  13. #13
    Member
    Join Date
    Apr 2011
    Location
    Earth
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Intrinsic View Post
    his tests are a bit iffy though. He uses brute force using his own tool but for example uses pngout without any other options, and only z4 for advpng, where other levels can give better results.
    It is true for all the tools that certain settings beyond the ones I've chosen produce better results on occasion, 'pngwolf' is no exception. However, an exhaustive search for all the options is infeasible, so I went with the maximum suggested settings as best as I know them. I do very much encourage others to conduct tests they find more suitable and publish their findings.

  14. #14
    Member
    Join Date
    May 2008
    Location
    England
    Posts
    309
    Thanks
    0
    Thanked 1 Time in 1 Post
    Welcome Bjoern! I only just found your new tool recently and it's very exciting and can't wait to see what else you have in store for it. It's certainly something i'd work into my PNG compression tool once i am in a position to restart work on it and when combined with deflopt and defluff could produce some great results no doubt.

    Plenty of very wise heads here to bounce ideas off of as i don't think many watch the gmain list.

  15. #15
    Member
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    48
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Intrinsic
    If it is possible an example where PNGKT or TruePng spoils a picture?

    I Now will hand over all information X128, I just with it spoke today

  16. #16
    Member
    Join Date
    May 2008
    Location
    England
    Posts
    309
    Thanks
    0
    Thanked 1 Time in 1 Post
    This one Lorents is an example:
    http://uk.riftgame.com/img/classes/c...ing-cleric.png

    Only PNGKT had problems, it removes valid pixels or changes the colour value of them incorrectly. I noticed this as IrfanView i can easily displays colour totals and i saw the processed image had less colours. So i put it into a paint program and did a difference(+plus boosted levels to clearly show the problem) process on the images and saw the changes when there shouldn't be any. See the attached image.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Cleric_PNGKT-Difference_Image.png 
Views:	142 
Size:	188 Bytes 
ID:	1519  

  17. #17
    Member
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    48
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Intrinsic
    Now I will hand over this information x128, wait updating PNGKT in the near future.

  18. #18
    Member
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    48
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Intrinsic
    Look at the attached picture, here it is accurate advantages PNGKT are visible.
    As you could notice, in your picture of loss insignificant.
    It is possible to use TruePng for clearing, completely without quality loss.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	comic_book_guy.png 
Views:	800 
Size:	87.4 KB 
ID:	1520  

  19. #19
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    I did a quick test today, I tried to compress an RGBA image as two separate images (RGB and Alpha) and the overall size of the two images was smaller compared to the RGBA image.

    RGBA : 105,035
    RGB : 89,562
    Alpha : 7,066

    RGB + Alpha = 96,628

    I've always thought that compressing images as RGBA was a bad idea, RGB and Alpha should be considered as two different data sources.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	mouse-alpha-slim.png.png 
Views:	122 
Size:	6.9 KB 
ID:	1554   Click image for larger version. 

Name:	mouse-RGB-slim.png.png 
Views:	120 
Size:	87.5 KB 
ID:	1555  

  20. #20
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    Two more samples:

    bigmac.png
    RGBA : 33,906
    RGB : 28,721
    Alpha : 2,233
    RGB + Alpha = 30,954

    getadrink.png
    RGBA : 65,317
    RGB : 53,734
    Alpha : 6,162
    RGB + Alpha = 59,896

    ImageMagick "convert" can easily be used to split an RGBA image:
    convert RGBA.png -alpha off RGB.png
    convert RGBA.png -alpha extract Alpha.png
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	bigmac-alpha-slim.png 
Views:	99 
Size:	2.2 KB 
ID:	1556   Click image for larger version. 

Name:	bigmac-RGB-slim.png 
Views:	116 
Size:	28.0 KB 
ID:	1557   Click image for larger version. 

Name:	getadrink-alpha-slim.png 
Views:	97 
Size:	6.0 KB 
ID:	1558   Click image for larger version. 

Name:	getadrink-RGB-slim.png 
Views:	104 
Size:	52.5 KB 
ID:	1559  

  21. #21
    Member
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    48
    Thanks
    7
    Thanked 0 Times in 0 Posts

  22. #22
    Member Karhunen's Avatar
    Join Date
    Dec 2011
    Location
    USA
    Posts
    86
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Would you use ImageMagick's composite to "rejoin them" as follows:
    RGBalphamask.png RGB.png -compose CopyOpacity -alpha on RGBAresult.png
    Or do yo have a different solution ? Also, any ideas on setting BackGround color and select Alpha Transparencies on the command line ?
    I can only use TweakPNG to set individual alpha indicies.

  23. #23
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    Quote Originally Posted by Karhunen View Post
    Also, any ideas on setting BackGround color and select Alpha Transparencies on the command line ?
    I can only use TweakPNG to set individual alpha indicies.
    As far as I know there's no command line tool that lets you directly modify tRNS or bKGD chunks, have you asked on ImageMagick's support forums/mailing lists?
    Last edited by caveman; 19th April 2012 at 17:28.

  24. #24
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    Quote Originally Posted by Karhunen View Post
    Would you use ImageMagick's composite to "rejoin them" as follows:
    RGBalphamask.png RGB.png -compose CopyOpacity -alpha on RGBAresult.png
    Or do yo have a different solution ?
    Had to do it today (I needed to move the alpha channel from one image to another), this command worked for me:
    convert RGB.png Alpha.png -compose Copy_Opacity -composite RGBAresult.png
    Last edited by caveman; 19th April 2012 at 17:30.

  25. #25
    Member Karhunen's Avatar
    Join Date
    Dec 2011
    Location
    USA
    Posts
    86
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by caveman View Post
    Had to do it today (I needed to move the alpha channel from one image to another), this command worked for me:
    convert RGB.png Alpha.png -compose Copy_Opacity -composite RGBAresult.png
    I was looking for the answer for this since I first posted it, and now I notice that Caveman answered it awhile back. As you noticed, transparency masks can compress quite differently from the RGB image. My motivation was testing FreeArc with two bitmaps, a PNM file and a windows BMP paletted file.

    Btw, my transparency mask (BMP) seems to have 11 unique colors. I notice that they are greyscales of uniform distribution (see below). Is this redundancy i.e. aren't all Alpha Channels bi-level images ?
    The command line that worked for me was convert RGB.pnm Alpha.bmp -compose Copy_Opacity -composite RGBAresult.png
    Thanks!

    PAL
    16
    0 0 0
    17 17 17
    34 34 34
    51 51 51
    68 68 68
    85 85 85
    102 102 102
    119 119 119
    136 136 136
    153 153 153
    170 170 170
    187 187 187
    204 204 204
    221 221 221
    238 238 238
    255 255 255

  26. #26
    Member Karhunen's Avatar
    Join Date
    Dec 2011
    Location
    USA
    Posts
    86
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by caveman View Post
    As far as I know there's no command line tool that lets you directly modify tRNS or bKGD chunks, have you asked on ImageMagick's support forums/mailing lists?
    GBMTOOLS allows command line chunks bkGD and tRNS, as long as the alpha is unassociated with the RGB:

    back_index=#
    transcol_rgb=#_#_#

    back_rgb=#_#_#
    Ignore_back

  27. #27
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    Added 64-bits Linux binary, and changed caps: CryoPNG-> cryopng since CryoPNG is Mac OS X GUI PNG optimizer.

    Todo:
    upgrade codebase from OptiPNG 0.6.4 to 0.7.4 and release the source patch files.

  28. #28
    Member
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    48
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Good afternoon!
    You in cryopng couldn't add function which to allow to create all options of optimization of the alpha channel?

    Attached Files Attached Files
    Last edited by lorents17; 22nd September 2013 at 16:41.

  29. #29
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    155
    Thanks
    6
    Thanked 29 Times in 17 Posts
    Cedric Louvrier (ScriptPNG) encouraged me to try more possibilities, this resulted in cryopngtk2 (take2) and gave me some ideas regarding vertical spreads.
    I'll add cryopngtk2 in a few days for those interested, but watch the pngthermal thread I'll try to explain why some of your transforms actually harm compression.

  30. #30
    Member
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    48
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Thank you, I will be awaiting news.

Page 1 of 2 12 LastLast

Similar Threads

  1. Most efficient/practical compression method for short strings?
    By never frog in forum Data Compression
    Replies: 6
    Last Post: 1st September 2009, 05:05
  2. Introduction.
    By Tribune in forum Off-Topic
    Replies: 1
    Last Post: 13th June 2008, 16:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •