RazrFalcon / svgcleaner

svgcleaner could help you to clean up your SVG files from the unnecessary data.
GNU General Public License v2.0
1.63k stars 94 forks source link

Using external tools on embedded or linked images #91

Open NoNoNo opened 7 years ago

NoNoNo commented 7 years ago

Please create a way to using an external tool on:

Useful e.g. for optimizing or rescaling images.

Pseudo code:

foreach(IMAGES as IMAGE) {
  save(IMAGE, '/tmp/image.ext');
  exec(EXTERNAL_TOOL, '/tmp/image.ext');
  IMAGE = read('/tmp/image.ext');
}

Running exec asynchronously would be a bonus…

Example from jhead:

Jhead is a program for manipulating settings and thumbnails in Exif jpeg headers
used by most Digital Cameras.  v3.00 Matthias Wandel, Jan 30 2013.
http://www.sentex.net/~mwandel/jhead

  -cmd command
             Apply 'command' to every file, then re-insert exif and command
             sections into the image. &i will be substituted for the input file
             name, and &o (if &o is used). Use quotes around the command string
             This is most useful in conjunction with the free ImageMagick tool. 
             For example, with my Canon S100, which suboptimally compresses
             jpegs I can specify
                jhead -cmd "mogrify -quality 80 &i" *.jpg
             to re-compress a lot of images using ImageMagick to half the size,
             and no visible loss of quality while keeping the exif header
             Another invocation I like to use is jpegtran (hard to find for
             windows).  I type:
                jhead -cmd "jpegtran -progressive &i &o" *.jpg
             to convert jpegs to progressive jpegs (Unix jpegtran syntax
             differs slightly)
RazrFalcon commented 7 years ago

Hello.

Yes. I thought about it, but I can't decide which way to use:

There are obvious benefits and downsides in both methods, but the main problem is distribution. There are prebuild packages for win/linux/mac and if I will add image processing options - I will have to distribute these applications (like jpegtran, (opti|oxi)png).

So it should be extensible, but also easy for a generic user.

For now, I can just add an ability to run a custom command on images only using CLI.