jpeg

How to output unicode characters and lines into an image file?

How to output unicode characters and lines into an image file? Question: I want to create a jpg or any other image format files for chinese characters, how do i do it? My input textfile (in utf8) looks like this: 阿贝•斯兰尼t是t美国人 Reading it is simple, i could simply do codecs.open(‘intext.txt’,’r’,’utf8).read().strip().split(‘t’) but how can I output …

Total answers: 1

In OpenCV (Python), why am I getting 3 channel images from a grayscale image?

In OpenCV (Python), why am I getting 3 channel images from a grayscale image? Question: I am using Python (2.7) and bindings for OpenCV 2.4.6 on Ubuntu 12.04 I load an image image = cv2.imread(‘image.jpg’) I then check the shape of the image array print image.shape I get (480, 640, 3), which I expect for …

Total answers: 4

OpenCV Python save jpg specifying quality; gives SystemError

OpenCV Python save jpg specifying quality; gives SystemError Question: I just installed the newest OpenCV 2.4 on windows 7 (32bit)/ Python 2.7.3, but I still get the same error I got using the beta version: >>> import cv2 >>> a = cv2.imread(r”DMap.jpg”) >>> a.shape (1080, 1920, 3) >>> cv2.imwrite(‘img_CV2_90.jpg’, a, [cv2.IMWRITE_JPEG_QUALITY, 90]) Traceback (most recent …

Total answers: 1

Convert RGBA PNG to RGB with PIL

Convert RGBA PNG to RGB with PIL Question: I’m using PIL to convert a transparent PNG image uploaded with Django to a JPG file. The output looks broken. Source file Code Image.open(object.logo.path).save(‘/tmp/output.jpg’, ‘JPEG’) or Image.open(object.logo.path).convert(‘RGB’).save(‘/tmp/output.png’) Result Both ways, the resulting image looks like this: Is there a way to fix this? I’d like to have …

Total answers: 7

Python Image Library fails with message "decoder JPEG not available" – PIL

Python Image Library fails with message "decoder JPEG not available" – PIL Question: PIL does support JPEG in my system. Whenever I do an upload, my code is failing with: File “PIL/Image.py”, line 375, in _getdecoder raise IOError(“decoder %s not available” % decoder_name) IOError: decoder jpeg not available How can I resolve this? Asked By: …

Total answers: 15

Determining JPG quality in Python (PIL)

Determining JPG quality in Python (PIL) Question: I am playing around with PIL library in Python and I am wondering how do I determine quality of given JPG image. I try to open JPG image do something to it and save it again in the its original quality. Image.save let me determine the desired quality: …

Total answers: 6

Converting a PDF to a series of images with Python

Converting a PDF to a series of images with Python Question: 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 …

Total answers: 5