Emf file is not handled correctly
What's problem
When I tried to open an emf file and convert it to a jpg file using Pillow, I found that Pillow did not handle the colors in the image correctly. Where it should be white (#FFFFFF), Pillow thought it was (#F8F8F8). I am sure that place is white because this emf image is made by me, and when I open this image with other image viewing software, there is white.
Environment
Windows 10 Python == 3.11.5 pillow == 10.4.0
How to reproduce this situation
Copy figure below into PowerPoint and then save the figure as fig.emf. Use code below and then you can find that the area that should be #FFFFFF has become #F8F8F8.
from PIL import Image
emf_path="fig.emf"
emf=Image.open(emf_path)
emf.show()
Copy figure below into PowerPoint and then save the figure as fig.emf
Could you kindly just attach the EMF file itself? If GitHub won't let you attach the file, compress it into a ZIP first.
Sure. I have uploaded a ZIP file. PillowIssue8271.zip
Hi. Pillow seems to use the Win32 API PlayEnhMetaFile to render the file in a fairly straightforward way, so I asked a question at https://learn.microsoft.com/en-us/answers/questions/2088347/incorrect-colours-from-playenhmetafile to see if we were missing anything.
The response was
The file can be investigated with a free vector graphics editor, which shows that it consists of a black border, having transparent background, and a centred smaller embedded image,. The background colour of the image is (248, 248, 248).
Other programs that displays this kind of images, such as Paint and Word, seem to alter the pixels.
So I don't think anything is wrong here.