Skip to content
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

PIL.UnidentifiedImageError: cannot identify image file (DDS file) #7517

Closed
finalcraftRu opened this issue Nov 2, 2023 · 3 comments · Fixed by #7589
Closed

PIL.UnidentifiedImageError: cannot identify image file (DDS file) #7517

finalcraftRu opened this issue Nov 2, 2023 · 3 comments · Fixed by #7589

Comments

@finalcraftRu
Copy link

finalcraftRu commented Nov 2, 2023

Hello! i try to make .DDS to .PNG converter but when i call code it raises PIL.UnidentifiedImageError: cannot identify image file

# Imports
from PIL import Image
import os

# Define names
file = 'C:\DDS\Portrait_Britain_Alan_Brooke.dds'
l = len(os.listdir("SOV"))+1
name = f'SOV/{l}.png'

# Load image
with Image.open(file) as im: # in this line error
    im.save(name)

screenshot of console:
error
this file:
Portrait_Britain_Alan_Brooke.zip

@radarhere
Copy link
Member

Just as an explanation, the image contains uncompressed RGB data with a bitcount of 16 - it looks like it is compressing the three channels into the space normally allocated for two. Pillow doesn't yet support this configuration.

Is the image one that can be added to our test suite, and distributed under Pillow's license?

@finalcraftRu
Copy link
Author

Yeah, I don't mind adding it, but this image was taken from the Hearts Of Iron 4 files

@radarhere
Copy link
Member

radarhere commented Nov 27, 2023

I've created PR #7589 to resolve this. I created a test image derived from one of our existing images.

With it, I can resave your image as the following PNG.

out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants