svgcleaner icon indicating copy to clipboard operation
svgcleaner copied to clipboard

Using external tools on embedded or linked images

Open NoNoNo opened this issue 7 years ago • 1 comments

Please create a way to using an external tool on:

  • embedded images data:img/*
  • linked images <image xlink:href="*"/>

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)

NoNoNo avatar Jul 14 '17 11:07 NoNoNo

Hello.

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

  • use hardcoded options for a specific applications
  • allow user to run custom command

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.

RazrFalcon avatar Jul 14 '17 11:07 RazrFalcon