-
Notifications
You must be signed in to change notification settings - Fork 111
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
Incorrect upscaling for some files with size=max #680
Comments
Hi @mmatela. Could you share the info.json output for that image?
I will check the code that sets up the operations and see what I can find out |
Thanks for looking into this @DiegoPino Attaching info from http://localhost:8182/iiif/3/2.jpg/info.json : IrfanView shows the file indeed has resolution of 400x400 dpi. I think we can rule out cache, this is the first time I've started Cantaloupe on this machine and this 2.jpg file has never changed. |
hi @mmatela. I tested locally on my self built Cantaloupe (Docker) and I can't reproduce it. Always generated Not sure if the act of uploading the image to GitHub/me downloading it might have re-encoded the JPEG? I used this docker container: If you could give 5.0.5 a try while I figure out what has changed/is different? I can't try a vanilla 5.0.6 today but will put in my todo list. |
I see the same problematic behavior with 5.0.4 and 5.0.5. With the file downloaded from github through this link: https://github.com/user-attachments/assets/eca73bfc-7194-4a50-9830-beee020d9e1a (redirected the browser to amazonaws, then I pressed ctrl+s) |
Wonder if java 21 has something to do with this. Do you see any errors/warnings in your cantaloupe log? |
I first noticed this problem on a Linux machine with Java 11. console output during request handling (changed the file name to make sure it's loaded from scratch):
There's the suspicious number |
Yes, that is strange. According to the code, cantaloupe/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/Size.java Line 178 in 60c3e2b
Could you please try enabling your derivative cache? and also force Java2D (manual source selection) to be JPEG processor? Need to check more |
@mmatela any updates on this? Checking so we keep debugging this or mark as resolved. Thanks |
@DiegoPino Oh, I thought you'd be able to run version 5 locally and reproduce the problem, should be more efficient than having this back and forth. Like you said:
|
@mmatela I have not been successful replicating the issue, maybe because but I don't have a Windows/Java 21 combo to test? |
Like I said, I've seen the same behavior on Linux with Java 11 and Windows with Java 21, so it doesn't seem to be OS/Java dependent. So far you've reported trying a docker with version 6.0.1. Did you try to simply download the latest release and run it with
I just took the sample properties file from the release package and only changed
OK, but I don't see how trying to run it on my side with different configs will help with that. |
@mmatela the issue is we can not fix backwards an existing release. 5.x is done. We can only fix our ongoing/live code base (6.x from the |
@mmatela update: spent the last 3 hours debugging this. @glenrobson (ping just so you know this is happening) I ran a vanilla 5.0.6 JAR file on JAVA 22 with your file changing just the filesystem path and I can replicate the issue. Then retested on a fully functional docker container (will all the dependencies using a fresh I have so far really no idea, I compared the source classes for The code cantaloupe/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v3/Size.java Lines 199 to 236 in 60c3e2b
Should return scale by percent because (maxScale being the max_scale property == 1.0) and DELTA == 0.000001 So other maxScale in not being processed or there is a floating point comparison issue? Clueless.
What I will do (tomorrow, 3 hours is my limit) is to do the same test with a |
@mmatela @glenrobson ok, I got this. This is actually a bug (or an interpretation/math issue). And it still exists in Let me explain what I found out:
@mmatela can you please delete your derivative caches *if you enabled them *, clear your browser cache and modify Debugging where the error(s) is/are and making a pull will take me some time. Some help might be great! |
Further debugging. Seems that the issue is happening because of: (for my own reference) cantaloupe/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/IIIFResource.java Lines 32 to 56 in 773ddee
|
And might be also the culprit for |
So. I know where this is happening (woho!). There is a chain of calls that happen just after the operation list is built cantaloupe/src/main/java/edu/illinois/library/cantaloupe/resource/ImageRequestHandler.java Line 395 in e025db6
cantaloupe/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/ImageResource.java Lines 96 to 105 in e025db6
But the size passed there is unaware of cropping (info.size is the full size of the source). So There are two options here:
@jcoyne @ksclarke @glenrobson am I understanding the IIIF Image API specs correctly? |
Congrats @DiegoPino on finding the issue!
I think you are correct. "max : The extracted region is returned at the maximum size available, but will not be upscaled. The resulting image will have the pixel dimensions of the extracted region, unless it is constrained to a smaller size by maxWidth, maxHeight, or maxArea as defined in the Technical Properties section." |
Resolved via b9d6bae |
Using cantaloupe 5.0.6, default settings except for FilesystemSource.BasicLookupStrategy.path_prefix. Java 21.0.1 on Windows, but experienced the same on other versions of Java on Linux.
Attaching sample file 2.jpg
When trying to get a fragment of size 100x100 with this url: http://localhost:8182/iiif/3/2.jpg/100,100,100,100/max/0/default.jpg i get the fragment upscaled to size 2604x2604 instead.
It works correctly when using size pct:100 instead of max (should there ever be a difference for these two?): http://localhost:8182/iiif/3/2.jpg/100,100,100,100/pct:100/0/default.jpg
It works correctly with image api v2: http://localhost:8182/iiif/2/2.jpg/100,100,100,100/full/0/default.jpg
Somehow it accepts size=max for v2, and also returns upscaled to 2604x2604: http://localhost:8182/iiif/2/2.jpg/100,100,100,100/max/0/default.jpg
I tried some other files in both jpg and other formats and for most of them it correctly returns 100x100, so it must be something inside the content file, but I'm not aware of any properties that should lead to this result.
The text was updated successfully, but these errors were encountered: