Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. The official ImageMagick docs themselves are still rather opaque to me. For my situation, it is necessary to do this within a python script.

Below is the relevant code snippet.

with Image(filename = HOME + outFileName + ".pdf", resolution = 90) as original:
    original.format = "jpeg"
    original.crop(width=500, height=500, gravity="center")
    original.save(filename = HOME + outFileName + ".jpg")

How can I accurately convert from CMYK to RGB?

UPDATE: Here are links to a sample pdf and its converted output.

Original PDF

Converted to JPG

like image 482
Christopher Perry Avatar asked Oct 13 '15 11:10

Christopher Perry


People also ask

Is it better to convert CMYK to RGB or RGB to CMYK?

How to Convert an RGB File to CMYK. RGB has a wider range, or gamut, of colors compared to CMYK. CMYK prints cannot reproduce all RGB model colors. It is not possible to reproduce all the colors you see on a screen in printed ink, since ink does not emit light.

How do I convert to RGB without Photoshop?

Using GIMP If you are looking for a way to convert RGB to CMYK without photoshop, you can use the GIMP open-source editing tool. Like the online converter, GIMP is a free tool that can change the color space of your file without license purchases.


1 Answers

This script will convert image to RGB and save it in-place if it detects that the image is in CMYK mode:

from PIL import Image
image = Image.open(path_to_image)
if image.mode == 'CMYK':
    image = image.convert('RGB')
like image 111
Temak Avatar answered Sep 21 '22 05:09

Temak