Page 2 of 2

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-06-20T08:00:13-07:00
by fmw42
Test the colorspace and whether there are profiles using string formats (or identify -verbose). See https://imagemagick.org/script/escape.php

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-07-01T05:44:35-07:00
by atf4_solace
Hello Team,

I have below command and input.jpg is CMYK and outputs wants to convert to sRGB output.jpg

Code: Select all

convert input.jpg -profile sRGB.icc output.jpg
Here is the input.jpg
https://solaceinfotech.com/imagic_test/input.jpg

This command is working fine on windows ImageMagick setup
But this command is not working on Linux through PHP exec function through a PHP script

I have sRGB.icc profile file exists in the current directory of the command

I have tried with many ways and command is working but profile transformation from CMYK to sRGB is not happening for Linux only and worked on windows
Can anyone help with why the profile is not converting from CMYK to sRGB though ICC profile exists in the currenct directory?

Help is appreciated
Thank You

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-07-01T05:48:15-07:00
by atf4_solace
Hello Team,

I have below command and input.jpg is CMYK and outputs wants to convert to sRGB output.jpg

Code: Select all

convert input.jpg -profile sRGB.icc output.jpg
Here is the input.jpg
https://solaceinfotech.com/imagic_test/input.jpg

This command is working fine on windows ImageMagick setup
But this command is not working on Linux through PHP exec function through a PHP script

I have sRGB.icc profile file exists in the current directory of the command

I have tried with many ways and command is working but profile transformation from CMYK to sRGB is not happening
Can anyone help with why the profile is not converting from CMYK to sRGB though ICC profile exists in the currenct directory?

Help is Appreciated
Thank You

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-07-01T06:32:02-07:00
by snibgo
atf4_solace wrote:Can anyone help with why the profile is not converting from CMYK to sRGB though ICC profile exists in the current directory?
I suggest you insert debugging commands in your PHP exec. What is your current directory? Does input.jpg exist? Does sRGB.icc exist?

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-07-01T06:58:57-07:00
by atf4_solace
Hello Snibgo,

Thanx for the reply
I suggest you insert debugging commands in your PHP exec.
when debugged like this exec($command,$k1,$k2);
$k1 is empty array and $k2 is 0 so 0 means command is running properly without profile conversion
What is your current directory?
PHP script, sRGB.icc file and output image path all are same
Does input.jpg exist? Does sRGB.icc exist?
Both input.jpg and sRGB.icc exists in the same folder

Below is the ouput after command

Code: Select all

Array
(
)
0
Array
(
    [0] => Image: output.jpg
    [1] =>   Format: JPEG (Joint Photographic Experts Group JFIF format)
    [2] =>   Mime type: image/jpeg
    [3] =>   Class: DirectClass
    [4] =>   Geometry: 500x333+0+0
    [5] =>   Resolution: 180x180
    [6] =>   Print size: 2.77778x1.85
    [7] =>   Units: PixelsPerInch
    [8] =>   Type: ColorSeparation
    [9] =>   Endianess: Undefined
    [10] =>   Colorspace: CMYK
    [11] =>   Depth: 8-bit
    [12] =>   Channel depth:
    [13] =>     cyan: 8-bit
    [14] =>     magenta: 8-bit
    [15] =>     yellow: 8-bit
    [16] =>     black: 8-bit
    [17] =>   Channel statistics:
    [18] =>     Pixels: 166500
    [19] =>     Cyan:
    [20] =>       min: 0 (0)
    [21] =>       max: 255 (1)
    [22] =>       mean: 130.18 (0.510511)
    [23] =>       standard deviation: 46.5642 (0.182605)
    [24] =>       kurtosis: -0.347349
    [25] =>       skewness: -0.435716
    [26] =>       entropy: 0.938603
    [27] =>     Magenta:
    [28] =>       min: 0 (0)
    [29] =>       max: 255 (1)
    [30] =>       mean: 101.229 (0.396975)
    [31] =>       standard deviation: 43.3923 (0.170166)
    [32] =>       kurtosis: -0.3768
    [33] =>       skewness: -0.0739833
    [34] =>       entropy: 0.925246
    [35] =>     Yellow:
    [36] =>       min: 0 (0)
    [37] =>       max: 255 (1)
    [38] =>       mean: 128.231 (0.502865)
    [39] =>       standard deviation: 56.3152 (0.220844)
    [40] =>       kurtosis: -0.581654
    [41] =>       skewness: -0.136699
    [42] =>       entropy: 0.971961
    [43] =>     Black:
    [44] =>       min: 0 (0)
    [45] =>       max: 230 (0.901961)
    [46] =>       mean: 48.9319 (0.19189)
    [47] =>       standard deviation: 58.3469 (0.228811)
    [48] =>       kurtosis: 0.220561
    [49] =>       skewness: 1.19287
    [50] =>       entropy: 0.822194
    [51] =>   Image statistics:
    [52] =>     Overall:
    [53] =>       min: 0 (0)
    [54] =>       max: 255 (1)
    [55] =>       mean: 102.143 (0.40056)
    [56] =>       standard deviation: 51.5434 (0.202131)
    [57] =>       kurtosis: 1.09621
    [58] =>       skewness: -0.121235
    [59] =>       entropy: 0.914501
    [60] =>   Total ink density: 313.725%
    [61] =>   Rendering intent: Perceptual
    [62] =>   Gamma: 0.454545
    [63] =>   Chromaticity:
    [64] =>     red primary: (0.64,0.33)
    [65] =>     green primary: (0.3,0.6)
    [66] =>     blue primary: (0.15,0.06)
    [67] =>     white point: (0.3127,0.329)
    [68] =>   Background color: cmyk(255,255,255,0)
    [69] =>   Border color: cmyk(223,223,223,0)
    [70] =>   Matte color: cmyk(189,189,189,0)
    [71] =>   Transparent color: cmyk(0,0,0,0)
    [72] =>   Interlace: None
    [73] =>   Intensity: Undefined
    [74] =>   Compose: Over
    [75] =>   Page geometry: 500x333+0+0
    [76] =>   Dispose: Undefined
    [77] =>   Iterations: 0
    [78] =>   Compression: JPEG
    [79] =>   Quality: 92
    [80] =>   Orientation: TopLeft
    [81] =>   Properties:
    [82] =>     date:create: 2019-07-01T09:56:39-04:00
    [83] =>     date:modify: 2019-07-01T09:56:39-04:00
    [84] =>     dc:format: image/jpeg
    [85] =>     exif:ApertureValue: 325770/65536
    [86] =>     exif:ColorSpace: -1
    [87] =>     exif:ComponentsConfiguration: 1, 2, 3, 0
    [88] =>     exif:CompressedBitsPerPixel: 3/1
    [89] =>     exif:CustomRendered: 0
    [90] =>     exif:DateTime: 2005:05:14 00:51:18
    [91] =>     exif:DateTimeDigitized: 2004-03-20T14:54:55+02:00
    [92] =>     exif:DateTimeOriginal: 2004-03-20T14:54:55+02:00
    [93] =>     exif:ExifImageLength: 333
    [94] =>     exif:ExifImageWidth: 500
    [95] =>     exif:ExifOffset: 228
    [96] =>     exif:ExifVersion: 0221
    [97] =>     exif:ExposureBiasValue: 0/3
    [98] =>     exif:ExposureMode: 0
    [99] =>     exif:ExposureTime: 1/640
    [100] =>     exif:FileSource: 3
    [101] =>     exif:Fired: False
    [102] =>     exif:Flash: 16
    [103] =>     exif:FlashpixVersion: 0100
    [104] =>     exif:FNumber: 56/10
    [105] =>     exif:FocalLength: 55/1
    [106] =>     exif:FocalPlaneResolutionUnit: 2
    [107] =>     exif:FocalPlaneXResolution: 3072000/892
    [108] =>     exif:FocalPlaneYResolution: 2048000/595
    [109] =>     exif:Function: False
    [110] =>     exif:ISOSpeedRatings: 400
    [111] =>     exif:Make: Canon
    [112] =>     exif:MaxApertureValue: 325770/65536
    [113] =>     exif:MeteringMode: 5
    [114] =>     exif:Mode: 2
    [115] =>     exif:Model: Canon EOS 300D DIGITAL
    [116] =>     exif:NativeDigest: 36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;9FEFDF7113F07DD29E804C0ECD118359
    [117] =>     exif:Orientation: 1
    [118] =>     exif:PixelXDimension: 500
    [119] =>     exif:PixelYDimension: 333
    [120] =>     exif:RedEyeMode: False
    [121] =>     exif:ResolutionUnit: 2
    [122] =>     exif:Return: 0
    [123] =>     exif:SceneCaptureType: 0
    [124] =>     exif:SensingMethod: 2
    [125] =>     exif:ShutterSpeedValue: 610922/65536
    [126] =>     exif:Software: Adobe Photoshop CS2 Windows
    [127] =>     exif:thumbnail:Compression: 6
    [128] =>     exif:thumbnail:JPEGInterchangeFormat: 1062
    [129] =>     exif:thumbnail:JPEGInterchangeFormatLength: 8474
    [130] =>     exif:thumbnail:ResolutionUnit: 2
    [131] =>     exif:thumbnail:XResolution: 180/1
    [132] =>     exif:thumbnail:YResolution: 180/1
    [133] =>     exif:UserComment: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    [134] =>     exif:WhiteBalance: 0
    [135] =>     exif:XResolution: 180/1
    [136] =>     exif:YCbCrPositioning: 1
    [137] =>     exif:YResolution: 180/1
    [138] =>     jpeg:colorspace: 4
    [139] =>     jpeg:sampling-factor: 1x1,1x1,1x1,1x1
    [140] =>     photoshop:ColorMode: 4
    [141] =>     photoshop:ICCProfile: U.S. Web Coated (SWOP) v2
    [142] =>     signature: fb2b5eabcce66fb21924a993316088c9f59ba6a2a5bcaf62ca08fd818aee06f4
    [143] =>     stRef:documentID: uuid:B4378616F6C3D911B37E9CCEB7A92F18
    [144] =>     stRef:instanceID: uuid:E8A977FAF7C3D911B37E9CCEB7A92F18
    [145] =>     tiff:Make: Canon
    [146] =>     tiff:Model: Canon EOS 300D DIGITAL
    [147] =>     tiff:NativeDigest: 256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;D2CA7C3003FED33A024E4350113D1850
    [148] =>     tiff:Orientation: 1
    [149] =>     tiff:ResolutionUnit: 2
    [150] =>     tiff:XResolution: 1800000/10000
    [151] =>     tiff:YCbCrPositioning: 1
    [152] =>     tiff:YResolution: 1800000/10000
    [153] =>     xap:CreateDate: 2005-05-14T00:51:18+03:00
    [154] =>     xap:CreatorTool: Adobe Photoshop CS2 Windows
    [155] =>     xap:MetadataDate: 2005-05-14T00:51:18+03:00
    [156] =>     xap:ModifyDate: 2005-05-14T00:51:18+03:00
    [157] =>     xapMM:DocumentID: uuid:02279014F8C3D911B37E9CCEB7A92F18
    [158] =>     xapMM:InstanceID: uuid:03279014F8C3D911B37E9CCEB7A92F18
    [159] =>   Profiles:
    [160] =>     Profile-8bim: 9984 bytes
    [161] =>     Profile-exif: 9542 bytes
    [162] =>     Profile-icc: 557168 bytes
    [163] =>     Profile-xmp: 16949 bytes
    [164] =>   Artifacts:
    [165] =>     filename: output.jpg
    [166] =>     verbose: true
    [167] =>   Tainted: False
    [168] =>   Filesize: 754KB
    [169] =>   Number pixels: 166K
    [170] =>   Pixels per second: 0B
    [171] =>   User time: 0.020u
    [172] =>   Elapsed time: 0:01.000
    [173] =>   Version: ImageMagick 6.9.3-8 Q16 x86_64 2018-06-20 http://www.imagemagick.org
)
0

Please help what we have missed.

Thank You

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-07-01T07:22:11-07:00
by snibgo
atf4_solace wrote:PHP script, sRGB.icc file and output image path all are same

Both input.jpg and sRGB.icc exists in the same folder
Yes, that is what you say. I suggest you add debugging commands that prove this is correct.

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-07-19T07:19:55-07:00
by atf4_solace
Hello Snibgo,

We are running the below command in Linux shell for applying the sRGB profile.

Input image link is below and is CMYK

https://solaceinfotech.com/imagic_test/input.jpg

Code: Select all

convert input.jpeg -profile sRGB.ICC output.jpg
And below command works fine

Code: Select all

convert input.jpeg  output.jpg
All the three things that are input.jpeg, sRGB.icc and output.jpg are in root and in the same folder but we are getting below error message

convert: delegate library support not built-in `input.jpeg' (LCMS) @ warning/profile.c/ProfileImage/814.

The issue is with -profile sRGB

So could you please help what's is wrong in the command and do we need to set up or add any update on server for ImageMagick setup

Your help is appreciated

Thank You

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-07-19T07:36:13-07:00
by snibgo
atf4_solace wrote:delegate library support not built-in `input.jpeg' (LCMS)
IM is telling you that it doesn't have LCMS, which it needs for "-profile". Confirm this with:

Code: Select all

convert -version
I get:

Code: Select all

Version: ImageMagick 6.9.9-50 Q16 x64 2018-06-02 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr
 lzma openexr pangocairo png ps raw rsvg tiff webp xml zlib
Note that my istallation includes the lcms delegate. What does your "-version" say? I suppose it doesn't include lcms, and you need to rebuild IM with lcms.

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-08-12T06:18:08-07:00
by atf4_solace
Hello Snibgo

Thanks for the above reply which solve the problem with profile conversion of image and we have installed the LCMS delegate and the -profile operator worked fine

We have one more question.

We have one CMYK image which does not have any profile with it and colorspace is CMYK.
So we have first added the profile with -profile operator and then changed the colorspace from CMYK to sRGB with -colorspace settings

So below is the overall command

Code: Select all

convert input.jpeg -profile sRGB.icc -colorpsace sRGB output.jpeg
Input image: https://solaceinfotech.com/imagic_test/input.jpeg

So is this -colorspace setting is necessary? and also is this command correct here? because if we ignore this and just keeps the -profile then image color is disturbed for the images which do not have a profile and are CMYK
So could you please suggest and help

Thank You

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-08-12T07:17:54-07:00
by snibgo
Your command is bad. When an image has no embedded profile, "-profile sRGB.icc" will assign that profile. But if the image is encoded as CMYK, assigning any RGB profile is not a good idea. Instead, you should do one of these three actions:

1. Assign a CMYK profile, then convert to a RGB profile, eg:

Code: Select all

convert input.jpeg -profile USWebUncoated.icc -profile sRGB.icc output.jpeg
2. Use "-colorspace":

Code: Select all

convert input.jpeg -colorspace sRGB output.jpeg
3. If "-colorspace sRGB" does what you want, you might also want to then assign a sRGB profile:

Code: Select all

convert input.jpeg -colorspace sRGB -profile sRGB.icc output.jpeg

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-08-26T05:12:56-07:00
by atf4_solace
Hello Snibgo,

Thanks for the above reply for profile conversion.

We have implemented the first solution out three solutions provided above for conversion of ( COLORSPACE CMYK + NO PROFILE ) image to ( COLORSPACE sRGB+ SRGB Profile ) image.

We have used the below command for this

Code: Select all

convert input.jpeg -profile USWebUncoated.icc -profile sRGB.ICC output.jpeg
The conversion happened fine but we observed that quality is somewhat reduced so how could we keep the quality maintained for this command ??
Is this conversion command reduces quality??

Please suggest and help.

Thank You

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Posted: 2019-08-26T07:57:40-07:00
by snibgo
Are you comparing IM's result to some other conversion from CMYK to RGB? In other words, are the two versions shown on your (RGB) screen? (If your screen isn't sRGB, then use an output profile that is more correct for your screen.)

If so, then your other conversion method from CMYK to sRGB is probably different to IM's. Perhaps the other method uses a different CMYK profile.

RGB images with no profile are assumed to be sRGB. There is no common assumption for CMYK. For example, if your CMYK image came from Japan, the correct profile might be JapanWebCoated.icc.