Search code examples
pythondjangopython-imaging-librarypsd

Python: Open PSD images (Django form)


is there a way to get size and content type of a PSD image while cleaning its form field?
The Image.open() raises this error:

IOError: cannot identify image file <InMemoryUploadedFile: Untitled-1.psd (image/vnd.adobe.photoshop)>

Solution

  • It looks like the issue might be because the file is still in memory. With an example PSD saved off the internet, I'm able to use the file command which returns the following:

    $ file 05.psd 
    05.psd: Adobe Photoshop Image, 800 x 800, RGB, 3x 8-bit channels
    

    Therefore, I think you're going to need to save the file to the file system at "cleaning time", and then analyse it with Image.