Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metadata: expose VIPS_META_PAGE_HEIGHT, VIPS_META_N_PAGES, requires libvips v8.7.0 #1205

Closed
lovell opened this issue Apr 24, 2018 · 8 comments

Comments

@lovell
Copy link
Owner

lovell commented Apr 24, 2018

Multi-page images e.g. TIFF are treated by libvips as a "toilet-roll" image. sharp could expose this information via the existing metadata feature.

If an image has the VIPS_META_PAGE_HEIGHT integer property set, add two new properties to metadata() response:

  • pageHeight: the value of VIPS_META_PAGE_HEIGHT
  • pages: the (total) height divided by VIPS_META_PAGE_HEIGHT, i.e. the number of pages
@woolite64
Copy link
Contributor

Does libvips have a way to count the number of TIFF directories? There are some situations (e.g. concatenated documents) where height may vary by page.

@lovell
Copy link
Owner Author

lovell commented Apr 24, 2018

libvips requires that all the heights (and a few other properties) are the same when reading multiple "pages" of a TIFF file.

https://github.com/jcupitt/libvips/blob/5176b4a17ec9ca5151f1b8b503b2f237f3c83b27/libvips/foreign/tiff2vips.c#L2173-L2197

@woolite64
Copy link
Contributor

woolite64 commented Apr 24, 2018

If I'm reading correctly, it looks like that requirement only holds when you are retrieving more than one page at a time. In the test cases for PR #1204, we're successfully loading different sized pages from the same file.

Before the snippet you linked, there is a call to rtiff_n_pages -- it appears to count the number of TIFF directories without requiring uniformity.

https://github.com/jcupitt/libvips/blob/5176b4a17ec9ca5151f1b8b503b2f237f3c83b27/libvips/foreign/tiff2vips.c#L495-L512

@lovell
Copy link
Owner Author

lovell commented Apr 24, 2018

Good point, thank you, for multi-page TIFF input this only makes sense after the n property of tiffload is exposed also (possibly with a more descriptive name).

@lovell
Copy link
Owner Author

lovell commented Apr 26, 2018

Better yet, we can use VIPS_META_N_PAGES, available in the future libvips v8.7.0, for the value of pages.

@lovell lovell changed the title metadata: expose VIPS_META_PAGE_HEIGHT metadata: expose VIPS_META_PAGE_HEIGHT, VIPS_META_N_PAGEs, requires libvips v8.7.0 Apr 26, 2018
@lovell lovell changed the title metadata: expose VIPS_META_PAGE_HEIGHT, VIPS_META_N_PAGEs, requires libvips v8.7.0 metadata: expose VIPS_META_PAGE_HEIGHT, VIPS_META_N_PAGES, requires libvips v8.7.0 Apr 26, 2018
@woolite64
Copy link
Contributor

Thanks @lovell, you beat me to it. jcupitt was quick with that commit.

How do you manage development against the latest libvips changes? Willing to test and PR this, but I'm not sure where to start.

@lovell
Copy link
Owner Author

lovell commented Apr 27, 2018

Features that require the future libvips v8.7.0 will need to wait until (a) it's released and (b) the next "major" version of sharp that places a minimum dependency on that version of libvips, which is likely to be sharp v0.21.0.

@lovell lovell added this to the v0.21.2 milestone Jan 1, 2019
lovell added a commit that referenced this issue Jan 2, 2019
@lovell
Copy link
Owner Author

lovell commented Jan 13, 2019

v0.21.2 now available with this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants