-
Notifications
You must be signed in to change notification settings - Fork 105
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
TurboJPEG has problems tiling images from PDFBox #482
Comments
@cmhdave Could you try this in 5.0.2? |
Sure enough, works like a charm with 5.0.2. I will mark as closed. Thanks @adolski ! |
We are seeing this exact same issue once again with v5.0.4. I can remove TurboJPEG and it works fine, add it back in and the behavior we see above returns. |
…482) This works around an apparent bug in TJCompressor whereby it does not deal correctly with images produced by BufferedImage.getSubimage()
In the past, the code in |
I tried sample.pdf with this commit fff5425 and it mostly works but not for images with x=0 on y axis. E.g. will return the same image as
@adolski could you check please? |
From my limited understanding the issue is that the patch has a typo (the same condition twice which escapes the Y offset when X is not offset): if (image.getRaster().getSampleModelTranslateX() < 0 ||
image.getRaster().getSampleModelTranslateX() < 0) { Should be if (image.getRaster().getSampleModelTranslateX() < 0 ||
image.getRaster().getSampleModelTranslateY() < 0) { I will make a fork and test locally during the weekend if anyone is still observing this. removing the TurboJPEG library is still a workaround but because it is quite deep into the code, manual strategy needs to be selected and an ugly warning appears. |
I am so glad that this issue got your attention. |
@hrvoj3e I'm building a multi arch docker container right now, if all goes well will share the tag so you can test (or use in production). Will still make a pull request against |
See #593 (comment) |
We are seeing issues with TurboJPEG and tiling PDFs. It is really strange and arbitrary. What I can say is that it does not happen when you remove TurboJPEG from the processing chain. I am able to reproduce this every time with the sample.pdf file that I've created and attached.
What you need to do is start Cantaloupe 5.0 with TurboJPEG available in the library path. We do this like so:
Then you open a tile like below (which happens to be a tile that was being requested from our manifest via Mirador)
http://localhost:8182/iiif/2/sample.pdf/512,512,512,512/512,/0/default.jpg
The resulting image starts at x=0, y=0 instead of x=512, y=512.
Now try the same URL with a PNG extension and you will get the correct tile.
http://localhost:8182/iiif/2/sample.pdf/512,512,512,512/512,/0/default.png
Here's where it gets strange. If you load the PDF as a JPG with a slightly different size it works correctly (notice
513,
rather than512,
http://localhost:8182/iiif/2/sample.pdf/512,512,512,512/513,/0/default.jpg
Another strange thing is that I can debug this in IntelliJ into
TurboJPEGImageWriter
inwrite(BufferedImage image, OutputStream os)
where when you calltjc.setSourceImage(image, 0, 0, 0, 0)
the image IS THE CORRECT TILE.Yet this is what gets rendered in the browser.
I have all very basic controls turned on and no caching enabled (to rule out an caching issue)
========
sample.pdf
The text was updated successfully, but these errors were encountered: