Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image package that filters raster resources through ImageMagick #436

Closed
alerque opened this issue Jan 20, 2017 · 2 comments
Closed

Add image package that filters raster resources through ImageMagick #436

alerque opened this issue Jan 20, 2017 · 2 comments
Assignees
Labels
enhancement Software improvement or feature request wontfix Rejected for other reasons than duplicate or invalid

Comments

@alerque
Copy link
Member

alerque commented Jan 20, 2017

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.

PREREQUISITES += image.jpg
image.jpg: media/image.png
    magick $< -normalize -crop 600x150+0+0 -resize 400x -bordercolor black -border 5 $@

%.pdf: %.sil $(PREREQUISITES)
    sile $< -o $@

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?

@alerque alerque added the enhancement Software improvement or feature request label Jan 20, 2017
@simoncozens
Copy link
Member

Start with the simple way and then try the complex way. :-)

@Omikhleia
Copy link
Member

Rejected (Wontfix): It does not seem relevant to introduce an ImageMagick dependency of that kind in the core distribution.
Maintainers have settled on keeping the core free, as much as they can, of packages that require external dependencies.

Not that this is therefore out of scope for core SILE, but not necessarily out of scope for the SILE ecosystem: Anything that requires compiling or using external dependencies belongs in a 3rd-party package, not to not to the core distribution.

We already have the tooling available for that and anybody can spin up a 3rd party package. If SILE needs to implement some API to make it more usable, we can look into that.

For future reference, at this date here are examples of 3rd-party packages that use external tooling:

The core converters package is also an interesting resource to consider.

@Omikhleia Omikhleia closed this as not planned Won't fix, can't repro, duplicate, stale Mar 26, 2023
@Omikhleia Omikhleia added the wontfix Rejected for other reasons than duplicate or invalid label Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Software improvement or feature request wontfix Rejected for other reasons than duplicate or invalid
Projects
None yet
Development

No branches or pull requests

3 participants