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).

2 Likes

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.

Hello, am just a observer to this conversation. Is image difference a module in this library and can it be used to detect defects in a, roll process in real- time ( by comparing a master image to the acquired video or frames from industrial camera)

Image.compare/3 provides a reasonable basis for comparing images. It will also return an image that highlights the differences between the two images. This is most useful for human evaluation but it might be used for further image processing.

Video frames can be acquired through the Image.Video module - which is a simple wrapper around Evision.VideoCapture.

So yes, you can compare a master image to frames from a camera. But I don’t believe you’ll get sustainable real-time streaming performance at typical video frame rates.

I would consider looking at what native capabilities exist in evision which is NIF-based wrapper upon OpenCV.

You might find that membrane gives you a solid foundation for the video stream and capture functions which could then be combined with either eVision or potentially image.

2 Likes

Hello, I know it is been more then a year, but client shutdown and now re introduced this project to me.
What did you refer on this ? To do all client(browser side ) ?
With JS and stuff ?
I am really not good at JS :slight_smile:

Thanks

I think my example code from July 2023 should work reasonably well with Liveview. I would still try to get the license plate template as an SVG so that the browser can scale it correctly.

@kip
Thanks a lot Kip, I will try out in coming days, and to paste it here or to make discussion on github ?

I think a GitHub discussion would be more appropriate.

Just wanted to say thank you to @kip and all the other contributors; Image is amazing! I just used it in a little side project and the precompiled install worked flawlessly, the API is smooth, and the docs are fantastic. I appreciate the work put into Image :heavy_heart_exclamation:

6 Likes

Thanks for the kind words @jc00ke. The real credit goes to @akash-akya who does the hard work of wrapping libvips in a NIF with vix. And of course the amazing John Cupitt who leads the development of libvips and who is incredibly responsive and supportive of users of his work. Lastly, evision by @cocoa who does amazing code wrangling to bring OpenCV into the Elixir ecosystem.

image is just an axiomatic Elixir wrapper of their work, but I’m happy you find it useful.

Expect a 1.0 release in January 2025!

11 Likes

Credits where credit is due, but you are doing an amazing work yourself. Your API design is on point and there is a lot of merit in creating higher level abstractions to turn more complex libraries/API into an accessible package. :slight_smile:

2 Likes

You are 100% right! Thank you to @akash-akya and @cocoa for their immediate Elixir work and to Dr. Cupitt who has done some amazing work!