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
Strange image shift in .bmp files #5246
Comments
Hi. Basic question that will probably not help in the end - but what is 'Dataray WCF File Converter'? Could you link to it? |
It is a software for converting a laser beam profiling camera file (extension: *.wcf) one gets by Dataray software (when you use their own software for controlling and recording data with their beam profiling camera), you can download it here: |
My current theory is that we're not adjusting the PixelDataOffset appropriately https://medium.com/sysf/bits-to-bitmaps-a-simple-walkthrough-of-bmp-image-format-765dc6857393
|
The image is faulty, or unusual at least. The image data offset is supposed to point to the offset where the image data starts. That should've been 1078 in this image, but it instead points to the offset of the color palette at 54. So the 1024 palette values are being treated as pixels too (after Pillow already successfully read those same bytes as the palette first). Additionally, the size header at offset 2 is supposed to be the full file size, but in this image is actually 1024 less. Perhaps software like MS Paint uses this information to correct it? Doing something like Even after correcting for that I still get 12 pixels on the right that look like they should be on the left, though, and the bottom two lines of the image also look off. This doesn't look like a decoding error. Do you see that in MS Paint etc. too? |
You are right gofr. Errors: Warnings: After applying the correction for the errors, the file looks the same in every program. @flozirkus , did you try the last version of the wcf converter? |
I think the image is incorrectly formed, but I've created PR #5899 to handle it. |
What did you do?
I opened a *.bmp file which i converted via Dataray WCF File Converter.
What did you expect to happen?
Show the file as it appears in MS Paint, MS Photo App or Affinity Photo.
What actually happened?
The content is shifted by approximately 160 pixels to the left. Missing pixels are added to the right side (seems like the image was cut in two pieces and the left part was added on the right side). The image format matches (width and height). No error was given.
I also tested the files with XnView, Irfanview and Gimp and they all show the same strange behaviour.
What are your OS, Python and Pillow versions?
testfiles.zip
Annotation: My python code contains more stuff, but this example is enough to see the misbehaviour.
The text was updated successfully, but these errors were encountered: