UniversalViewer / universalviewer

A community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
http://universalviewer.io
Other
489 stars 184 forks source link

thumbnails aspect ratio should be determined by the first thumbnail image not by the first image in the collection #743

Open akohlbecker opened 4 years ago

akohlbecker commented 4 years ago

UV version:

 universalviewer@v3.0.1

I'm submitting a:

Current behavior:

UV takes the aspect ration of the first full resolution image as default, for all thumbnail images. This causes thumbnails to be quite ugly in situations when the aspect ration of the images in the collection is not always the same. In collections with varying image aspect ratio you may want to crop the thumbnails to harmonize the various aspect ratios, so that all thumbnails have the same aspect ratio and dimension. The thumbnail images should then perfectly fit into their frames. But this does not work. Here is an example screenshot depicting the situation in which the dimensions of the thumbnails are harmonized but they are placed into wrongly sized thumbnail container divs by UV:

(http://test.e-taxonomy.eu/dataportal/preview/cyprus/cdm_dataportal/taxon/e9925386-b197-4d81-a4fc-137ea96e6b4f/images) - link is unstable!

Expected behavior:

The aspect ratio of thumbnails should be determined by the first thumbnail image not by the fist image in the viewer part.

stephenwf commented 4 years ago

I think there are 2 factors. The height is set here:

https://github.com/UniversalViewer/universalviewer/blob/2a08b8aa87dce7dd5d4d6c65c63df495bebe9775/src/modules/uv-shared-module/ThumbsView.ts#L45-L57

Calculated from the median height of the images. https://github.com/UniversalViewer/universalviewer/blob/2a08b8aa87dce7dd5d4d6c65c63df495bebe9775/src/modules/uv-shared-module/ThumbsView.ts#L137-L142

The property used appears to be thumbs.height which may be calculated from the canvas height and width scaled down to fit.

Does the specification mention anything about thumbnails of different sizes/ratios @edsilv / @tomcrane ?

akohlbecker commented 4 years ago

I found a workaround for my case which at least works with universalviewer@v3.0.1:

The thumbnail dimensions are corrected if I set width and height of the thumbnails for the canvas size. You can see the change by comparing the attached manifest files: original= manifest.txt, tweaked=manifest-canvas-for-thumbs.txt (needed to use txt as file extension as github does not accept json)

I am not sure if this solution conforms to the IIIF Presentation API 3.0 specification or if I should fear that coming changes to UV will behave differently with respect to my workaround.

johnjung commented 3 years ago

I'm having a similar issue with this version 3 manifest. However in my case, all the images have the same height, so my issue doesn't seem to be related to median height.

I do see that this issue appears in both UV3 and UV4. This problem doesn't show up in a version 2 manifest with the same page images.

Please let me know if I should open a separate ticket for this issue, or if it's more appropriate to add it here. If there is anything I can do to help with testing or debugging, please let me know. Thank you!

johnjung commented 3 years ago

After searching a bit, I realized that the v3 example I gave above might be obfuscating the problem...this manifest might make it a bit clearer.

It looks like when UV opens this manifest, the thumbnail for whatever page it opens to is requested at 200px wide, no matter what width is specified in the thumbnail id. The other thumbnails get requested at whatever width was specified in the manifest.

Then, looking in the createThumbs() function that @stephenwf mentioned above, I see that the width and height properties of each item in the thumbs array has been scaled to a width of 200...so when UV calculates a median height, it calculates it based on 200px wide thumbnails.

I'll try to find more time to keep digging, but if this anyone has other information that could help me as I work please feel free to comment or send it along- I appreciate any help you can provide. (And if I can run any other tests or provide any additional info please let me know.)

johnjung commented 3 years ago

Ok, I see what's happening now. Here's where UV gets configuration options to determine the thumbnail width.

Right now, this function checks to see if the viewingDirection has been set in the manifest. If it has been set, it requests thumbnails based on the twoColThumbWidth and twoColThumbHeight config settings- otherwise it uses oneColThumbWidth and oneColThumbHeight.

My issue was that viewingDirection isn't required by the IIIF Presentation API, and I had been triggering the thumbnails in the side panel by adding a behavior of "paged" to my manifest. Here's a manifest that demonstrates the fix for my issue.

LlGC-szw commented 1 year ago

All issues will be triaged for further investigation or closure by the 28 September 2023. If your issue is still relevant and would like for it be investigated further please comment by 14 September 2023.