Replies: 3 comments 4 replies
-
Hello @rhymes,
So even though I only loaded the first page, I still see It's best to divide height by page height, with page height defaulting to height if not defined. Eg.: def get_defaulted(image, name, default)
if image.get_typeof(name) != 0
image.get(name)
else
default
end
end
def get_page_height(image)
get_defaulted(image, "page-height", image.height)
end
def get_n_loaded_pages(image)
image.height / get_page_height(image)
end This should probably be added to ruby-vips (this logic is in other bindings, like the C API). |
Beta Was this translation helpful? Give feedback.
-
It depends what you want. image height / page height gives you the number of loaded pages, n-pages gives you the number of pages in the underlying file. Eg.:
So I've only loaded 1 page, though the underlying file has 139 pages. I can load more pages, eg.:
Now I've loaded 14 pages, starting from page 12. You can use |
Beta Was this translation helpful? Give feedback.
-
Just recently there was a pull request in another gem -- sdsykes/fastimage#119 |
Beta Was this translation helpful? Give feedback.
-
I would like to count frames of loaded images, regardless if they are animated or not.
I came up with this (mostly borrowed by @jcupitt in #274 (comment)):
Is this reliable? Thank you!
Beta Was this translation helpful? Give feedback.
All reactions