4

This is a followup question of

how do I get maximal compressed screenshots?

Is there a screenshot tool that has optipng or pngcrush already included to minimize the filesizes of the png screenshots?

I personally favoritize Shutter, but any screenshoter would be great that would create optimized pngs.

maybe there are plugins available?

rubo77
  • 31,573
  • 49
  • 159
  • 281

1 Answers1

5

If your favorite tool is "shutter" you can try to create a little plugin for it.

Creating Plugin for Shutter.

1) Make sure you have installed optipng, or install it with:

  • sudo apt-get install optipng

2) If shutter is running close it or kill it..

  • pkill shutter

3) Create a folder for the plugin and give it the correct perms. (eg:optipngplugin)

  • sudo mkdir /usr/share/shutter/resources/system/plugins/shell/optipngplugin

  • sudo chmod 755 /usr/share/shutter/resources/system/plugins/shell/optipngplugin

4) Create the script (eg:optipngplugin)

  • gksudo gedit /usr/share/shutter/resources/system/plugins/shell/optipngplugin/optipngplugin

5) Put this content in the script:

#!/usr/bin/env bash
TEXTDOMAIN=shutter-plugins
TEXTDOMAINDIR=$SHUTTER_INTL
PLUGIN_NAME=$"OptiPNG Plugin"
PLUGIN_SORT=$"Recompress"
PLUGIN_TIP=$"OptiPNG is a PNG optimizer that recompresses image files to a smaller size"
PLUGIN_EXT="image/png"
if [[ "${1}" = "name" ]];then
    echo "${PLUGIN_NAME}"
    exit 0
elif [[ "${1}" = "sort" ]];then
    echo "${PLUGIN_SORT}"
    exit 0
elif [[ "${1}" = "tip" ]];then
    echo "${PLUGIN_TIP}"
    exit 0
elif [[ "${1}" = "ext" ]];then
    echo "${PLUGIN_EXT}"
    exit 0
fi
FILE="${1}"
#LOGO="/usr/share/shutter/resources/system/plugins/shell/optipngplugin/optipngplugin.png"
optipng -o7 "${FILE}"
exit 0

In my case I choose the optimization level of OptiPNG to Maximun (-o7) (very slow), and I added an image as a logo.

Man Pages

enter image description here

NOTE: Feel free to change the script according to your needs

6) Save the changes and give it perms.

sudo chmod 755 /usr/share/shutter/resources/system/plugins/shell/optipngplugin/optipngplugin

7) In my case I edited a png logo with gimp, and I saved as "optipngplugin.png" in my desktop.

enter image description here

8) copy the logo to the plugin directory (give it the same name as the plugin plus .png) and the correct permissions:

sudo cp /home/user/Desktop/optipngplugin.png /usr/share/shutter/resources/system/plugins/shell/optipngplugin/optipngplugin.png

sudo chmod 644 /usr/share/shutter/resources/system/plugins/shell/optipngplugin/optipngplugin.png

9) Test the plugin. Open shutter and take a screenshot of your desktop.

enter image description here

Right click in the screenshot and click in "Run a Plugin...", then choose "OptiPNG Plugin" from the list.

enter image description here

10) Run the plugin to recompress the screenshot you took.

enter image description here

NOTE: If you have to add something to the script or some change. you can run shutter with this command to force it to reload all plugins

  • shutter --clear_cache

Hope its help.

rubo77
  • 31,573
  • 49
  • 159
  • 281
Roman Raguet
  • 9,473
  • 2
  • 40
  • 40
  • thanks, that works, although I get an error in the plugin selection: http://i.stack.imgur.com/qop8j.png. – rubo77 Aug 14 '13 at 23:19
  • It would be great to create an Ubuntu deb package from this: http://askubuntu.com/questions/332738/how-can-i-create-an-ubuntu-package-from-a-script – rubo77 Aug 14 '13 at 23:25
  • @rubo77... Great. glad it worked! – Roman Raguet Aug 15 '13 at 13:54
  • 1
    You can use another shell script plugin as template. folder: /usr/share/shutter/resources/system/plugins/shell/. https://answers.launchpad.net/shutter/+question/118974 – Roman Raguet Aug 16 '13 at 11:34
  • 1
    with "shutter --clear_cache" you reload all the plugins again. – Roman Raguet Aug 16 '13 at 11:58
  • the definition of `LOGO="/usr/share/shutter/resources/system/plugins/shell/optipngplugin/optipngplugin.png` is not needed if you name the logo like the plugin. Here is the finished script: http://pastebin.com/xEebiLhE – rubo77 Aug 16 '13 at 12:28
  • cool, with `shutter --clear_cache` it works. [discussion how we found out](http://chat.stackexchange.com/rooms/10160/discussion-between-rubo77-and-roman-raguet) – rubo77 Aug 16 '13 at 14:16