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

'ValueError: unknown raw mode' when converting large TIF file #3828

Closed
anpr opened this issue May 6, 2019 · 7 comments
Closed

'ValueError: unknown raw mode' when converting large TIF file #3828

anpr opened this issue May 6, 2019 · 7 comments
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects

Comments

@anpr
Copy link

anpr commented May 6, 2019

What did you do?

I tried to open this large TIF file with Pillow 6.1.0 (sha 0e36b28) in the following way:

from PIL import Image
image = Image.open(input_path)
thumbnail_size = (800, 800)
image.thumbnail(thumbnail_size, Image.ANTIALIAS)

What did you expect to happen?

No exception. I can later save the image with image.save(output_path)

What actually happened?

The following exception occurred:
ValueError: unknown raw mode

What are your OS, Python and Pillow versions?

  • OS: Inside a Docker container, Debian stretch 9
  • Python: Python 3.7.3
  • Pillow: Pillow 6.1.0 (sha 0e36b28)

This is a follow-up issue of #3815

@aclark4life aclark4life added the Bug Any unexpected behavior, until confirmed feature. label May 11, 2019
@aclark4life aclark4life added this to Backlog in Pillow May 11, 2019
@aclark4life aclark4life moved this from Backlog to In progress in Pillow May 11, 2019
@anpr
Copy link
Author

anpr commented Jun 17, 2019

Any news on this? Is there any way to help?

@radarhere
Copy link
Member

Apologies for not getting this the first time. I've created PR #3913 to help. If that is merged, you will be able to do -

from PIL import Image
image = Image.open('alp-1978-big-tif.tif')
image.thumbnail((800, 800))
image.copy().save('out.tif')

You will not be able to run that code without the copy() - presumably this is because of something more complicated to do with the TIFF format.

@hugovk
Copy link
Member

hugovk commented Jun 22, 2019

@anpr Please can you check if the PR helps?

@radarhere
Copy link
Member

The PR has now been merged, so you can check master.

@radarhere
Copy link
Member

Pillow 6.1.0 has now been released, so the improvement is now a part of that.

@anpr
Copy link
Author

anpr commented Jul 5, 2019

Sorry for the delay, we only could test it now. We did test it now, using the 6.1.0 release, and indeed everything works as expected!

Thanks a lot :-)

@anpr anpr closed this as completed Jul 5, 2019
Pillow automation moved this from In progress to Closed Jul 5, 2019
@Dionysusnu
Copy link

I'm having this same issue, even if using .copy() in between.

Traceback (most recent call last):
  File "convertdds.py", line 11, in <module>
    img.copy().save(filename[0:len(filename)-4]+".png")
  File "C:\Users\myusername\AppData\Local\Programs\Python\Python38-32\lib\site-packages\PIL\Image.py", line 1115, in copy
    self.load()
  File "C:\Users\myusername\AppData\Local\Programs\Python\Python38-32\lib\site-packages\PIL\ImageFile.py", line 230, in load
    decoder = Image._getdecoder(
  File "C:\Users\myusername\AppData\Local\Programs\Python\Python38-32\lib\site-packages\PIL\Image.py", line 439, in _getdecoder
    return decoder(mode, *args + extra)
ValueError: unknown raw mode
import os
import sys
from PIL import Image

directory = sys.argv[1]
for filename in os.listdir(directory):
    if filename.endswith(".dds"):
        filename = os.path.join(directory, filename)
        print(filename)
        with Image.open(filename) as img:
            img.copy().save(filename[0:len(filename)-4]+".png")

I'm iterating over a directory of dds files and converting them to png. The first 20 or so work fine, but I consistently get this error at a specific file. Any ideas why or how to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
Pillow
  
Closed
Development

No branches or pull requests

5 participants