Sign in to follow this  
I Like Pi

OptiPNG file type plugin (November 30, 2008)

Recommended Posts

I want ot submit a patch.

To get rid of annoying window, appearing each time you change some settings, or saving file,

change lines 92—95 of OptiPngFileType.cs

from

      StartInfo = {
                           Arguments = "\"" + tempFile + "\"" + " -o" + token.Compression + " -i" + (token.Interlace ? "1" : "0"),
                           WindowStyle = ProcessWindowStyle.Minimized
                       }

to

                        StartInfo = {
                           UseShellExecute = false,
                           CreateNoWindow = true,
                           Arguments = "\"" + tempFile + "\"" + " -o" + token.Compression + " -i" + (token.Interlace ? "1" : "0")
                       }

Share this post


Link to post
Share on other sites

P.S.:

the best way to find a path to the “optipng.exe” executable is to find a path to currentAssembly.

Besause on my work machine I have no access to HKLM registry, so no path is stored there, and sometimes current directory is changed.

Also, I recomment to use string.Format method to create an argument string.

To sum up, lines 90-107 of OptiPngFileType.cs should be changed from

if (token.Optimize) {
   Process optimize = new Process {
       StartInfo = {
           Arguments = "\"" + tempFile + "\"" + " -o" + token.Compression + " -i" + (token.Interlace ? "1" : "0"),
           WindowStyle = ProcessWindowStyle.Minimized
       }
   };
   string startDir;
   try {
       startDir = (string)Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Paint.NET").GetValue("TARGETDIR");
   } catch (NullReferenceException) {
       startDir = Environment.CurrentDirectory;
   }
   optimize.StartInfo.FileName = Path.Combine(Path.Combine(startDir, "FileTypes"), "optipng.exe");
   optimize.Start();
   optimize.WaitForExit();
   optimize.Dispose();
}

to

if (token.Optimize) {
   Process optimize = new Process {
       StartInfo = {
           UseShellExecute = false,
           CreateNoWindow = true,
           Arguments = string.Format("\"{0}\" -o{1} -i{2}", tempFile, token.Compression, token.Interlace ? "1" : "0")
       }
   };
   string startDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
   optimize.StartInfo.FileName = Path.Combine(startDir, "optipng.exe");
   optimize.Start();
   optimize.WaitForExit();
   optimize.Dispose();
}

btw, reference to Microsoft.Win32 can be thrown away now.

Share this post


Link to post
Share on other sites

Thanks, I've added in your patch. I'm leaving the command prompt window as is since it is the only source of information on the progress of the optimization. I've also updated to OptiPNG 0.62.

Share this post


Link to post
Share on other sites

Can someone help me figure out why this plugin is not showing up? I unzipped it to my desktop then initially dropped it in the "Effects" folder. I reread the thread and saw that it needed to be in the "File Types" folder and when I tried to delete it I got a message stating that I cannot delete it: access is denied. So I went ahead and dropped the dll and exe in the File Types folder anyway and restarted PDN. I don't see anything. I have a few other plugins installed ok so I'm not sure why this one is giving me issues.

Any troubleshooting advice would be great.

Share this post


Link to post
Share on other sites

It should show in the filetype dropdown menu of the Save As... dialogue.

That's what I thought, but nothing is there. Could it have something to do with the error message I got when trying to delete it (see my orig post)? Did I do it correctly by placing the exe and dll in the "file types" folder?

Share this post


Link to post
Share on other sites

I realize this is an old thread, but I'm having the same problem with OptiPNG. I downloaded and extracted the files, put the exe file in the File types folder of Paint.Net, but there is no DLL file in the download and nothing happens. I assume that I should see an option under Save As...., but there is no change.

I really have searched everywhere for an answer first.

Share this post


Link to post
Share on other sites

Yes, I've closed and opened Paint.net several times and downloaded and extracted several times. I downloaded from SourceForge and the OptiPNG site and neither download file has a DLL file in it.

Share this post


Link to post
Share on other sites
Compiled DLL:

OptiPNG plugin.zip

Both the DLL and optipng.exe need to be in the FileTypes directory.

Did you try downloading the attachment in the original post and did you put BOTH files in the downloaded zip into the filetypes directory?

Share this post


Link to post
Share on other sites

Did you try downloading the attachment in the original post and did you put BOTH files in the downloaded zip into the filetypes directory?

What attachment in what original post? Do you mean an earlier version of the plug-in? I didn't think that I should download a 2007-2008 file since the program was updated in 2011 and the older versions are no longer supported.

As I keep repeating, there IS NO DLL file in the download, so obviously, I can not put something I don't have anywhere.

Edited by LaGringa

Share this post


Link to post
Share on other sites

First post in this thread - second link, where it says "Complied DLL".

The link downloads a ZIP file with the compiled DLL in it AND the OptiPNG application.

Follow the instructions in that post.

Share this post


Link to post
Share on other sites

You will never find your DLL file then. As I am now starting to repeat, download the attachment because that is where the files you need reside.

Share this post


Link to post
Share on other sites

First post in this thread - second link, where it says "Complied DLL".

The link downloads a ZIP file with the compiled DLL in it AND the OptiPNG application.

Follow the instructions in that post.

Thank you and thank you for your patience.

I saw a message on this forum saying that installation of the plug-ins was not intuitive. I hope you all can appreciate how exactly counter-intuitive it is to download a current zip file but to have to go back through 5 pages of a 4-year-old thread and copy a 2007 DLL file to go with it. While there were several text files in the zip file (and I read them all), there was no read me file, no instructions saying where or how to find the DLL or that it was okay to use the 2007 file or even that it was needed.

Hopefully these last messages will help the next person who comes along, but I'm really perplexed why the download file wouldn't include everything that is needed to use the plug-in or a bit of instructions on how to install it. Maybe even where to find it after it is installed.

Just a suggestion -- but thank you for your help. My problem is solved. ;-)

Share this post


Link to post
Share on other sites

I think you may have originally downloaded from the first link. I'm glad we managed to sort it out for you.

This forum works on the general principle that a plugin is released in it's own thread. So the first post is always the place to look for the download (when you follow a link to a thread, it generally defaults to the first post - so that's where most users find stuff they are looking for).

When updates are posted for a plugin, we find it best to replace the download in the first post - rather than bury the update in the middle of the thread. This keeps ONE download relevant.

Don't worry - you'll get used to how we work here! boltbait.big_smile.png

Share this post


Link to post
Share on other sites

Perhaps it should be updated to OptiPNG 0.6.5, as versions 0.6.2 (& below) have unpatched security vulnerabilities:

  • All past OptiPNG versions, up to and including version 0.6.2, are known to be vulnerable to use-after-free attacks, due to a bug in the GIF image reader. (Many thanks to Roy Tam for the report, and to Bryan McQuade for the fix.)
  • OptiPNG versions 0.6 and 0.6.1 are known to be vulnerable to array-overflow attacks, due to a bug in the BMP image reader. (Many thanks to an anonymous user for the report.)

0.6.5 was release 2011-01-24.

Share this post


Link to post
Share on other sites

It should show in the filetype dropdown menu of the Save As... dialogue.

I just got the plugin and could not figure out where it showed up so finding this answer was great, Thanks.

Share this post


Link to post
Share on other sites

When I tried to unzip with 7zip it gave errors for both files.

Using default windows cut/paste out of the archive seemed to work fine :/

Tested and seems to save an image fine though.

Edited by angelp1ay

Share this post


Link to post
Share on other sites

Perhaps it should be updated to OptiPNG 0.6.5, as versions 0.6.2 (& below) have unpatched security vulnerabilities:

  • All past OptiPNG versions, up to and including version 0.6.2, are known to be vulnerable to use-after-free attacks, due to a bug in the GIF image reader. (Many thanks to Roy Tam for the report, and to Bryan McQuade for the fix.)
  • OptiPNG versions 0.6 and 0.6.1 are known to be vulnerable to array-overflow attacks, due to a bug in the BMP image reader. (Many thanks to an anonymous user for the report.)

0.6.5 was release 2011-01-24.

It looks like support for this plugin is dead. The OptiPNG project itself does provide Win32 builds (no Win64, sadly--would probably be a lot faster). I'm using their pseudo-nightly build (from the Mercurial repo, presumably more recent code than 0.7.1), and it appears to work correctly as a drop-in replacement for the included optipng.exe. 0.7.1 fixes not just security flaws, but an actual image corruption bug for grayscale images.

It would be really nice to see OptiPNG included (stand-alone download if necessary) as an official plugin for PDN, preferably in 64-bit native. libjpeg-turbo wouldn't hurt, either...

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this