Image - an image processing library based upon Vix

Does Image support PDF?

Vips says it supports pdf:

Images can have any number of bands. It supports a good range of image formats, including JPEG, JPEG2000, JPEG-XL, TIFF, PNG, WebP, HEIC, AVIF, FITS, Matlab, OpenEXR, PDF, SVG, HDR, PPM / PGM / PFM, CSV, GIF, Analyze, NIfTI, DeepZoom, and OpenSlide.

Yes, but only as an image container. Which means that if you call Image.open/2 on a PDF file, then each page will be an Vix.Vips.Image.t. There is nothing in libvips that parses the contents of a PDF file as structured data. The obverse is true for writing PDF files.

I don’t believe the prebuilt libvips library has PDF support built in so you may have to:

VIX_COMPILATION_MODE=PLATFORM_PROVIDED_LIBVIPS mix deps.compile vix

Making sure you’ve installed libvips first (on MacOS, brew install libvips for example).

1 Like

Perfect, that’s what I needed! I’m using this to create a snapshot test for a PDF. Turns out this is quite simple to do!

Glad to hear you’re up and running. Image comparison is quite a tricky topic. If you find hamming distance doesn’t work well for you, you might try Image.compare/3 since it has more tunable options.