sile-typesetter / sile

The SILE Typesetter — Simon’s Improved Layout Engine
https://sile-typesetter.org
MIT License
1.66k stars 98 forks source link

Add backend for direct image output #1022

Open alerque opened 4 years ago

alerque commented 4 years ago

Screenshots are an easy-reach tool and PDF's aren't that hard to rasterize, but a first class backend that rendered straight to raster images (PNG? page-layered TIFFs?) would actually be pretty spicy. Perhaps it would just be candy wrapper around the libtexpdf backend that converted to an image when done, perhaps it would use a different backend like Cairo (#634), Skia (#553), or some other PS/SVG output driver ... but however it is implemented in the end uses for this are constantly coming up for me and it seems like a nicety we could support.

rjmunro commented 4 years ago

It would be good if it could render to a PNG with alpha background and anti-aliasing of the text against the alpha channel, so that I can, e.g. layer it over a video.

alerque commented 4 years ago

Yes.

And just a tip until it does — I've been doing this already both for video and posters, book covers, etc. by rendering the text layers I want to PDF, then converting them to PNGs using ImageMagic. You get a lot of control over anti-aliasing and (if you've coordinated your page size and conversion DPI with your final workspace) end up with resources that are pretty easy to fold into a composited project.

ctrlcctrlv commented 4 years ago

Why not Ghostscript?

alerque commented 4 years ago

For what? In the context of what I used and recommended ImageMagic for, it provides a LOT more control over the raster side of things. Ghostscript does fine working with PostScript but as soon as you rasterize it's out of its depth whereas with IM‌ the possibilities are nearly limitless.

As a possible backend for SILE to talk directly too, passing rendered PostScript might not be a bad option and bring us close to parity with the existing PDF backend right out of the gate. In any event there are several possible things to look into when actually implementing this, and yes using GS an an output driver would be one of them.

ctrlcctrlv commented 4 years ago

As an output driver yeah