我有一些代码,将改变一个图像色彩空间从RGB到GenericCMYK配置文件。我希望能够使用ICC配置文件将图像转换为CMYK色彩空间。在Photoshop中有一种方法可以做到这一点,但是当你在处理100张图像时,这个过程占用了用户太多的时间,我正在尝试创建一个AppleScript液滴来为他们做这件事。
我已经看过NSColorspace的页面,看起来有一种方法可以做到这一点。我只是不知道如何将这个Objective-C转换成ApplescriptObjC。以下是NSColorSpace中对ICC配置文件的两个引用: init?(iccProfileData: Data)初始化并返回给定ICC配置文件的NSColorSpace对象。var iccProfileData:数据?用于创建接收器的ICC配置文件数据。
以下是我在Macscripter.net上感谢沙恩的代码:
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 genericCMYKColorSpace()
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)
set colorSpace to bitmapRep's colorSpaceName() as text
(jpegData's writeToURL:theOutput atomically:true)我只需要弄清楚如何将ICC配置文件作为CMYK转换过程的一部分,我相信在这行代码中:
set targetSpace to current application's NSColorSpace's genericCMYKColorSpace()有没有人能给我一些指导?
谢谢!
发布于 2019-06-21 05:00:47
您正在查看Swift中的NSColorSpace文档。AppleScriptObjC是Objective-C的桥梁,因此在Objective-C (可以在页眉中设置语言)中查看文档更有意义,您的代码片段将变成
set targetSpace to current application's NSColorSpace's alloc's initWithICCProfileData:iccData其中iccData是您要使用的ICC配置文件数据。
https://stackoverflow.com/questions/56692855
复制相似问题