Hi community. I have a PDF with 180 MB ( ) and my pdf reader opens the document very slow. My document has 19 images, all webp. But when compile typst converts all images to PNG (And the image now is more big, 310 KB to 13 MB).
What is the process for compile a light pdf file? And What recommendations can you give me for insert images in typst documents?
Hi. How did you check that images are converted to PNG?
Usually having images in JPEG just works, they should be embedded as is. Might even take less space when embedded. Pretty sure you can convert them with magick from an imagemagick package.
A bug? Have you checked how large the images get it you convert them with another tool to a png file?
If I recall correctly, the PDF spec doesnât support WebP so Typst has to re-encode images.
I think the best you can do is to downscale the images to a reasonable size for your document and maybe lossily convert them before useing them in your Typst document.
Another option to get smaller output size is to use JPEG 2000: you cannot include such images directly in Typst, but you can include PDF files that contain such images. So you âjustâ need to first convert all your images to JPEG 2000 wrapped in PDF files (or use a single PDF container for all images, one per page, and use #image("my-images.pdf", page: xxx) for each image).
I really donât get all this talk about JPEG (a terrible format nowadays and for a good time) when the post is about webp images.
If webp is not supported and is silently transformed into a different format, that is a considerable concern since jpeg has terrible quality and PNG has large file sizes. But no idea if this is the fault of typst itself or other libraries etc
Itâs a PDF format issue: if it doesnât support WebP, then converting the image data in some way is always required. (And some pdf viewers somehow support WebP, but the format itself does not really support it.)