imagemagick

String interpolation failing inside os.system call

String interpolation failing inside os.system call Question: Editing to skip to the answer: The problem was that the string I was interpolating had a non-ascii character in it that was invisible to the naked eye. I’m trying to run this ImageMagick Command: convert -verbose -size 732×142 xc:transparent -fill black -stroke black -strokewidth 2 -draw "roundrectangle …

Total answers: 2

what is fastest way to convert pdf to jpg image?

what is fastest way to convert pdf to jpg image? Question: I am trying to convert multiple pdfs (10k +) to jpg images and extract text from them. I am currently using the pdf2image python library but it is rather slow, is there any faster/fastest library than this? from pdf2image import convert_from_bytes images = convert_from_bytes(open(path,"rb").read()) …

Total answers: 3

ImageMagick not authorized to convert PDF to an image

ImageMagick not authorized to convert PDF to an image Question: I have a program, in which I need to convert a PDF to an image using Image Magick. I do that using the subprocess package: cmd = ‘magick convert -density 300 ‘+pdfFile+'[‘+str(rangeTuple[0])+’-‘+str(rangeTuple[1])+’] -depth 8 ‘+’temp.tiff’ #WINDOWS if(os.path.isfile(‘temp.tiff’)): os.remove(‘temp.tiff’) subprocess.call(cmd,shell=True) im = Image.open(‘temp.tiff’) The error I …

Total answers: 4

Trim whitespace using PIL

Trim whitespace using PIL Question: Is there a simple solution to trim whitespace on the image in PIL? ImageMagick has easy support for it in the following way: convert test.jpeg -fuzz 7% -trim test_trimmed.jpeg I found a solution for PIL: from PIL import Image, ImageChops def trim(im, border): bg = Image.new(im.mode, im.size, border) diff = …

Total answers: 4

What is the fastest way to generate image thumbnails in Python?

What is the fastest way to generate image thumbnails in Python? Question: I’m building a photo gallery in Python and want to be able to quickly generate thumbnails for the high resolution images. What’s the fastest way to generate high quality thumbnails for a variety of image sources? Should I be using an external library …

Total answers: 8

How to unit test a Python function that draws PDF graphics?

How to unit test a Python function that draws PDF graphics? Question: I’m writing a CAD application that outputs PDF files using the Cairo graphics library. A lot of the unit testing does not require actually generating the PDF files, such as computing the expected bounding boxes of the objects. However, I want to make …

Total answers: 6

Documents and examples of PythonMagick

Documents and examples of PythonMagick Question: Where can I find the document and examples of PythonMagick? I did a search on Google but no much information was found. Asked By: jack || Source Answers: EDIT: Nothing to see here. Refer to better answer below. It is a bindings to the MagickWand API : http://www.assembla.com/wiki/show/pythonmagickwand So …

Total answers: 6