imagemagick convert RGB PNG to CMYK PDF - imagemagick

I am trying to create a PDF file using Latex. However, Latex does not handle TIFF or any other image format capable of both transparency and CMYK. The only solution I think I can use is to convert the PNG image to PDF and embed those in the file.
I am somewhat familiar with imagemagick, however, I am having trouble figuring out how to convert a PNG (probably in the RGB/SRGB colour space) to a PDF in the CMYK colour space.
How do I go about doing this conversion so that the colours are correct and the transparency remains?

In Imagemagick, you should use a CMYK type profile to do the conversion:
convert input.png -profile USWebCoatedSWOP.icc output.pdf
Note, however, that Imagemagick will simply put the raster image into a vector PDF shell. It will not vectorize the image.

Related

How can I convert .psd files to jpg,pdf and png (RGB/CMYK) using imagemagick

Can I use multiple variations of the below Imagemagick command to achieve the to convert a psd to png, jpg and pdf with rgb and cmyk settings
convert -colorspace rgb/cmyk original.psd convert.png/jpg/pdf
I am a newbie trying to play with file formats and I also want to convert the output files based on RGB and CMYK.
Any help would be greatly appreciated.

Retaining colour compoent when doing OCR using Image magick - tesseract

My initial input is a colour multi column JPG file. I run image magick on this to create a TIFF file which tesseract 4.0 then performs OCR on to convert the TIFF to a PDF with the text in a searchable form.
Problem with this is because the TIFF output from Imagemagick is monochrome ( which is has to be for tesseract to extract the text correctly ) the final PDF is monochrome with the text highlightable on it. What I am trying to figure out is , is there a way to retain the colour of the original document when Imagemagick converts it to TIFF?
I am running on Ubuntu 14.0
The goal is to start with a coloured JPG image ( book scan but I don't have control over the scan process so always get a JPG ) which has text on it and convert this to a PDF file which looks the same as the JPG but with the text in a searchable/highlightable format.
My imageMagick command to convert the JPG to tiff is
convert -density 300 MyImage.jpg -depth 8 -lat 30x30-5% MyImage.tiff
MyImage.tiff is black and white which works best for Tesseract to to its OCR.
Tesseract command to convert to PDF is
tesseract MyImage.tiff MyImage pdf
But the final PDF will be black and white. What I would want to have is the text overlayed on a colour version of the original JPG.
Tesseract will only give decent results if using a monochrome input tiff file

How to convert a jpg into a 24-bit uncompressed BMP 4.0?

I've tried using image magic but it converts the image into a compressed format and most of the online conversion tools are also doing the same thing.
Is there some way i could achieve this in image magic or anywhere else?
Use the ImageMagick "-compress none" option to prevent compression, and use "-define bmp:format=bmp4" to force BMP4.0:
convert in.jpg -define bmp:format=bmp4 -compress none out.bmp
You can omit defining the bmp4 format because that's the currently the default BMP output format for ImageMagick anyhow.
Add "-alpha on" if you need RGBA instead of RGB pixels.
See the ImageMagick documentation for the -compress and -define options.

imagemagick convert CMYK pdf to RGB jpeg or PNG and preseerve colors

I have a cmyk pdf that I am trying to convert to a RGB jpeg or png file but have the colors stay pretty close to what the CMYK version is (compared to how photoshop does it)
I am trying the following command but the colors change drastically from a red color to almost bright neon red and so on.
Here is the command
convert cmykpdf.pdf +profile icc -profile AdobeRGB1998.icc -colorspace sRGB jpegtesting.jpg
Any ideas? or thoughts on how to do this. I tried saving it as a PNG also and same issue occurs and have tried changing sRGB to just RGB
NOTE: It doesnt necessarily need to be RGB jpeg it can even be CMYK jpeg but i just need it to be displayed in the browser correctly and I know safari does not display cmyk jpegs correctly
My goal is to just display a img in the browser that shows the correct color and correct resolution nothing pixilated
The solution is fairly easy, there's nothing voodoo or special about Photoshop's CMYK to RGB nowadays. Imagemagick uses LCMS color engine, which does its job just fine.
But first you'll need to edit delegates.xml file inside IM's directory. Find the line with delegate decode="ps:cmyk" and insert -dUseCIEColor=false near the end, so it looks like that:
<delegate decode="ps:cmyk" restrain="True" command=""#PSDelegate#" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" -dUseCIEColor=false "-f%s" "-f%s""/>
It's necessary because otherwise Ghostscript (before returning pam image to ImageMagick) will perform CMYK to CMYK convertion (assuming DeviceCMYK to be CIEbased CMYK), and you probably don't want that, as colors will shift considerably.
Then try this command:
convert -density 144 cmyk.pdf -profile USWebCoatedSWOP.icc -resample 72 -profile "sRGB Color Space Profile.icm" -quality 100 out.jpg
Here we take cmyk.pdf (rather, temporary pam image that GS returns to IM), assign CMYK profile (just as you do in Photoshop, when you open a file or do it explicitly - therefore choose profile that describes you input CMYK best), convert it to sRGB profile (because I don't think you want AdobeRGB as color space of images for Internet) and save to jpeg. Reduce quality parameter as needed.
One more trick here is additional manual anti-aliasing -- note intermediate resolution of 144 dpi and final 72 dpi. Because I don't think that Ghostscript's anti-aliasing with -dGraphicsAlphaBits=4 is en par with Photoshop's anti-aliasing.
The result of this command looks exactly the same as converted in Photoshop.
You could try this:
convert -negate -colorspace RGB srcfile.jpg outputfile.jpg
Let me know if it works!
Based on previous answers, I finally managed to keep natural colors from a CMYK pdf to a RGB png simply using:
convert -colorspace sRGB cmyk.pdf rbg.png

Image conversion to Grayscale using ImageMagick is very dark

I converted a bunch of "normal" JPG photos via
convert infile -colorspace Gray outfile
to monochrome. However the result is for all images very dark. Here a sample conversion: original photo and converted monochrome image.
Is there a better way to convert a photo-realistic image with ImageMagick to gray-scale?
The documentation states that when changing the color space, the colors are converted from their original gamma to linear before the conversion. You need to convert them back to an appropriate gamma.
convert infile -colorspace Gray -gamma 2.2 outfile

Resources