I try to combine two CMYK based images into one image. The first image serves as background, the 2nd image as overlay. However, from the second image I only want to use pixels that have a certain pre-defined colour.
image1.jpg JPEG 7121x1434 7121x1434+0+0 8-bit CMYK 918KB 0.000u 0:00.000
image2.eps EPT 6008x298 6008x298+0+0 16-bit ColorSeparation CMYK 7.162MB 0.000u 0:00.000
from image2 I only want to use pixels with CMYK colour 60 30 20 80 for the overlay.
the images should be center aligned (-gravity center)
How can this be accomplished using imagemagick?
Copy a certain CMYK color from one image to another image
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Copy a certain CMYK color from one image to another image
I think you want to composite the second image over the first, but only after making other colours transparent, like this:
The icc-color numbers are in the range 0.0 to 1.0. I'm not sure how you would specify 60 30 20 80 which I assume are out of 255.
Code: Select all
magick in1.jpg ( in2.jpg -alpha set -fuzz 0.5% +transparent icc-color(cmyk,0,0,0,0) ) -composite out.jpg
snibgo's IM pages: im.snibgo.com
Re: Copy a certain CMYK color from one image to another image
I'm also unsure about the icc-colours & CMYK relation.
The second image has only two colours, CMYK 60 30 20 80 and white. Maybe this information helps solving the problem.
What I used sofar was:
But the colours CMYK of output.jpg seem to be slightly different from the image2.jpg, probably because it is the result of a pixel multiplication process of both images.
The second image has only two colours, CMYK 60 30 20 80 and white. Maybe this information helps solving the problem.
What I used sofar was:
Code: Select all
composite -compose multiply image2.eps -gravity center image1.jpg output.jpg
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Copy a certain CMYK color from one image to another image
What version of IM, on what platform?
I suggest you don't use the "composite" command. Instead, use "convert" in v6 or "magick" in v7, with a "-composite" option.
Why are you multiplying pixels?
I suggest you don't use the "composite" command. Instead, use "convert" in v6 or "magick" in v7, with a "-composite" option.
Why are you multiplying pixels?
snibgo's IM pages: im.snibgo.com
Re: Copy a certain CMYK color from one image to another image
I'm using
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
on
Ubuntu 18.10 LTS
I multiplied the pixels because optically it came close to what I was looking for. Image2 has only two colours white and CMYK 60 30 20 80 (which comes close to black)
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
on
Ubuntu 18.10 LTS
I multiplied the pixels because optically it came close to what I was looking for. Image2 has only two colours white and CMYK 60 30 20 80 (which comes close to black)
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Copy a certain CMYK color from one image to another image
If image2 has only white and some other colour, and you don't want the white copied, then...
I write to tiff instead of jpg because tiff is by default lossless.
Code: Select all
convert in1.jpg ( in2.eps -alpha set -transparent icc-color(cmyk,0,0,0,0) ) -composite out.tiff
snibgo's IM pages: im.snibgo.com
Re: Copy a certain CMYK color from one image to another image
This command does the trick for me, everything in image 2 that is white (cmyk,0,0,0,0) is made transparant before using image2 as an overlay on top of image1:
Thank you for all your support!
PS:
Finding 1) I also found out that imagemagick reports the CMYK colours on a scale from 0 to 255. The CMYK colour I was using (60 30 20 80) translated to image magicks definition of CMYK as cmyk,153,76,51,204
To determine the colour of a certain pixel I used the following command:
convert image2.tiff -format '%[pixel:p{1,149}]' info:-;echo
with the following result: cmyk(153,76,51,204), the same pixel is reported in Photoshop as CMYK 60,30,20,80.
Finding 2) However converting the command like this (making everything transparant that has not the pre-defined cmyk colour) didn't work for some reason.
Code: Select all
convert image1.jpg -gravity center \( image2.eps -alpha set -transparent icc-color\(cmyk,0,0,0,0\) \) -composite output.tiff
PS:
Finding 1) I also found out that imagemagick reports the CMYK colours on a scale from 0 to 255. The CMYK colour I was using (60 30 20 80) translated to image magicks definition of CMYK as cmyk,153,76,51,204
To determine the colour of a certain pixel I used the following command:
convert image2.tiff -format '%[pixel:p{1,149}]' info:-;echo
with the following result: cmyk(153,76,51,204), the same pixel is reported in Photoshop as CMYK 60,30,20,80.
Finding 2) However converting the command like this (making everything transparant that has not the pre-defined cmyk colour) didn't work for some reason.
Code: Select all
convert image1.jpg -gravity center \( image2.eps -alpha set +transparent icc-color\(cmyk,153,76,51,204\) \) -composite output.tiff