Tuesday, November 19, 2019

#1 2013-01-24 10:16:35 am

ame
Member
Registered: 2011-06-28
Posts: 178

Incorrect Color conversion with SIPS

Hi,

I need to convert CMYK with embedded profiles (example Uncoated Forgra 29) to "web" sRGB.

using sips and -M with perceptual "should" bypass the BCP (Black Point Compensation) problem. Sips don't have BCP like Photoshop.

If I do In Photoshop using convert to profile, Apple CMM, Perceptual and no Black Point Compensation, the RGB conversion is OK.

Same approach with sips washed out the image.

Seems that rendering intent is sips is bugged.

Anyone as a workaround for this?

Maybe ASOC to read the images and with Cocoa command convert the to sRGB with profile conversion?

Ame


Filed under: conversion, rgb, SIPS, cmyk

Offline

 

#2 2013-01-24 11:17:58 am

McUsrII
Member
Registered: 2012-11-21
Posts: 3046
Website

Re: Incorrect Color conversion with SIPS

Maybe it can be done with Image Magick?
It's commandline tools for image manipulation that can be downloaded from Macports.org.

By the way, there is no need for X11 to use Gimp anymore.


Filed under: Image Magick

Offline

 

#3 2013-01-24 11:23:59 am

ame
Member
Registered: 2011-06-28
Posts: 178

Re: Incorrect Color conversion with SIPS

Using ImageMagick works with some tricks that are in contrast to what they say in the manual.
But you have, before, to extract the icc profile from image.
And -profile command need to be used two time CMYK->CMYK>RGB vene if the documentation say to don't do this.

I posted the question here:

http://www.imagemagick.org/discourse-se … =1&t=22665

Ame

Offline

 

#4 2013-01-24 04:05:27 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6034

Re: Incorrect Color conversion with SIPS

ame wrote:

Maybe ASOC to read the images and with Cocoa command convert the to sRGB with profile conversion?


Does this help?

Applescript:

set theInput to POSIX path of (choose file with prompt "Choose CMYK file")
set theOutput to POSIX path of (choose file name default name "Untitled.tif")
set theImage to current application's NSImage's alloc()'s initWithContentsOfFile_(theInput)
set imageRep to theImage's representations()'s objectAtIndex_(0)
set targetSpace to current application's NSColorSpace's sRGBColorSpace()
set newImage to imageRep's bitmapImageRepByConvertingToColorSpace_renderingIntent_(targetSpace, current application's NSColorRenderingIntentPerceptual)
set tiffData to newImage's TIFFRepresentation()
tiffData's writeToFile_atomically_(theOutput, true)

Or doing it with ASObjC Runner:

Applescript:

script convertImage
   set {theInput, theOutput} to current application's NSApp's passedValue() as list
   set theImage to current application's NSImage's alloc()'s initWithContentsOfFile_(theInput)
   set imageRep to theImage's representations()'s objectAtIndex_(0)
   set targetSpace to current application's NSColorSpace's sRGBColorSpace()
   set newImage to imageRep's bitmapImageRepByConvertingToColorSpace_renderingIntent_(targetSpace, current application's NSColorRenderingIntentPerceptual)
   set tiffData to newImage's TIFFRepresentation()
   set theResult to tiffData's writeToFile_atomically_(theOutput, true)
   return theResult
end script

set theInput to POSIX path of (choose file with prompt "Choose CMYK file")
set theOutput to POSIX path of (choose file name default name "Untitled.tif")
tell application id "au.com.myriad-com.ASObjC-Runner" -- ASObjC Runner.app
   -- success will return true
   set theResult to run the script {convertImage} passing {theInput, theOutput} with response
end tell

Edited to fix code as per message below.

Last edited by Shane Stanley (2013-01-28 04:33:38 pm)


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#5 2013-01-28 04:21:27 am

ame
Member
Registered: 2011-06-28
Posts: 178

Re: Incorrect Color conversion with SIPS

Hi Shane,

thanks for the code. When I create a Asoc app and run it I receive this error:

cmyk-rgb[673:403] *** -[AppDelegate converti:]: -[NSImage bitmapImageRepByConvertingToColorSpace:renderingIntent:]: unrecognized selector sent to instance 0x1006f7740 (error -10000)

I tried with both CMYK .jpg and .tif files as input.

I put all the code in a handler called converti_(sender) connected to a simple button just to try.

Ame

Offline

 

#6 2013-01-28 05:03:26 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6034

Re: Incorrect Color conversion with SIPS

Sorry -- when I translated from Objective-C I left a line out. The relevant code should be:


Applescript:

set theImage to current application's NSImage's alloc()'s initWithContentsOfFile_(theInput)
set imageRep to theImage's representations()'s objectAtIndex_(0)
set targetSpace to current application's NSColorSpace's sRGBColorSpace()
set newImage to imageRep's bitmapImageRepByConvertingToColorSpace_renderingIntent_(targetSpace, current application's NSColorRenderingIntentPerceptual)
set tiffData to newImage's TIFFRepresentation()
tiffData's writeToFile_atomically_(theOutput, true)


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#7 2013-01-28 05:15:19 am

ame
Member
Registered: 2011-06-28
Posts: 178

Re: Incorrect Color conversion with SIPS

Hi Shane it workssssss ;-))))))

Many many thanks.

Offline

 

#8 2019-06-19 01:00:36 pm

chrisndeca
Member
From:: Oakland, CA
Registered: 2005-06-28
Posts: 23

Re: Incorrect Color conversion with SIPS

Sorry for resurrecting an old topic, but I am wondering what the JPEG equivalent to TIFFRepresentation might be? I tried JPEGRepresentation, jpegRepresentation, NSJPEGRepresentation, NSjpegRepresentation, and they all give me an error of "Unrecognized Selector".

Bonus question, is there an ApplescriptObjC way of reading the chosen files current color space or should I just use Image Events for that?

Thanks!

Offline

 

#9 2019-06-20 05:44:01 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6034

Re: Incorrect Color conversion with SIPS

chrisndeca wrote:

Sorry for resurrecting an old topic, but I am wondering what the JPEG equivalent to TIFFRepresentation might be? I tried JPEGRepresentation, jpegRepresentation, NSJPEGRepresentation, NSjpegRepresentation, and they all give me an error of "Unrecognized Selector".



Today you'd re-write it like this:

Applescript:

use AppleScript version "2.4" -- 10.11 or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

set theInput to (choose file with prompt "Choose CMYK file")
set theOutput to (choose file name default name "Untitled.jpg")
set theImage to current application's NSImage's alloc()'s initWithContentsOfURL:theInput
set imageRep to theImage's representations()'s objectAtIndex:0
set targetSpace to current application's NSColorSpace's sRGBColorSpace()
set bitmapRep to imageRep's bitmapImageRepByConvertingToColorSpace:targetSpace renderingIntent:(current application's NSColorRenderingIntentPerceptual)
set theProps to current application's NSDictionary's dictionaryWithObjects:{1.0, true} forKeys:{current application's NSImageCompressionFactor, current application's NSImageProgressive}
set jpegData to bitmapRep's representationUsingType:(current application's NSJPEGFileType) |properties|:theProps
jpegData's writeToURL:theOutput atomically:true

Bonus question, is there an ApplescriptObjC way of reading the chosen files current color space or should I just use Image Events for that?



Use the relevant part above to get bitmap image rep, and then:

Applescript:

bitmapRep's colorSpaceName() as text


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#10 2019-06-20 12:47:07 pm

chrisndeca
Member
From:: Oakland, CA
Registered: 2005-06-28
Posts: 23

Re: Incorrect Color conversion with SIPS

Use the relevant part above to get bitmap image rep, and then:

Open this Scriplet in your Editor:

Applescript:

bitmapRep's colorSpaceName() as text



So when I add the line above in my script at the bottom before the final "writeToURL" like this:

Applescript:

set colorSpace to bitmapRep's colorSpaceName() as text

The script always comes back with "NSDeviceCMYKColorSpace" no matter if the image is RGB or CMYK.

Am I doing something wrong?

And thank you Shane for that code, that was terrific of you!

Offline

 

#11 2019-06-20 05:54:15 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6034

Re: Incorrect Color conversion with SIPS

It's returning NSCalibratedRGBColorSpace here.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)