Jump to content
How to Install Plugins ×

OptiPNG file type plugin (November 30, 2008)


I Like Pi

Recommended Posts

NOTE: This plugin is incompatible with Paint.NET 4.0.  Use the most recent version found here:

https://forums.getpaint.net/topic/114190-optipng-filetype-2019-05-07/

 

 

This plugin integrates OptiPNG with Paint.NET. It optimizes PNG to make them smaller, which is good for web use.

Compiled DLL:
OptiPNG plugin.zip
Both the DLL and optipng.exe need to be in the FileTypes directory.

November 30 - updated to OptiPNG 0.62, some minor changes suggested by antond
October 24 - updated to OptiPNG 0.61, no changes in my code
June 20 - updated to OptiPNG 0.6, no changes in my code


Source Code:
License: GNU General Public License (GPL) v3
Source Code.zip

 

Edited by toe_head2001
Link to comment
Share on other sites

Original - 57.2 KB

[attachment=1]PNG_transparency_demonstration_1.png[/attachment]

OptiPNG file type plugin; RGB with alpha, compression 7 (basically the defaults which appeared) - 58.8 KB

[attachment=0]PNG_transparency_demonstration_1 v2.png[/attachment]

(The black backgrounds are fully transparent).

Your kidding me, it makes it larger :?

Link to comment
Share on other sites

Lots of Wikipedia's images are already optimized :wink:

17:58, 17 August 2007 JeffyP 320×240 57 KB revert

17:39, 17 August 2007 JeffyP 320×240 44 KB Compressed even further

08:03, 15 October 2005 Txuspe 320×240 57 KB Compressed with PNGOUT.

00:45, 12 July 2005 Daniel G. 320×240 62 KB 24bit PNG with 8bit alpha layer Rendered in POV-Ray by user:ed_g2s. See also: Image:PNG transparency demonstration 1.png {{GFDL}}

Link to comment
Share on other sites

Maybe we should do a little benchmark with new pictures.

Would be interesting to compare it with HD Photo, too.

I would do it, but I will not be here again until Monday, so please don't wait for me.

And thanks for the plugin, at least this is a good step.

Link to comment
Share on other sites

Fair comment I Like Pi...

Original - 33.7 KB

myrddinav6-4slatted-1.png

OptiPNG file type plugin; RGB with alpha, compression 7 - 26.1 KB

myrddinav6-4slattedcompressed.png

--------------------------------------------

Original - 651 KB

th_ladyofthelakepng.png

Click for larger

OptiPNG file type plugin; RGB, compression 7, transparency threshold 0 - 394 KB

th_ladyofthelakepngv2.png

Click for larger

Well done, it works! Thank you very much, this will save considerable time. The slow speed I'll attribute to OptiPNG as all the PNG optimisers I've tried are reasonably slow, however, is there anything you can do about speed, especially when dealing with larger images?

Link to comment
Share on other sites

Small update:

  • [*:8d48b]Changed default optimization level to 2 because it's OptiPNG's default
    [*:8d48b]Added some more tooltips
    [*:8d48b]Interlacing on/off

In the future, I may expose more of OptiPNG's command line options so users who know what they're doing can eshew OptiPNG's preset levels (which basically brute force a bunch of settings for the smallest size).

Problem is I don't fully understand the options.

Link to comment
Share on other sites

Nice. This might be really usefull. Ive been using OptiPNG for a while now, and its great to see it integrated into Pdn.

I'm still alive!

Link to comment
Share on other sites

This is quite cool! I like it a lot, and it will certainly come in handy! Thanks!

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

In the future, I may expose more of OptiPNG's command line options so users who know what they're doing can eshew OptiPNG's preset levels (which basically brute force a bunch of settings for the smallest size).

Problem is I don't fully understand the options.

If possible, it would be very nice to see this brute force thing (PNGauntlet has something similar) available. If you have problems you could make a beta, I'm sure you would find a lot of "testers", and maybe this would be a help.

Link to comment
Share on other sites

If possible, it would be very nice to see this brute force thing (PNGauntlet has something similar) available. If you have problems you could make a beta, I'm sure you would find a lot of "testers", and maybe this would be a help.

It already uses brute force. The defaults tell OptiPNG to brute force a bunch of filters and stuff. (This is what the "x trials" means.)

From OptiPNG documentation (the -ox corresponds to what this plugin uses):

Optimization level presets:
   -o0  <=>  -nz
   -o1  <=>  [apply libpng heuristics]         (1 trial)
   -o2  <=>  -zc9 -zm8 -zs0-3 -f0,5            (8 trials)
   -o3  <=>  -zc9 -zm8-9 -zs0-3 -f0,5          (16 trials)
   -o4  <=>  -zc9 -zm8 -zs0-3 -f0-5            (24 trials)
   -o5  <=>  -zc9 -zm8-9 -zs0-3 -f0-5          (48 trials)
   -o6  <=>  -zc1-9 -zm8 -zs0-3 -f0-5          (120 trials)
   -o7  <=>  -zc1-9 -zm8-9 -zs0-3 -f0-5        (240 trials)

(If anyone wants to improve anything, feel free to download the source code.)

Link to comment
Share on other sites

It already uses brute force. The defaults tell OptiPNG to brute force a bunch of filters and stuff. (This is what the "x trials" means.)

I see. I thought brute force would mean that it automatically detects the best settings for the picture. When I use PNGauntlet it displays something like "image doesn't fit into 256 color space, try RGB instead". Maybe I'm wrong and this isn't what brute force actually means...? Well, the reason why I asked was that PNGauntlet produced in some tests I made in a bunch of cases files that were around 10 KB smaller, and I thought that would be related to this brute force stuff. Using the file type plugin, you can select many options (like grayscale, RGB with alpha and so on), and my idea was that I used bad settings and as a consequence I got better results with PNGauntlet cause it searched for the best settings... To be honest I haven't looked if the settings of the file type plugin are chosen automatically or if it remebers the previous settings...?

If someone wants to make tests with PNGauntlet (rather useless for 10 poor KB, I think), please note that the release I got came with an outdated version of pngout (the commandline exe which PNGauntlet uses) and I had to download the actual version seperately.

Another question: Can there be a checkbox to disable the preview? I don't know how much the speed impact actually would be...?

Link to comment
Share on other sites

The power of a PNG optimizer is best realized when optimizing many images. All the icons in Paint.NET v3.10 are optimized using OptiPNG and it cut down the installer size by 100k or so.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

By the way I realized that optimized pngs are best with screenshots (without wallpaper) and other similar pictures with sharp lines. When you have a complex picture like taken with a camera, HD Photo - surprise! - gives in a lot of cases better results (not ever, but in a test I did I got around 130 KB for an 500X350 picture with optimized png and 90 KB with HDP). Too bad I get no previews for HDPs running XP, I think Microsoft should release a shell extension for it, just that you get previews... You have no planes to make one in your free time, aren't you, Rick...? :roll:

(OK, this joke was rather bad...)

Link to comment
Share on other sites

Brute force is trying out every possibility. Intelligently detecting optimal settings would be the opposite. http://en.wikipedia.org/wiki/Brute_force

The plugin remembers the previous settings; this is done by Paint.NET.

PNGGauntlet has a brute force search option, but I don't know what it does by default.

The color options reduce the amount of color so that OptiPNG can do more optimization. I do not pass them as arguments to OptiPNG. If an image is already grayscale, for example, your color selection should not make a difference because OptiPNG should notice that the image fits in grayscale and make a grayscale PNG. However, if the image does not already fit in grayscale, OptiPNG will not reduce the image to grayscale.

Update 1.0.2:

  • [*:5cbde]Feature: preview checkbox
    [*:5cbde]Efficiency improvement: don't optimize again when pressing OK if the last preview is identical.

Link to comment
Share on other sites

This would mainly be useful for the whole "Pngs darker in ie" thing.

"By trying to reinvent the wheel every time we find very often with square wheels" ...X-blaster

Link to comment
Share on other sites

  • 2 weeks later...

Has any one else files "tmp##.png" in his TEMP-folder (Start -> Run: %TEMP%) left behind by this plugin? The reason the aren't not deleted seems not to be related to crashes, cancelling etc.

Link to comment
Share on other sites

I Like Pi: You can make sure the temp files are deleted by either using the FileOptions.DeleteOnClose flag with File.Create() (in C# code), or the FILE_FLAG_DELETE_ON_CLOSE flag with CreateFile() (in C/C++).

(That's assuming of course that you are the one creating the files, not optipng.exe)

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Thanks for your kind support, Rick. At the moment I assume the files are related to the preview (or to the fact that you can disable the preview). I'll try to do some tests in the next time, until then everybody is invited to share his knowledge.

Link to comment
Share on other sites

Fixed :)

Wow, that was fast. Thank you very much, I l-o-v-e this plugin and use it very often.

Edit: Could you just attach the zip to your first post? I had several times trouble with media fire (cookies enabled, it's their fault) and now again I couldn't download...

Link to comment
Share on other sites

Erm, I don't know how important this actually is, but I scan my drawings with 300 dpi and when I save them with optimized png, the dpi value is taken down to 96 dpi. The same issue occurs when using irfan view with pngout. I don't know if this has any impact on quality, but it is important for me to save the pictures in the same (or better :) ) quality they had when I scanned them, and so I want to ask if a dpi setting could be added to the plugin's options in the case that lower dpi values affect the quality negative. I know that 72/96 dpi are good for viewing, but I maybe want to print the pictures again and also I just don't want to loose quality.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...