Questions tagged [wand]

The ctypes-based simple ImageMagick binding for Python.

Wand is a ctypes-based simple ImageMagick binding library for Python. It works on Python 2.7, 3.2 through 3.9 and PyPy.

Docs

Community

383 questions
9
votes
5 answers

ImageMagick to verify image integrity

I'm using ImageMagick (with Wand in Python) to convert images and to get thumbnails from them. However, I noticed that I need to verify whether a file is an image or not ahead of time. Should I do this with Identify? So I would assume checking the…
Kiarash
  • 7,378
  • 10
  • 44
  • 69
8
votes
1 answer

ImageMagick wand not recognizing pdf image?

I'm trying to use this blog post to convert one pdf to a jpg, however everytime I try to run this simple script I get this exception wand.exceptions.WandError: wand contains no images MagickWand-56' @ error/magick-image.c/MagickWriteImage/13001 from…
BarFooBar
  • 1,086
  • 2
  • 13
  • 32
8
votes
2 answers

How to install python imagemagick at windows 7. I followed these instruction

To install python IMagick binding wand api on windows 64 bit (python 2.6) This is what I did: downloaded and installed ImageMagick-6.5.8-7-Q16-windows-dll.exe downloaded wand module from http://pypi.python.org/pypi/Wand after that i ran python…
python_dev
  • 81
  • 1
  • 1
  • 3
7
votes
4 answers

How to convert a wand image object to numpy array (without OpenCV)?

I am converting pdf files to image using Wand. Then, I do further image processing using ndimage. I would like to directly convert the Wand image into a ndarray... I have seen the answer here, but it use OpenCV. Is this possible without using…
xdze2
  • 3,986
  • 2
  • 12
  • 29
7
votes
0 answers

How to provide image to Tesseract from memory

I'm using Tesseract to do OCR on millions of PDFs, and I'm trying to squeeze out as much performance as I can. My current pipeline uses convert to convert a PDF to PNG files (one per page), and then uses Tesseract on each of those. During…
mlissner
  • 17,359
  • 18
  • 106
  • 169
7
votes
1 answer

How to optimize image size using wand in python

I want to resize and optimize png and jpg image size using wand. With PIL, I'm able to save the same image with about a 3rd of the size if I specify the optimize option. with open(filename, 'rb') as f: pimage = PImage.open(f) resized_pimage…
nlhma
  • 81
  • 1
  • 3
7
votes
2 answers

Convert from CMYK to RGB

I'm having trouble converting a single page pdf (CMYK) to a jpg (RGB). When I use the code below, the colors in the jpg image are garish. I've tried reading through the Wand docs, but haven't found anything to simply replicate the original image.…
Christopher Perry
  • 149
  • 1
  • 2
  • 8
7
votes
1 answer

Python-Wand Sequence Not Clearing From Memory

If I do the following for root, dirs, files in os.walk(myDir): for myFile in files: with Image(filename=myFile) as img: with Image(image=img) as main: print main.sequence[0].width I end up with memory faults using Wand. I'm…
Nertskull
  • 491
  • 6
  • 20
6
votes
8 answers

ImportError: MagickWand shared library not found[windows]

Good morning, After a lot of attemps running from wand.image import Image I get the following error: Traceback (most recent call last): File "C:\Users\XXXXX\PycharmProjects\PDF_convert\venv\lib\site-packages\wand\api.py", line 180, in…
jfqv
  • 83
  • 1
  • 2
  • 6
6
votes
1 answer

How to convert wand image object to open cv image (numpy array)

I have imported wand using the following code from wand.image import Image as WandImage from wand.color import Color with WandImage(filename=source_file, resolution=(RESOLUTION,RESOLUTION)) as img: img.background_color = Color('white') …
c.Parsi
  • 771
  • 2
  • 9
  • 26
6
votes
3 answers

Python Wand converts from PDF to JPG background is incorrect

I found a so wired thing while converting a pdf to jpeg, so i'd like to figure out that maybe this is a small bug. See the converted jpg below, you could find that, the background color are all black. The image is here:…
cendy
  • 81
  • 1
  • 3
6
votes
0 answers

Performance of python subprocess vs Wand?

I'm looking for a compute- and memory- efficient way to use ImageMagick in a Python program to retrieve the dimensions of batches of photos. I first used the current favorite ImageMagick-Python package, Wand. I tried it and it felt slow. So I…
Dean Moses
  • 2,372
  • 2
  • 24
  • 36
6
votes
0 answers

advanced text formatting with wand (magickwand)

While creating images with formatted annotations i have found image magick ability to render html like formatted text (pango http://www.imagemagick.org/Usage/text/#pango ). Further investigation showed that there is no pango functionality…
etk
  • 83
  • 2
5
votes
1 answer

Python WAND convert only first PDF page

I have this piece of code, taking a pdf file as argument and convert it to JPG. My problem is, when the pdf have more than one page wand create image like this : test-0.jpg, test-1.jpg etc.. with Img(filename=args['pdf'] + file, resolution=300) as…
Nathan30
  • 689
  • 2
  • 8
  • 29
5
votes
3 answers

How to convert wand.image.Image to PIL.Image?

I spent whole day on this problem and did not see answer in stack overflow! I tried this but did not work: >> pil_image = Image.frombytes('RGBA', wand_image.size, wand_image.make_blob(format='png'), 'raw') ValueError: not enough image…
MGH
  • 169
  • 4
  • 10
1
2
3
25 26