Created
July 9, 2013 00:09
-
-
Save JamoCA/5953579 to your computer and use it in GitHub Desktop.
This is a ColdFusion 10-only UDF that will identify whether a JPEG image is a CMYK or not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- isImageCMYK() v1 (7/6/2013) | |
UDF for ColdFusion 10 by James Moberg | |
Identifies whether a JPEG image uses a CMYK (CUSTOM) palette | |
---> | |
<CFSET ImageFile = expandPath("cmyk.jpg")> | |
<CFSET ImageObject = ImageRead(ImageFile)> | |
<CFOUTPUT> | |
File = #isImageCMYK(Imagefile)#<br> | |
File = #isImageCMYK(ImageObject )#<br> | |
</CFOUTPUT> | |
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment