Open gopherbot opened 13 years ago
Example image from Martin (OP), who couldn't attach stuff here.
Attachments:
On a related note, a substantial number of the pics in my collection (which I would like to handle with camlistore) have a 4:4:0 downsampling ratio (hv = 0x12). So it's not exactly the same error, but I think it's an issue pretty close to this one. Do you want me to open another issue for that? Attached is an example of such a pic.
Attachments:
The image really has different Cb and Cr sampling: $ identify -format "%[jpeg:sampling-factor]" 11100602s.JPG 2x2,1x1,2x2 (The image seems to be made with anabuilder, an old freeware tool from 2006 based on Java 1.4.) Allowing this without breaking Go 1 API seems complicated. Currently type YCbCr struct { Y, Cb, Cr []uint8 YStride int CStride int SubsampleRatio YCbCrSubsampleRatio Rect Rectangle } allows only for same rate sampling of Cb and Cr. As this is a) common and b) sensible it does not seem worth changing. But such images are legal jpegs (in my understanding of the spec). It should be able to decode such an 2x2,1x1,2x2 image into 2x2,1x1,1x1 (4:2:0) YCbCr by subsampling Cr. This would keep the image dimensions but discard some chroma information contained in the image. (To keep the chroma information one _could_ return an image.RGBA.) Is this a) worth fixing and b) would downsampling Cr be the right fix?
Would adding YCbCrSubsampleRatio421 in the appropriate places break the API? An image that formerly gave an error on decoding would instead yield a YCbCr struct with a new SubsampleRatio value, which client code that directly examines chroma subsampling may not be designed to handle. Isn't this a fix to a buggy library, which is allowed?
You could avoid discarding chroma information by decoding to 4:4:4 and duplicating one of the chroma channels. I think that it's do-able, without breaking backwards compatability, but it does add more complexity to the code, and I'm not sure if it's worth the cost, given how infrequent such images are. The image/jpeg package doesn't promise to be a complete JPEG implementation. For example, it doesn't support 12-bit JPEG images, or arithmetic-coded JPEG images. I note that https://en.wikipedia.org/wiki/Chroma_subsampling#4:2:1 currently says that '4:2:1' "is not expressible in J:a:b notation. '4:2:1' is a hangover from a previous notational scheme, and very few software or hardware codecs use it."
The Bleau_082007-001.jpg image should work fine now with Go tip's image/jpeg.
The 11100602s.JPG image still doesn't work, but comments 12 and 16 are still valid.
Hello, i'm interested working on this. I run into this kind of images recently (2x2,1x1,2x2 and 2x2,1x1,1x2 subsampling) from a big swedish media site.
After messing around a bit i think i ended with half-doing what @nigeltao suggested in comment 16 and it looks like this:
Does not look too far away but some implementation guidance would be nice.
Example images:
https://static-cdn.sr.se/images/3052/9f978572-ed62-4f0f-a6b4-9e7506cb6c44.jpg?preset=256x256 https://static-cdn.sr.se/images/2519/4ed3bde6-46a3-469b-af8e-5c2bde6d1749.jpg?preset=256x256
Does not look too far away but some implementation guidance would be nice.
Unfortunately, I don't have any spare time to give implementation guidance. It'd have to be up to somebody else to volunteer.
Does not look too far away but some implementation guidance would be nice.
Unfortunately, I don't have any spare time to give implementation guidance. It'd have to be up to somebody else to volunteer.
Understand that, thanks for answering
by laeuter: