Add image package that filters raster resources through ImageMagick #436
Labels
enhancement
Software improvement or feature request
wontfix
Rejected for other reasons than duplicate or invalid
Including an image in a document is all well and good. Being able to set the size in the layout is all well and good. But this is often the very final step in including an image in a document. First the image has to be manipulated, perhaps cropped or resized, perhaps recolored to fit the context. Then and only then are they placed on a page.
Some desktop publishing programs have non-destructive ways to do basic image manipulation such as cropping and adding borders when inserting an image. They keep the original image internally and process it in place on output. Currently the only way to handle this in SILE is to edit the image externally and include the finished image. This often means doing destructive raster edits on a source image. Sure you can keep this in version control, but that's awkward.
My solution to date has been to keep a directory of raster resources used in a book at the highest quality and original format. Then in each book project's
Makefile
I have target rules to generate versions of those to be included in the document using ImageMagick. Those are then appended to the prerequisites list for the book so they are generated whenever SILE runs.Now every time I run
make my_book.pdf
a cropped, resized, normalized, and bordered version of the image will be generated and I can use it as the source file in my document. The major advantage of this method is that the editing is "non destructive". Since the source is untouched and the file will regenerate whenever necessary I can always tweak it with different parameters.This gets the job done, but it occurred to be that a package could allow SILE to handle this internally. Not everybody is going to build their documents using GNU-Make and handling this in the source of the document would make it a lot for context sensitive.
I don't know how this should be implemented. An easy hack would be simply to read the file through a pipe and pass some command line arguments along the way.
\image[src=image.png,magick="-normalize -crop 600x150+0+0 -resize 400x -bordercolor black -border 5",width=6em]
A more complicated way might be to use one of ImageMagick's APIs and develop a command that processes the options and handles this image processing internally without having to call out to the command line.
Thoughts?
The text was updated successfully, but these errors were encountered: