elixir-image/image

Is there a way to extract all pages as separate images?

Closed this issue · 2 comments

Looking at the implementation for map_pages -- is there a way to do something like this but return a list of Images, one for each page?

Thanks!

I have just published Image version 0.43.0 which includes the new Image.extract_pages/1 function. I think that will do what you're after. I'll close the issue for now - but please reopen if required.

Here's the full changelog:

Breaking Changes

  • Image.erode/2 and Image.dilate/2 now take a radius parameter rather than a pixels parameter. Both functions have been refactored to allow a radius in the range 1..5 with a default of 1. The radius represents the dimension of the matrix used in the Vix.Vips.Operations.range/4 function that underpins dilation and erosion. As such they represent the approximate number of pixels eroded or dilated. In addition, this function now results in a single libvips operation. The previous implementation created n operations (where n was the value of the pixels param) that could result in a slow imaging pipeline and in some cases a segfault of the entire VM due to stack space exhaustion in libvips.

  • The signature for Image.linear_gradient/{1..3} has changed. The function now takes:

    • An image and an optional keyword list of options
    • A width and height as numbers and a keyword list of options
  • Image.dominant_color/2 now returns an {:ok, rgb_color} tuple rather than a [r, g, b] list. Use Image.dominant_color!/2 if only the color value return is required.

  • Image.map_pages/2 is deprecated in favour of Image.map_join_pages/2 to better reflect the intent of the function.

Enhancements

  • Image.linear_gradient/{1..3} now takes an :angle option which determines the angle of the gradient in degrees. Thanks to @severian1778 for considerable patience. Closes #67.

  • Improve options handling and documentation for Image.radial_gradient/3.

  • Add Image.radial_gradient!/3 to mirror Image.radial_gradient/3.

  • Add Image.dominant_color!/2 to mirror Image.dominant_color/2.

  • Add Image.extract_pages/1 which will extract the pages of a multi-page image into a list of separate images.

That does exactly what I'm after! Thanks so much @kipcole9.