If you want to submit a Typst template to the package repository, the packaging rules ask for a thumbnail – a picture of the first page of a typical document using your template.
I looked online for instructions on how to automatically generate a suitable image from a .typ document, and did not find any. Here is what I came up with, in case it can help others:
Suppose you want to turn foo.typ into foo-thumbnail.png. Use the following:
Also related: for packages, where 250 dpi and a single thumbnail is not mandatory, creating dark and light mode thumbnails can be nice. the community’s package template contains the setup for you
I was pointed at typst compile foo.typ foo.png on the github as well, but I notice that it generates fairly large png files. At the recommended resolution my example takes 2Mio, compared with 250-300Kio with ImageMagick.
(From a distance I don’t really understand how to use thumbnail.typ. Is the expectation that typst packages would generally handle both a light and a dark mode, so that they can adjust their own settings accordingly, and use that in the demo file used to generate the thumbnail?)
Thanks, that was the info I was missing! Is the difference still noticeable after oxipng?
Well, it’s a community template. There’s benefit in mentioning it, but it’s also understandable that Typst-the-company is reluctant in endorsing specific non-official projects. I don’t think even Tinymist is mentioned in the docs? (Although one could argue that Tinymist “competes” with the web app, but I don’t think that’s the deciding difference.)
No, unless the package has a use to do that. The idea is that you want to showcase your package on a website, and if that website supports dark mode, the showcase should fit the user’s preference. Take Alexandria: this package is about bibliography and has nothing to do with themes, but on the website you want to present it nicely. So thumbnail.typ, not the package is responsible for theming. The thumbnail is basically a document using the package, not part of it. And this document supports dark mode.
Obviously you’re free to remove that from your package if you want, but it seemed useful enough to include it by default, so that having a dark mode thumbnail is easier to accomplish.