-
Notifications
You must be signed in to change notification settings - Fork 1
PDF page to image conversion on upload #121
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
base: develop
Are you sure you want to change the base?
Changes from all commits
b9d98e0
f27eb3f
4ccc016
ddc8d2b
3ac5cae
14a2bea
0db7e7a
18c10b5
5213487
3e6a41c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,30 +25,53 @@ def iiif | |
| page_number = params[:page] || 1 | ||
|
|
||
| redirect_resource do |resource| | ||
| resource.image? ? resource.content_converted_iiif_url(page_number) : resource.content_iiif_url(page_number) | ||
| if resource.converted_pages? | ||
| resource.content_converted_pages_iiif_url(page_number.to_i) | ||
| elsif resource.image? | ||
| resource.content_converted_iiif_url(page_number) | ||
| else | ||
| resource.content_iiif_url(page_number) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def image_api | ||
| page_number = params[:page] || 1 | ||
|
|
||
| redirect_resource do |resource| | ||
| resource.content_image_api_url( | ||
| page_number, | ||
| params[:region], | ||
| params[:size], | ||
| params[:rotation], | ||
| params[:quality], | ||
| params[:format] | ||
| ) | ||
| if resource.converted_pages? | ||
| resource.content_converted_pages_image_api_url( | ||
| page_number, | ||
| params[:region], | ||
| params[:size], | ||
| params[:rotation], | ||
| params[:quality], | ||
| params[:format] | ||
| ) | ||
| else | ||
| resource.content_image_api_url( | ||
| page_number, | ||
| params[:region], | ||
| params[:size], | ||
| params[:rotation], | ||
| params[:quality], | ||
| params[:format] | ||
| ) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def info | ||
| page_number = params[:page] || 1 | ||
|
|
||
| redirect_resource do |resource| | ||
| resource.image? ? resource.content_converted_info_url(page_number) : resource.content_info_url(page_number) | ||
| if resource.converted_pages? | ||
| resource.content_converted_pages_info_url(page_number) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we do
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch; seems safer to me to just do the conversion inside |
||
| elsif resource.image? | ||
| resource.content_converted_info_url(page_number) | ||
| else | ||
| resource.content_info_url(page_number) | ||
| end | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -64,14 +87,30 @@ def manifest | |
| end | ||
|
|
||
| def preview | ||
| page_number = params[:page] || 1 | ||
|
|
||
| redirect_resource do |resource| | ||
| resource.image? ? resource.content_converted_preview_url : resource.content_preview_url | ||
| if resource.converted_pages? | ||
| resource.content_converted_pages_preview_url(page_number) | ||
| elsif resource.image? | ||
| resource.content_converted_preview_url | ||
| else | ||
| resource.content_preview_url | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def thumbnail | ||
| page_number = params[:page] || 1 | ||
|
|
||
| redirect_resource do |resource| | ||
| resource.image? ? resource.content_converted_thumbnail_url : resource.content_thumbnail_url | ||
| if resource.converted_pages? | ||
| resource.content_converted_pages_thumbnail_url(page_number) | ||
| elsif resource.image? | ||
| resource.content_converted_thumbnail_url | ||
| else | ||
| resource.content_thumbnail_url | ||
| end | ||
| end | ||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the other endpoints in this file need the
resource.converted_pages?check and fork to use the new URLs you defined inresource.rb?e.g.
image_apican usecontent_converted_pages_image_api_url,infocan usecontent_converted_pages_info_url, same sort of thing forpreviewandthumbnailThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point; I've added all the ones that seem relevant but I admit to not having a thorough sense of all the contexts in which these endpoints are used so I haven't tested fully. Thumbnails and previews seem to work as expected at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info: redirects to info.json, the IIIF Image Information doc (dimensions, tile sizes, formats). Viewers fetch this once before requesting any tilesimage_api: the full IIIF Image API endpoint (with params like size, rotation, etc). This is the most-fetched endpoint by IIIF viewers with deep zoom capabilitiesiiif: convenience redirect to an image or page as a JPEG (at full max res/full/max/0/default.jpg)previewandthumbnailare pretty self explanatory, they are fixed size JPEG derivatives