I want to decrease file size of my document with many images. What are effective ways to do it?
Typst supports WEBP which is more efficient than JPEG, so I thought that using smaller WEBP images would reduce the file size. But I read Typst reencodes JPEG images, and I don’t know if PDF supports WEBP images, so it seems that Typst would reencode WEBP to JPEG. If Typst encodes it anyway, it seems that the best way would be to just resize the images to a reasonable resolution and let Typst’s encoder do its thing.
PDF seems to support JPEG2000 because PDF/A-2 requires it, and that would be in theory the best option, but Typst does not support JPEG2000.
If I remember correctly, in the newest version of Typst, JPEGs are embedded as provided, so if that’s an option one way would be to optimize the JPEG. However, as you mentioned, all other images will more or less be re-encoded, so for those the only way is to reduce the actual dimensions of the image.
Note however that there is some ongoing work on embedding PNGs directly, so it’s possible that starting from the next version, optimizing the PNG itself is also an option!
You can use another tool to put JPEG2000 images in a PDF file, and then include the PDF file in the Typst document with #image("file.pdf", page: xxx). This will embed the image without reencoding (though I’m not sure if this behavior is documented and will stay like that in future versions).