pythonmagick

How to make transparent background white instead of black when converting PDF to JPG using PythonMagick

给你一囗甜甜゛ 提交于 2019-12-22 18:00:03
问题 I'm trying to convert from PDF to JPG using PythonMagick, but I can't find a way to set the background color, which by default is changed from transparent to black. I can get the desired result using os.system and the -flatten parameter as shown below. import os os.system('convert -flatten -background \#ffffff -density 400 -adaptive-resize 1900x infile.pdf outfile.jpg') However, PythonMagick does not seem to have a flatten method and the following snippet produces an image with a black

How to handle multi-page images in PythonMagick?

烂漫一生 提交于 2019-12-21 04:39:34
问题 I want to convert some multi-pages .tif or .pdf files to individual .png images. From command line (using ImageMagick) I just do: convert multi_page.pdf file_out.png And I get all the pages as individual images (file_out-0.png, file_out-1.png, ...) I would like to handle this file conversion within Python, unfortunately PIL cannot read .pdf files, so I want to use PythonMagick. I tried: import PythonMagick im = PythonMagick.Image('multi_page.pdf') im.write("file_out%d.png") or just im.write(

PythonMagick can't find my pdf files

久未见 提交于 2019-12-17 15:38:53
问题 I've downloaded and installed PythonMagick for python 2.7, 64 bit Windows 7, from the Unofficial Windows Binaries. I am trying to run this code (Processor.py) import PythonMagick pdf = 'test.pdf' p = PythonMagick.Image() p.density('600') p.read(pdf) p.write('doc.jpg') within this folder (D:\Python Projects\Sheet Music Reader) However, using that relative pdf path or pdf = "D:\\Python Projects\\Sheet Music Reader" results in this error; Traceback (most recent call last): File "D:/Python

Error Installing PythonMagick Under OSX Lion

ぃ、小莉子 提交于 2019-12-13 04:23:39
问题 Has anyone here on StackOverflow been able to get PythonMagick successfully installed on a Mac computer running Lion? I've downloaded the PythonMagick source and installed all of the dependencies specified. However, when I run "./configure", "make" and "make install" it exits with an "error 1". Any help would be greatly appreciated. thank you, L. 回答1: To answer your question: yes, people have been able to get PythonMagick to work. You'll need to include more information about the error for us

Installing PythonMagick with boost on osx

元气小坏坏 提交于 2019-12-12 04:39:19
问题 I am trying to install PythonMagick following these instructions. https://gist.github.com/tomekwojcik/2778301 When I get to $ make I get this error Making all in pythonmagick_src CXX libpymagick_la-_DrawableFillRule.lo _DrawableFillRule.cpp:3:10: fatal error: 'boost/python.hpp' file not found #include <boost/python.hpp> ^ 1 error generated. make[1]: *** [libpymagick_la-_DrawableFillRule.lo] Error 1 make: *** [all-recursive] Error 1 How do I get PythonMagick installed in my project? Any way

Problems detecting PythonMagick after install Mac OSX

你。 提交于 2019-12-11 14:08:31
问题 I followed the instructions at https://gist.github.com/2778301 but when I try to do import PythonMagick I get the error message: Traceback (most recent call last): File "<string>", line 1, in <module> File "PythonMagick/__init__.py", line 1, in <module> from . import _PythonMagick ImportError: cannot import name _PythonMagick The PythonMagick.so is in my python2.7 site-packages. EDIT: I solved this problem by copying from where make install installed PythonMagick /usr/local/lib/python2.7/site

How to compose with center gravity in PythonMagick

十年热恋 提交于 2019-12-11 05:14:46
问题 I did appreciate the answer by Orbling on .composite(): flattened.composite(img, 0, 0, PythonMagick.CompositeOperator.SrcOverCompositeOp) This is the form where the second image is placed to the (0, 0) coordinates of the original image. I tried, but I could not find how the image could be centered to the original. The internal __doc__ says (formatted manually): composite( (Image)arg1, (Image)arg2, (GravityType)arg3 [, (CompositeOperator)arg4]) -> None : C++ signature : void composite(class

With Python`s PIL, how to set DPI before loading an image?

ぃ、小莉子 提交于 2019-12-07 10:08:58
问题 I was trying to use PIL to open an (Illustrator) .eps-file, do some changes and save it. I want to set the document to 300 dpi, and color mode to cmyk before opening, creating or interpreting the object. First I tried the same with PythonMagick and it worked like this: import PythonMagick # That's NOT what I want img72 = PythonMagick.Image() img_file = 'epstest.eps' img.read(img_file) img_dens = img72.density() print 'W: %d, H: %d' % (img.size().width(), img.size().height()) # W: 403, H: 2475

How to make transparent background white instead of black when converting PDF to JPG using PythonMagick

别来无恙 提交于 2019-12-06 11:48:06
I'm trying to convert from PDF to JPG using PythonMagick, but I can't find a way to set the background color, which by default is changed from transparent to black. I can get the desired result using os.system and the -flatten parameter as shown below. import os os.system('convert -flatten -background \#ffffff -density 400 -adaptive-resize 1900x infile.pdf outfile.jpg') However, PythonMagick does not seem to have a flatten method and the following snippet produces an image with a black background. import PythonMagick import os img = PythonMagick.Image("infile.pdf") img.backgroundColor('#ffffff

With Python`s PIL, how to set DPI before loading an image?

冷暖自知 提交于 2019-12-05 15:35:21
I was trying to use PIL to open an (Illustrator) .eps-file, do some changes and save it. I want to set the document to 300 dpi, and color mode to cmyk before opening, creating or interpreting the object. First I tried the same with PythonMagick and it worked like this: import PythonMagick # That's NOT what I want img72 = PythonMagick.Image() img_file = 'epstest.eps' img.read(img_file) img_dens = img72.density() print 'W: %d, H: %d' % (img.size().width(), img.size().height()) # W: 403, H: 2475 <-- See here print 'Density Width: %r' % img_dens.width() # 72 print 'Density Height: %r' % img_dens