Comments (16)
btw, the tomato photo I provided eariler is not very representitive, since the
gain map
is all 1.0s (completely white).
please look at my first message.
It is not white.
from pillow.
Are there any images with a small file size that could be added to our test suite and distributed under the Pillow license?
I, as the author of the tomato photo and the trees photo, agree to add these to the Pillow test suite and to adhere to its licensing terms.
I don't have smaller ones, since this is already the 'medium resolution'; the other option is 'full resolution.'
from pillow.
Pillow should either reject a gain map and show only primary image, or it should decode second frame correctly, even with lower resolution.
I've created #8056 to treat Ultra HDR images as standard JPEGs, ignoring the gain map. I would consider decoding the second frame correctly to be a matter for #8036
from pillow.
Sorry my bad, I tested it on Pillow 10.2
on Pillow 10.3 there is no error when decoding, just second image looks wrong.
Updated issue to reflect this. Sorry for mess.
from pillow.
Hi, @bigcat88 , 10.3.0 correctly extract the second frame with a different resolution. However, the second frame is not actually a frame, it's a gain map
according to this UltraHDR format.
A JPG file should only have one frame. And people naturally expect the second frame would in the same resolution as the first one. That's the problem we have in comfyanonymous/ComfyUI#3416 (comment)
So, supporting UltraHDR is a good way to go, I guess. #8036
from pillow.
10.3.0 correctly extract the second frame with a different resolution
No it does not, imho.
Pillow should either reject a gain map
and show only primary image, or it should decode second frame correctly, even with lower resolution.
from pillow.
btw, the tomato photo I provided eariler is not very representitive, since the gain map
is all 1.0s (completely white). I didn't understand this was related to the UltraHDR format earlier.
Here is another photo I took that has something in the gain map
:
we can see the gain map
is smaller comparing to the original photo.
from pillow.
perhaps gain maps need their own type returned from .get_bands() or some way to explicitly exclude them from ImageSequence.Iterator
from pillow.
Are there any images with a small file size that could be added to our test suite and distributed under the Pillow license?
from pillow.
Thanks very much for the test image. I've included it in the PR.
from pillow.
Pillow should either reject a gain map and show only primary image, or it should decode second frame correctly, even with lower resolution.
I've created #8056 to treat Ultra HDR images as standard JPEGs, ignoring the gain map. I would consider decoding the second frame correctly to be a matter for #8036
Im not familiar with the specs for MPO or Ultra HDR, but I am assuming the smaller gain map is embedded in the exif data of the main photo and is being extracted as a seperate file when opening images? Is there any way to reattach the gain map to the exif of the main image so the data is still there later but it is only presented as a single image? I imagine there are future uses where preserving the data is preferred behavior, but presenting them as seperate image is not.
from pillow.
My suggestion will just change the automatic detection of the image format. If a user would like to retain the current behaviour, they could open it directly as an MPO
from PIL import MpoImagePlugin
im = MpoImagePlugin.MpoImageFile('input.jpg')
im.show()
from pillow.
Gotcha, My quick read suggests MPO is MultiPictureObject format, intended for stereographic images, but the Ultra HDR spec hijacks it using the 2nd image as a gain map.
It seems like this being in xmp meta-data separates one of these UltraHDR images from a true MPO stereoscopic file where both images would be wanted:
<rdf:li rdf:parsetype="Resource,
<Container: Item
Item: Semantic="GainMap"
Item: Mime=" image/jpeg"
Item: Length="66171" />
</rdf:li>
It seems like users should not have to be familiar with different implementations of the same file specification to be able to get the proper output when opening a file, so a quick parse of the XMP looking for Item: Semantic="GainMap", should differentiate between a true MPO stereoscopic file, and an UltraHDR file, and dictate if standard opening behavior shows one image, or two.
from pillow.
In #8056, I'm checking for the "Signal of the format", 'hdrgm:Version'.
If you're trying to say that isn't the best way to check if an image is Ultra HDR or not, I'm not following why. Nor does the spec seem to indicate that an Ultra HDR image will be anything other than a single JPEG without a gain map.
from pillow.
Gotcha, I was suggesting that maybe checking both is a good way to guard against improper spec implementation. It seems less likely to me that they forget to label their gain map in the XMP than it is that they specify the hdrgm:Version incorrectly. In any case, they are both in the XMP, and redundancy never hurt anyone.
from pillow.
For the moment, unless you've found a malformed image like that in the wild, I'd rather not double check. When it comes to identifying a format, I don't think it's Pillow's overall style.
If/when #8036 is resolved, then I expect both the signal and the gain map to be required.
from pillow.
Related Issues (20)
- Windows Docker / nanoserver support HOT 8
- Save GIF without loss of quality HOT 23
- scientific-python-nightly-wheels-publish triggered in fork HOT 1
- `ImageFont` claims to load font sizes in pixels but seems to use points? HOT 6
- Problems HOT 1
- Emf file is not handled correctly HOT 2
- Bitmap missing for glyph HOT 4
- ImportError: cannot import name '_imagingft' from 'PIL' HOT 7
- Cannot install Tkdesigner HOT 2
- Cannot install Tkdesigner HOT 14
- Add XMP writing HOT 7
- Add SVG Support Using PlutoSVG HOT 3
- ImageDraw.rounded_rectangle: wrong ValueError HOT 2
- Crash when using `Draw.text` with invalid type HOT 2
- ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (python3.7, PILLOW vers < 9.0) HOT 8
- Scale factor for resizing HOT 3
- `ValueError: encoding error 5` during WEBP encoding should be replaced with something more informative HOT 3
- Impossible to detect multi-images tiff pages HOT 6
- OSError: broken data stream when using OpenJPEG 2.5.2 HOT 8
- Arrow Support HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pillow.