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'))
Related
I need to convert SVG with custom fonts into PNG, I’m using the following Python code for this.
import cairosvg
png = cairosvg.svg2png(bytestring=svg_data)
The code works fine on my local machine (running under Mac OS) with installed fonts. However, when I try to deploy it to remote Ubuntu instance the fonts somehow couldn't be loaded and I end up with PNG having some default fonts in it. The fonts are installed in the system (I've already tried different font folders, also fontconfig has the fonts in the list of available fonts) and the access rights seem to be in order. Any hints what could be going wrong will be useful!
Managed to solve the problem using Wand:
from wand.image import Image
with Image(blob=svg_data, format="svg") as image:
png_image = image.make_blob("png")
P.S. CairoSVG version still doesn't work.
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 would like to load a video file's frames into a numpy array. I want the frames to be properly upright, which means I need to read the orientation metadata in the video file, and rotate the loaded frames accordingly.
I have a means of loading the frames (opencv's python bindings), so all I need is a way to read the video file's orientation metadata.
I'm trying to read a .MOV file recorded off my iPhone, in python running on an Ubuntu 14.04 machine.
Stuff I've looked at:
opencv: no way of inspecting video orientation
hachoir-metadata: doesn't display orientation metadata
enzyme: only works on .mkv files, AFAICT.
ffmpeg: no longer available as a stand-alone executable on Ubuntu's repositories. This is a dealbreaker since I'd rather just hand-specify the rotation rather than go through the trouble of compiling ffmpeg from source just to get video orientation.
PIL, pyexiv: AFAICT, only loads image files.
I'm running the code on an Ubuntu 14.04 machine, so I'm looking for libraries or command-line programs available on that platform.
Any pointers would be greatly appreciated.
We use MediaInfo (libmediainfo)
it is running both on Windows and Ubuntu, and you can get all you need (codec, aspect, fps, bitrate, orientation...).
use qtrotate. It's just one file, and it works on .Mov files
https://github.com/danielgtaylor/qtrotate
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
Question(s):
I am trying to get a turtle graphic window to save as a jpg. Presently I can get it to save as a .ps or .eps file.
can=turtle.getscreen().getcanvas()
can.postscript(file="test1.eps")
From here, I was hoping to use Ghostscript to convert the file to jpg/png/pdf.
Using the ghostscript documentation, it looks like this would work: (https://www.ghostscript.com/doc/9.22/Use.htm#Invoking)
ps2pdf file.ps
Here is my dilemma. I cannot install ghostscript to my boot drive. I am on a network so this prevents me. I do have a drive I can install to, but I don't know if that will work with ghostscript and python. Any ideas?
GHOSTSCRIPT : I am not sure how ghostscript works with python (or otherwise). I tried to log into the IRC chat on the ghostscript site, but that doesn't seem active for non-paying customers.