<HTML ><HEAD ><TITLE >imagecolorat</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Image functions" HREF="ref.image.html"><LINK REL="PREVIOUS" TITLE="imagecolorallocatealpha" HREF="function.imagecolorallocatealpha.html"><LINK REL="NEXT" TITLE="imagecolorclosest" HREF="function.imagecolorclosest.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.imagecolorallocatealpha.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.imagecolorclosest.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.imagecolorat" ></A >imagecolorat</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN34518" ></A ><P > (PHP 3, PHP 4 )</P >imagecolorat -- Get the index of the color of a pixel</DIV ><DIV CLASS="refsect1" ><A NAME="AEN34521" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >imagecolorat</B > ( resource image, int x, int y)<BR ></BR ><P > Returns the index of the color of the pixel at the specified location in the image specified by <TT CLASS="parameter" ><I >image</I ></TT >. </P ><P > If PHP is compiled against GD library 2.0 or higher and the image is a truecolor image, this function returns the RGB value of that pixel as integer. Use bitshifting and masking to access the distinct red, green and blue component values: <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN34538" ></A ><P ><B >Example 1. Access distinct RGB values</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $im = ImageCreateFromPng("rockym.png"); $rgb = ImageColorAt($im, 100, 100); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > See also <A HREF="function.imagecolorset.html" ><B CLASS="function" >imagecolorset()</B ></A > and <A HREF="function.imagecolorsforindex.html" ><B CLASS="function" >imagecolorsforindex()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.imagecolorallocatealpha.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.imagecolorclosest.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >imagecolorallocatealpha</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.image.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >imagecolorclosest</TD ></TR ></TABLE ></DIV ></BODY ></HTML >