I've got this multi-image tiff and when I try to open it with PIL like so
from PIL import Image
Image.open(image_path)
I receive the following exception:
OSError: cannot identify image file 'image.tiff'
However I am able to split the tiff into multiple valid single-image tiffs using ImageMagick via the following command on ubuntu 16.04:
convert image.tiff img_split-%d.tiff.
This means that the file is valid.
Question
Why can't I open the file using PIL?
And if it is impossible to use PIL in this situation, what other library can I use to interact with the images in the file?
Related
I dont know what to import and how to do this. How do I print and add a image in python.
I have tried nothing im just looking for suggestions.
In the console it's impossible, but you can use OpenCV, PIL, or matplotlib to display images.
With OpenCV you can display the pixel value in the console:
If you are interested in image manipulation check out Pillow. It's an image manipulation/processing library.
You can install it with:
python -m pip install Pillow
To load an image and show it use this:
from PIL import Image
im = Image.open("image.png")
im.show()
For more examples and information check out the official documentation.
I am trying to open an image using pyautogui so i can compare the images pixels. I have looked in the auto correction in visual studio code and I looked in a documentary about it. Can someone please tell me how to do it?
well you can do it by PIL (pillow) like -
from PIL import Image
im = Image.open(r"path\to\image.png")
im.show()
ICO created from PNG or JPG with python Pillow are not working on Windows XP. ICO works fine on Vista and later versions.
I wrote a simple code which demonstrate that an ICO which was working on XP and saved with PIL break it on XP:
from PIL import Image
original = Image.open('favicon.ico') # you can try with whatever format
original.save('newfavicon.ico') # not recognized on XP
I am using Python 2.7.
Do you know if there is anything special with ICO on XP?
Do you have suggestion of other lib I could try?
It is not working with Pillow because ICO is saved PNG format, see answer here https://github.com/python-pillow/Pillow/issues/1102
It is working properly with PythonMagick.
I'm using Pillow 2.2.1 (installed it with pip) on Ubuntu Server 12.04 64-bit and trying to batch resize images into jpeg format. I've also installed both zlib1g-dev and libtiff-dev with apt-get.
I use the following line
Image.open(path/to/image)
to open the image files (jpeg and tiff's). I can open some tiff images, but for others I just get the following error:
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 2006, in open
raise IOError("cannot identify image file")
Since this doesn't occur for every tiff image I try to open does this mean that these files are corrupted? I have no problem opening the images in question with windows photo viewer or even with GIMP though.
Note: All the images were just given to me by my client so I have no idea how he digitized the images (scanned or took a picture of them is my best guess), or if that even matters.
Am I missing a package or dependency, or is there really just something about the image files that I'm not seeing?
TIFF is only a container format (like AVI on the video). The file extension does not actually signify how the image data inside is encoded. Most professional photo editing applications create their own flavour of TIFF which is unreadable in other software. PIL might support only certain subset of TIFF flavours (e.g. uncompressed).
If your system is a web upload style system I suggest you stop accepting TIFF format to avoid problems altogether.
More information: http://en.wikipedia.org/wiki/Tagged_Image_File_Format
I cant load images thats not BMP files in pygame.
Ive searched everywhere for solution but I couldn't find one.
In pygame site they say this:
The image module is a required dependency of Pygame, but it only
optionally supports any extended file formats. By default it can only
load uncompressed BMP images. When built with full image support, the
pygame.image.load - load new image from a file function can support
the following formats.
I couldn't understand what to do, and how can I get the full build image support.
I am running python 3.3 on ubuntu 13.04.
I'm new to python.
help?
the error:
File "/home2/tor/workspace/PYGAME/src/Main.py", line 13, in <module>
ball = pygame.image.load("/home2/tor/Downloads/ball.gif")
pygame.error: File is not a Windows BMP file
BTW I also tried this on jpg file.
Your version of Pygame may not be sufficient for Python 3 on your system, I believe ubuntu 13.04 comes with Python 3 installed by default, I am not sure if it has Python 2, but if it did happen to have it, I would use that instead.
Information from this question: PyGame.error in ubuntu
Right below where it says "can support the following formats" the list says:
JPG
PNG
GIF (non animated)
BMP
PCX
TGA (uncompressed)
TIF
LBM (and PBM)
PBM (and PGM, PPM)
XPM
Although it does say it is not a Windows BMP file, that does not mean it has to be bmp. I do not believe gif is supported when animated as the list says.
Here is an example from the pygame comments for a png image.
char_surf=pygame.image.load(os.path.join('data', 'char.png'))