Is there a way to extract all pages as separate images?
cigrainger opened this issue · comments
Looking at the implementation for map_pages
-- is there a way to do something like this but return a list of Image
s, 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
andImage.dilate/2
now take aradius
parameter rather than apixels
parameter. Both functions have been refactored to allow a radius in the range1..5
with a default of1
. The radius represents the dimension of the matrix used in theVix.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 singlelibvips
operation. The previous implementation createdn
operations (wheren
was the value of thepixels
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. UseImage.dominant_color!/2
if only the color value return is required. -
Image.map_pages/2
is deprecated in favour ofImage.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 mirrorImage.radial_gradient/3
. -
Add
Image.dominant_color!/2
to mirrorImage.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.