I'm looking for something like PIL (Python Imaging Library), which sadly doesn't support WebP images.
I'd like to be able to do resizes and crops. Or at least convert to JPEG and then I can work it with PIL.
Take a look at:
http://code.google.com/p/python-webm/
I was able to walk through the test file to see how they were doing it.
imagemagick's convert tool, version 6.5.7-8 or better, can manipulate WebP images.
Also, Google provides an encoder and decoder for Linux, Windows and Mac OS X.
Related
I am converting jpg to webp format using cwebp tool provided in official doc.
I am checking if PIL library supports converting images from jpg to webp with all the support cwebp CLI has? like -lossless or quality -q.
I am asking this because I didn't see any documentation for the same.
Thanks.
I was trying to convert a pdf to images using a python script and Wand with ImageMagick bindings. But, I really want to avoid using Ghostscript? Is it possible to do because the installation of Wand doesn't mention anything about Ghostscript but it seems that it is mandatory to have the conversion from pdf to an image using python. Has anyone tried doing the same?
There is also a similar issue open in the Wand git repo (https://github.com/dahlia/wand/issues/319). This means that it is really not possible to convert pdf to png without Ghostscript?
Can this be an issue based on OS and ImageMagick version? I am using MacOS and ImageMagick#6. For some reason, I was not able to run the latest ImageMagick(7.1) on Mac. So, if anyone has tried on a different OS or with latest version of ImageMagick, inputs are welcome.
ImageMagick ultimately pipes out to Ghostscript for the conversion.
And poorly as well. I just had this issue a few months ago in PHP script, where crystal reports created badly formed PDF files, that ImageMagick attempts to fix, and throws a java error, but Ghostscript can convert it just fine if ImageMagick is bypassed.
Execute ghostscript with this command line
-dJPEGQ=95 -r600 -dNOPAUSE -q -sDEVICE=jpeg -dBATCH -sOutputFile="OutputImage_%d.jpeg" "SourcePDFPath.pdf" to turn a PDF into multiple jpegs
Background:
I have to upload images from users.
Problem:
The images need to be re-sized so that I don't end up with huge images on my disk. This re-sizing should happen just after the image is saved.
I have checked the following code
Django Snippet for image scaling
But couldn't use it directly, as the windows path of the image was giving a issue. Is there a simple way in which the scaling can be done. Are there any python or django modules which can directly be used for this ?
If yes which will be the most optimized one ?
Make use of the Python PIL library. With this library you can manipulate images and make the changes you require. There are loads of examples of using PIL over the net.
I would recommend you using the PIL library and writing your own code as it can be a lot easier than trying to get third party libraries working (personal experience).
What are some of the better libraries for image generation in Python? If I were to implement a GOTCHA (for example's sake), thereby having to manipulate an image on the pixel level, what would my options be? Ideally I would like to save resulting image as a low-resolution jpeg, but this is mere wishing, I'll settle for any common image format.
Thank you for your attention.
The Python Imaging Library (PIL) is the de facto image manipulation library on Python. You can find it here, or through easy_install or pip if you have them.
Edit: PIL has not been updated in a while, but it has been forked and maintained under the name pillow. Just install it this way in a shell:
pip install Pillow
The import statements are still the same as PIL (e.g., from PIL import image) and is backward compatible.
Pillow is a fork of PIL that is still actively developed. While PIL is not dead it has been a number of years since the last release.
If you should generate text or other vector based images (and then save to .png or .jpg), you could also consider Cairo (PyCairo, in this case). I use it a lot.
Otherwise, for pixel-level manipulation, PIL is the obvious choice.
What's the easiest way to generate a bitmap using Python?
Text support would be nice but not required.
(On Mac, I was trying to use Quartz through Python, but Snow Leopard seems to have broken its functionality. Therefore I've decided to look for a solid, simple, cross-platform solution that won't break each time the OS is updated.)
Use the Python Imaging Library:
"The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities."
I'm not a Mac person so I can't help with Mac specifics, but I do know it works on the Mac.