CFLib.org – Common Function Library Project

isImageCMYK(image)

Last updated July 08, 2013

author

James Moberg

Version: 1 | Requires: CF10 | Library: UtilityLib

Description:
Pass a file path or image object and it will identify whether the image uses a CUSTOM (CMYK) color palette.

Return Values:
Returns a boolean

Example:

<cfset ImageFile = expandPath("logo.jpg")>
<cfset ImageObject = ImageRead(ImageFile)>
<cfoutput>
fileOb = isImageCMYK(ImageFile)<br>
ob = isImageCMYK(ImageObject)<br>
</cfoutput>

Parameters:

Name Description Required
image Either a path to an image or an image object. Yes

Full UDF Source:

<!---
 Identifies CMYK images.
 
 @param image      Either a path to an image or an image object. (Required)
 @return Returns a boolean 
 @author James Moberg (james@ssmedia.com) 
 @version 1, July 8, 2013 
--->
<cffunction name="isImageCMYK" returntype="boolean" output="false" hint="Returns a true/false indicator regarding if image uses CMYK (CUSTOM) palette.">
    <cfargument name="image" default="" required="true" hint="path w/file or image object" />
    <cfset local.testImage = "">
    <cfset local.isCMYK = 0>
    <cfif IsSimpleValue(arguments.image)>
        <cfif fileExists(arguments.image) and isImageFile(arguments.image)>
            <CFSET local.testImage = imageRead(arguments.image) />
        </cfif>
    <cfelseif isImage(arguments.image)>
        <cfset local.testImage = arguments.image />
    </cfif>
    <cfif isImage(local.testImage)>
        <cfif not val(imageGetBufferedImage(local.testImage).getType())>
            <cfset local.isCMYK = 1 />
        </cfif>
    </cfif>
    <cfreturn local.isCMYK />    
</cffunction>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson