New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to change image colorspace #110
Comments
I'm trying to add a basic colorspace property to the Image class. See this commit of my colorspace branch: srubin@dd0c2f2 However, when I do this: from wand.image import Image
with Image(filename='in.pdf') as img:
print img.colorspace # CMYK
img.format = 'png'
img.colorspace = 'sRGB'
print img.colorspace # sRGB
img.save(filename='out3.png') I'm still getting the bad result: I'm not sure why this isn't giving me the same result as
Alas. Still trying to figure it out. |
I also want colorspace feature. However, @srubin 's changes works fine for me. I am looking forward to seeing if the changes can be merged to mainstream. |
I have the same problem. I need to convert PDF file pages to JPGs. But when I use Wand: with Image(filename=pdf_path, resolution=300) as img:
img.type = 'truecolor'
img.colorspace = 'srgb'
img.save(filename=img_path) Everything converts fine, but resulting image does not like the same as image, converted with How I can convert PDF to series of JPG with Wand like with "convert" and -colorspase option? |
A colorspace attribute have been implemented but it is basically getting and setting the value without applying any transformation from the previous colorspace to the new one. The transformation is done though the C function MagickTransformImageColorspace. To not break backwards compatibility it would be possible to add a new transformColor(new_colorspace) method to the class Image, but it seems to not follow the the libraries philosophy. |
Thanks @zqsd! I will try |
This is an important issue on our album app. Love to see it merged. |
Would like to know the status of this. |
This bug is not fixed yet. |
For those who need a workaround with the current version or past versions from ctypes import c_void_p, c_int
from wand.api import library
library.MagickTransformImageColorspace.argtypes = [c_void_p, c_int]
...
with WandImage(file = io) as img:
library.MagickTransformImageColorspace(img.wand, 13) where "13" is the idx of the colorspace you are wanting to set (1->rgb, 12->cmyk, 13->srgb) |
@byoungb, can you elaborate on your workaround? I tried: from wand.image import Image
from ctypes import c_void_p, c_int
from wand.api import library
library.MagickTransformImageColorspace.argtypes = [c_void_p, c_int]
img = Image(filename='in.pdf', resolution=300)
library.MagickTransformImageColorspace(img.wand, 13)
img.save(filename='out.png') The output out.png is having the wrong color. |
I just checked my code. And what I had was just this # FOR NON RGB IMAGES
if 'rgb' not in wand.colorspace:
# SET COLORSPACE TO SRGB
library.MagickTransformImageColorspace(wand.wand, 13) And I was only opening and saving JPGs |
Is this not the solution: http://docs.wand-py.org/en/latest/guide/colorspace.html ? |
FYI - Wand v0.4.2 added a |
@brkastner sorry, but can you explain how to use Results of converting PDF into JPGs with Wand:
still not have the same colors as original PDF and with the results of this direct IM command:
|
@applecat AFAIK your direct IM command and This is how I'm using the command currently: with WandImage(file=io) as wand:
if 'rgb' not in wand.colorspace:
wand.transform_colorspace('srgb') which seems to work correctly. Maybe @dahlia or another wand contributor can offer more insight, I'm not actually a developer for this project. |
Reading the post linked by @brkastner I understand that
and not:
If I understand correctly, the convert option |
I am using wand to convert a CMYK PDF to an sRGB png.
Here's a sample CMYK PDF: https://dl.dropboxusercontent.com/u/15672/dndel/in.pdf (sorry, github doesn't allow me to add a pdf directly to an issue).
When I use imagemagick on the command line:
I get:
which is bad. Instead, I have to change the colorspace, so if I do
I get:
which is good.
As far as I can tell, there's no way to set colorspace in Wand.
When I run
I get the same as the first
convert
:It would be nice if Wand supported
colorspace
-- many PDFs and other print documents use CMYK.The text was updated successfully, but these errors were encountered: