wand

Compositing two images with python wand

一个人想着一个人 提交于 2019-12-10 04:10:15
问题 I need to use python wand (image-magick bindings for python) to create a composite image, but I'm having some trouble figuring out how to do anything other than simply copy pasting the foreground image into the background image. What I want is, given I have two images like: and both jpegs, I want to remove the white background of the cat and then paste it on the room. Answers for other python image modules, like PIL, are also fine, I just need something to automatize the composition process.

How to optimize image size using wand in python

纵然是瞬间 提交于 2019-12-09 12:14:34
问题 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 = pimage.resize((scaled_width, scaled_height), PImage.ANTIALIAS) bytes_buffer = io.BytesIO() resized_pimage.save(bytes_buffer, format="PNG", optimize=True) However, I'm not sure what the equivalent option for Wand is: with default_storage.open(filename,

Constant error using ImageMagick with Python in Windows

本小妞迷上赌 提交于 2019-12-08 10:43:53
问题 I'd like to ask if someone has ever dealt with the same type of error with different files . My friend and I did a code to convert PDF files to JPG images, but quite often it gives an error like: "wand.exceptions.CorruptImageError: unable to read image data C:/Users/ACERES~1/AppData/Local/Temp/magick-1364LojCg7PrnIwH1' @ error/pnm.c/ReadPNMImage/1344 Exception TypeError: TypeError("object of type 'NoneType' has no len()",) in <bound method Image.__del__ of <wand.image.Image: (empty)>> ignored

Changing colour of an image

我的未来我决定 提交于 2019-12-08 03:41:46
问题 What is the easiest way to change the colour of the whole image with a RGB value? I have tried wand , however the documentation didn't make much sense to me, and I can only find changing the intensity of the colours in the Pillow documentation. I tried multiple solutions online, however either they didn't do what I wanted, or were out of date and didn't work. I want it so that the whole image gets tinted and I can control the tint by changing the RGB colour, bit like this: http://cdn

imagemagick wand save pdf pages as images

不羁的心 提交于 2019-12-07 15:46:41
问题 I would like to use imagemagick Wand package to convert all pages of a pdf file into a single image file. I am having the following trouble though (see comments below which highlight problem) import tempfile from wand.image import Image with file('my_pdf_with_5_pages.png') as f: image = Image(file=f, format='png') save_using_filename(image) save_using_file(image) def save_using_filename(image): with tempfile.NamedTemporaryFile() as temp: # this saves all pages, but a file for each page (so 3

Changing colour of an image

我怕爱的太早我们不能终老 提交于 2019-12-06 16:29:24
What is the easiest way to change the colour of the whole image with a RGB value? I have tried wand , however the documentation didn't make much sense to me, and I can only find changing the intensity of the colours in the Pillow documentation. I tried multiple solutions online, however either they didn't do what I wanted, or were out of date and didn't work. I want it so that the whole image gets tinted and I can control the tint by changing the RGB colour, bit like this: http://cdn.makeuseof.com/wp-content/uploads/2012/11/Folder-Colorizer-Color-Manager.jpg?69fac7 I can implement the wheel

Replace a color using Wand

我的梦境 提交于 2019-12-06 14:49:00
I'm trying to replace a color in an image with another color, by defining the coordinates of one of its pixels. But when I run the code the result is exactly the same as the original. here's the original image: here's the code: from wand.image import Image from wand.display import display from wand.drawing import Drawing from wand.color import Color with Drawing() as draw: draw.fill_color = Color('#ff0000') draw.color(192,84,'replace') with Image(filename='rgb.jpg') as img: img.save(filename='rgr.jpg') display(img) 192,84 is somewhere around the middle of the blue section of the image. Which

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

旧城冷巷雨未停 提交于 2019-12-06 09:35:16
问题 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 data I appreciate every solution. 回答1: This worked for me: img_buffer = numpy.asarray(bytearray(wand_img.make_blob(format='png')), dtype='uint8') bytesio = io.BytesIO(img_buffer) pil_img = PIL.Image.open(bytesio) 来源: https://stackoverflow.com/questions/52536843

imagemagick wand save pdf pages as images

痴心易碎 提交于 2019-12-05 19:25:50
I would like to use imagemagick Wand package to convert all pages of a pdf file into a single image file. I am having the following trouble though (see comments below which highlight problem) import tempfile from wand.image import Image with file('my_pdf_with_5_pages.png') as f: image = Image(file=f, format='png') save_using_filename(image) save_using_file(image) def save_using_filename(image): with tempfile.NamedTemporaryFile() as temp: # this saves all pages, but a file for each page (so 3 files) image.save(filename=temp.name) def save_using_file(image): with tempfile.NamedTemporaryFile() as

How to create high res JPEG with Wand from binary string

左心房为你撑大大i 提交于 2019-12-05 12:18:44
I'm trying to convert some PDFs to high res jpegs using imagemagick . I'm working on win 10, 64 with python 3.62 - 64 bit and wand 0.4.4. At the command line I have : $ /e/ImageMagick-6.9.9-Q16-HDRI/convert.exe -density 400 myfile.pdf -scale 2000x1000 test3.jpg. which is working well for me. In python: from wand.image import Image file_path = os.path.dirname(os.path.abspath(__file__))+os.sep+"myfile.pdf" with Image(filename=file_path, resolution=400) as image: image.save() image_jpeg = image.convert('jpeg') Which is giving me low res JPEGs . How do I translate this into my wand code to do the