ImageGlass icon indicating copy to clipboard operation
ImageGlass copied to clipboard

Add support for reducing the size of image with lossless compression

Open dlemstra opened this issue 2 years ago • 1 comments

The Magick.NET library contains an ImageOptimizer that can be used to reduce the size of an image with lossless compression. Would you be open to a pull request that adds support for this to ImageGlass? Not sure where should be added in the menu though. Maybe in the Image menu? And would you be okay with this only be added to the v9 branch?

dlemstra avatar Mar 25 '23 08:03 dlemstra

v9 is a good branch! Note that the source code of v9 is in the v9 folder. Since the upcoming v9.0 beta 4 will support "Tools" menu, including built-in and external tools. This ImageOptimizer can be added as a built-in tool, may be called Image optimizer, in the Tools menu.

You can add a new ToolstripMenuItem called MnuImageOptimizer.

  • In FrmMain.IGMethods.cs, write a method IG_OptimizeImage().
  • In the click event of the menu MnuImageOptimizer_Clicked(), call the IG_OptimizeImage() function.
  • To show a message to user, there are 2 ways:
    • PicMain.ShowMessage() is for short time and unimportant message. It is usually dismissed after the task is done or exceed the duration from Config.InAppMessageDuration.
    • Config.ShowError(), Config.ShowInfo(), Config.ShowWarning() are for important and persistent message. It's only dismissed by the user.

For the external tools, it's loaded via the settings Tools in igconfig.json. The Exif tool from v8 will be decoupled as a standalone tool. Currently, I put a placeholder for it in the Tools menu:

image

The setting for external tool is as below: https://github.com/d2phap/ImageGlass/blob/633d457ce3347765a6c39b97afe6349d411a6fe6/v9/Components/ImageGlass.Settings/Config.cs#L735-L748

d2phap avatar Mar 25 '23 13:03 d2phap

This feature is added in ImageGlass 9.1 Beta

image

image

d2phap avatar May 29 '24 12:05 d2phap