How to correct inverted CMYK image
How to correct inverted CMYK image
Hello,
i've extracted the jpg and icc profile from a pdf. The image seems to have inverted colors. How could i correct the image color?
Thanks in advance
Regards
https://www.dropbox.com/s/mbo7z95o1jgb1 ... k.jpg?dl=0
https://www.dropbox.com/s/7ispvjldpfvvb ... k.icc?dl=0
i've extracted the jpg and icc profile from a pdf. The image seems to have inverted colors. How could i correct the image color?
Thanks in advance
Regards
https://www.dropbox.com/s/mbo7z95o1jgb1 ... k.jpg?dl=0
https://www.dropbox.com/s/7ispvjldpfvvb ... k.icc?dl=0
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to correct inverted CMYK image
Your file has no CMYK embedded profile.
Do either of these work for you? I am not sure if your file is corrupted, since these do not work for me
If not, then try
Do either of these work for you? I am not sure if your file is corrupted, since these do not work for me
Code: Select all
convert testcase_cmyk.jpg -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc testcase_rgb.jpg
convert testcase_cmyk.jpg -colorspace sRGB testcase_rgb.jpg
Code: Select all
convert testcase_cmyk.jpg -negate testcase_rgb.jpg
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to correct inverted CMYK image
We could guess at how to undo the damage to this jpg file, but it is probably better to extract it without causing damage.Roman80 wrote:i've extracted the jpg and icc profile from a pdf.
How did you extract it? What commands? Why is there a separate ICC file?
It would help if you could link to the PDF file.
snibgo's IM pages: im.snibgo.com
Re: How to correct inverted CMYK image
It comes from a photoshop PDF document, so the icc was embedded.
If I extract the same from an rgb image/PDF, then it works.
I will try the negate command
Regards
If I extract the same from an rgb image/PDF, then it works.
I will try the negate command
Regards
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to correct inverted CMYK image
If you provide the original PDF document, perhaps we can just convert from that and show you how. Did you really mean PDF and PSD?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to correct inverted CMYK image
But the ICC isn't embedded in the JPEG.Roman80 wrote:... so the icc was embedded.
My point is that you have a JPEG file that is valid but contains wrong data. We might guess what is wrong and how to correct it, but I suspect it can be extracted correctly.
Unless you tell us how you extracted the JPEG and ICC, and ideally link to the PDF, all we can do is guess.
snibgo's IM pages: im.snibgo.com
Re: How to correct inverted CMYK image
I've attached those pdf files. I extracted it with our lightweight pdf parser which reads the required things without transformation according to the pdf 1-7 reference.https://www.google.at/url?sa=t&rct=j&q= ... 12RpbpRRYg
Both files are photoshop PDFs. The RGB version is correct and also the cmyk
data is the raw data from the pdf, in each pdf there are ICC profiles,
the jpg encoded preview and the original 8BIM Photoshop file.
CMYK version
https://www.dropbox.com/s/ulxgk07l2u71l ... k.pdf?dl=0
RGB version
https://www.dropbox.com/s/t64yay3b1b85z ... b.pdf?dl=0
Both files are photoshop PDFs. The RGB version is correct and also the cmyk
data is the raw data from the pdf, in each pdf there are ICC profiles,
the jpg encoded preview and the original 8BIM Photoshop file.
CMYK version
https://www.dropbox.com/s/ulxgk07l2u71l ... k.pdf?dl=0
RGB version
https://www.dropbox.com/s/t64yay3b1b85z ... b.pdf?dl=0
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to correct inverted CMYK image
Your PDF does not show any profiles using
So providing and input cmyk profile and output surge profile, this command works for me to convert to sRGB.
With Imagemagick 7, change convert to magick. If you want a larger pixel dimension image, then add -density before reading the input. For example
Alternately, you might extract the image that is imbedded within the vector pdf. If you can do that and create a cmyk jpg with its embedded profile, then post that.
I tried using pdfimages to extract the image, but it is not a jpg and so is extracted as PPM RGB format without profile. So I added an sRGB profile as follows:
Code: Select all
identify -verbose pdf_cmyk.pdf
Code: Select all
convert pdf_cmyk.pdf -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc test1.jpg
Code: Select all
convert -density 300 pdf_cmyk.pdf -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc test2.jpg
I tried using pdfimages to extract the image, but it is not a jpg and so is extracted as PPM RGB format without profile. So I added an sRGB profile as follows:
Code: Select all
pdfimages pdf_cmyk.pdf ./
convert -000.ppm -profile /Users/fred/images/profiles/sRGB.icc test3.jpg
Re: How to correct inverted CMYK image
What we want is to
1.) extract the image and ICC from the pdf and
2.) convert or modify it afterwards with ImageMagick
Step 1.) is done, the problem is the step 2.).
With an RGB image/pdf it works like a charm.
If I understand it correctly, then there is no way to directly convert the extracted CMYK image with the extracted ICC?
The PDF include an ICC, which is within an compressed stream.
You could read and verify the ICC when you use the header (http://www.color.org/icProfileHeader.h)
You could find the ICC in the PDF in object (9 0 obj).
The image is in object (10 0 obj)
Regards
1.) extract the image and ICC from the pdf and
2.) convert or modify it afterwards with ImageMagick
Step 1.) is done, the problem is the step 2.).
With an RGB image/pdf it works like a charm.
If I understand it correctly, then there is no way to directly convert the extracted CMYK image with the extracted ICC?
The PDF include an ICC, which is within an compressed stream.
You could read and verify the ICC when you use the header (http://www.color.org/icProfileHeader.h)
You could find the ICC in the PDF in object (9 0 obj).
The image is in object (10 0 obj)
Regards
Re: How to correct inverted CMYK image
What i found out is that the embedded jpg image is encoded. So, the question is how I could decode it with ImageMagick?
Here is the description from the PDF reference:
Here is the description from the PDF reference:
RegardsIf the image has three color components, transform RGB values to YUV before encoding and from YUV to RGB after decoding. If the image has four components, transform CMYK values to YUVK before encoding and from YUVK to CMYK after decoding. This option is ignored if the image has one or two color components.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to correct inverted CMYK image
You only need to extract the image with its IC profile. Once you have that, you can change profiles and convert back and forth between CMYK and sRGB. You process of extracting the ICC is corrupting your image. If you can find the ICC profile name from any method, then you know which profile you start with and only need to provide (from an externals source) along with your destination profile, since it does not show to Imagemagick. But you do not need to extract the ICC profile, only find out what it is. Perhaps EXIFTOOL will tell you what profile is associated with the PDF. I have not yet tried that.What we want is to
1.) extract the image and ICC from the pdf and
2.) convert or modify it afterwards with ImageMagick
Re: How to correct inverted CMYK image
What do you exactly mean with ICC profile name?
All I get from the ICC is the following:
https://www.dropbox.com/s/v6b6mp21dtuji ... 9.JPG?dl=0
Regards
All I get from the ICC is the following:
https://www.dropbox.com/s/v6b6mp21dtuji ... 9.JPG?dl=0
Regards
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to correct inverted CMYK image
Pdfimages can extract the CMYK image:
Exiftool finds the ICC profile:
So IM can convert the CMYK tif to whatever we want, such as an sRGB png:
Code: Select all
f:\web\im>pdfimages -all pdf_cmyk.pdf pdfx
f:\web\im>dir pdfx*
Volume in drive F is New Volume
Volume Serial Number is F8C5-053E
Directory of f:\web\im
29/08/2017 08:18 3,149,030 pdfx-000.tif
1 File(s) 3,149,030 bytes
0 Dir(s) 54,198,243,328 bytes free
f:\web\im>%IM%identify pdfx*
pdfx-000.tif TIFF 1024x768 1024x768+0+0 8-bit CMYK 3.149MB 0.000u 0:00.000
Code: Select all
f:\web\im>exiftool pdf_cmyk.pdf | grep Profile
ICC Profile Name : U.S. Web Coated (SWOP) v2
Code: Select all
f:\web\im>%IM%convert pdfx-000.tif -profile USWebCoatedSWOP.icc -profile sRGB.icc out.png
snibgo's IM pages: im.snibgo.com
Re: How to correct inverted CMYK image
This seems to work, but which function did i need to call if I use the API not the ImageMagick binaries?fmw42 wrote: ↑2017-08-28T13:45:27-07:00Code: Select all
convert testcase_cmyk.jpg -negate testcase_rgb.jpg
Thanks to all for your great help
Regards
Roman
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to correct inverted CMYK image
Which API? To do what? To negate? Try looking for a function with "negate" in the name. For example, with the MagickCore API, use the NegateImage() function.Roman80 wrote:This seems to work, but which function did i need to call if I use the API not the ImageMagick binaries?
snibgo's IM pages: im.snibgo.com