Sign in to follow this  
Followers 0
I Like Pi

OptiPNG file type plugin (November 30, 2008)

103 posts in this topic

NOTE >> This plugin is incompatable with Paint.NET 4.0.  Use the more recent version found here: http://forums.getpaint.net/index.php?showtopic=22841

 

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

0

Share this post


Link to post
Share on other sites

Original - 57.2 KB

4114_50f312246db85b15383e8d9271fafa0c

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

4114_ac2a7a1316acb7a8ddd70d7ba81d950a

(The black backgrounds are fully transparent).

0

Share this post


Link to post
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 :?

0

Share this post


Link to post
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}}

0

Share this post


Link to post
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.

0

Share this post


Link to post
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?

0

Share this post


Link to post
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.

0

Share this post


Link to post
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.

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
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.

0

Share this post


Link to post
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.)

0

Share this post


Link to post
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...?

0

Share this post


Link to post
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.

0

Share this post


Link to post
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...)

0

Share this post


Link to post
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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
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)

0

Share this post


Link to post
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.

0

Share this post


Link to post
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...

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0