Ok, so I have Python 2.5 with Windows XP. I want to create a program that will create and/or manipulate an icon (.ico) file. Is there any module that can do this? Thanks.
EDIT:
I will need to save the image back into a .ico file.
Try the Python Image Library or PIL for short. Also, take a look at this plug in for PIL that makes it handle images correctly on windows: http://code.google.com/p/casadebender/wiki/Win32IconImagePlugin
There is also this: pythonMagick
Related
I get continuously PIL Images, using while True loop, and want to show them as a movie.
I can show an image by img.show(), but this code inside the loop makes multiple windows.
Would you tell me the way to display them as a movie?
I think the easiest way is to use ImageMagick in the command line to great a .gif file with the following command, assuming your image files are named something like image-1.png, image-2.png:
sudo apt-get install imagemagick
convert -delay 20 -loop 0 image-*.png my_movie.gif
This will create a my_movie.gif in the same directory where your images are located.
Another way to create a movie from frames is to use Blender, an open source program based on Python. I don't think Pillow supports creating gifs or movie files directly; every solution I have seen involves some other library, so I think the best way is to go with a simple command line tool.
I know py2exe isn't compatible with Python 3.3(which I use) I tried using cx_freeze it worked but I need to have my files with my .exe also. I have a folder that has images that I use for my game and without them the game doesn't work. Anybody know how I can convert my 3.3 pygame with a folder to an .exe? P.S I'm on Windows 7
I figured it out
If you want to include other "data files" along with your code in the .exe, use a setup script to list all the files needed. These two links should help you: FAQs- Using Data Files and distutils setup script.
Also, another alternative is to use Qt's resource system to embed the data in your code. See these two links: The Qt Resource System and PyQT by example. (But if you're using pygame, you probably aren't also using Qt)
I wish to use python to place an image (say jpg or bmp) at a specific location on my Windows 7 desktop. I would also like the ability to drag it around using the mouse and for the python code to store it's final locations coordinates. So when Windows restarts (with the python code configured to run at startup), it reads the stored location and places the image back at its previous location.
Is this possible to do?
If it is, could someone please provide some suggestions on how to do it, as my python experience is pretty limited?
Thanks.
You need to use LVM_SETITEMPOSITION for arranging icons on the desktop.
There are a similar questions:
How can I programmatically manipulate Windows desktop icon
locations?
win32 programming
Python is not the best choice for this job, but if it's required try to look in to - commctrl, win32gui, and pywin32 libraries
I'm learning Python now and I want to develop a screen capture tool in Python.How I can do this work?
If you're on windows, use ImageGrab module along with Imaging library.
Something like:
from PIL import ImageGrab
ImageGrab.grab().save("screenshot.jpg", "JPEG")
I think the best way to do this would be create a higher level interface to ffmpeg. Unless you want to write the code to deal with X11 and record the screen, then it would be the best option.
If you test it on various platforms, then give useful error messages on things like incompatible sound systems, where to get certain video drivers, etc then this could be a pretty useful program.
I'm attempting to use Python to convert a multi-page PDF into a series of JPEGs. I can split the PDF up into individual pages easily enough with available tools, but I haven't been able to find anything that can covert PDFs to images.
PIL does not work, as it can't read PDFs. The two options I've found are using either GhostScript or ImageMagick through the shell. This is not a viable option for me, since this program needs to be cross-platform, and I can't be sure either of those programs will be available on the machines it will be installed and used on.
Are there any Python libraries out there that can do this?
ImageMagick has Python bindings.
Here's whats worked for me using the python ghostscript module (installed by '$ pip install ghostscript'):
import ghostscript
def pdf2jpeg(pdf_input_path, jpeg_output_path):
args = ["pdf2jpeg", # actual value doesn't matter
"-dNOPAUSE",
"-sDEVICE=jpeg",
"-r144",
"-sOutputFile=" + jpeg_output_path,
pdf_input_path]
ghostscript.Ghostscript(*args)
I also installed Ghostscript 9.18 on my computer and it probably wouldn't have worked otherwise.
You can't avoid the Ghostscript dependency. Even Imagemagick relies on Ghostscript for its PDF reading functions. The reason for this is the complexity of the PDF format: a PDF doesn't just contain bitmap information, but mostly vector shapes, transparencies etc.
Furthermore it is quite complex to figure out which of these objects appear on which page.
So the correct rendering of a PDF Page is clearly out of scope for a pure Python library.
The good news is that Ghostscript is pre-installed on many windows and Linux systems, because it is also needed by all those PDF Printers (except Adobe Acrobat).
If you're using linux some versions come with a command line utility called 'pdftopbm' out of the box. Check out netpbm
Perhaps relevant: http://www.swftools.org/gfx_tutorial.html