The Coldfusion Open Source Forums
Home | ImageCFC | CFFM | BlogCFM | CFMBB | CFOpenMail / ImapCFC | CFOpenChat
Forums | Profile | Inbox | Members | Chat | Search | Login | RSS
Vivio Technologies CFML Hosting
New Topic Reply Subscription Options   Previous Page  Page: 1   Previous Page

Forums: ImageCFC Forum: Grab color info for image pixel
Created on: 11/20/09 {ts '2018-12-15 13:53:00'} Views: 9718 Replies: 3
Grab color info for image pixel
Posted Friday, November 20, 2009 at {ts '2018-12-15 13:53:00'}

Hi Rick,

Just wondering if it's possible to use ImageCFC to examine individual pixels in an image to determine their color information? IE RGB or hex value.

TIA!

RE: Grab color info for image pixel
Posted Wednesday, December 9, 2009 at {ts '2018-12-15 11:48:00'}

ImageCFC doesn't do that, but you could certainly use java image stuff for that.

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/BufferedImage.html#getRGB(int, int)

You could call the getRGB() function of the BufferedImage object

RE: Grab color info for image pixel
Posted Wednesday, December 9, 2009 at {ts '2018-12-15 12:11:00'}

Thanks Rick,

Not being a Java programmer, can you give me a hint as to how I would go about this? Are you already leveraging the BufferedImage object in your CFC? If so, would it make more sense for me to add a method to your image.cfc file, than to put the Java code in my CF page?

Thanks for your reply

Edited 12/09/09 {ts '2018-12-15 12:11:00'}
RE: Grab color info for image pixel
Posted Wednesday, December 9, 2009 at {ts '2018-12-15 12:34:00'}

starkraving2002 wrote:

Thanks Rick,

Not being a Java programmer, can you give me a hint as to how I would go about this? Are you already leveraging the BufferedImage object in your CFC? If so, would it make more sense for me to add a method to your image.cfc file, than to put the Java code in my CF page?

Yes, everything in imageCFC leverages that object.

so you'll want to call the readImage() method in imagecfc, like this:


<cfset imageCFC = createObject("component","image")>
<cfset img1 = imageCFC.readImage("C:\Inetpub\wwwroot\myimage.jpg")>

<cfset xPos = 1>
<cfset yPos = 1>

<cfset rgbVal = img1.getRGB(javacast("int",xPos), javacast("int",yPos))>
<cfdump var="#rgbVal#">

New Topic Reply Subscription Options   Previous Page  Page: 1   Previous Page
Subscription Options
Subscription options are available after you log in.

There are 11 active user sessions right now.