note 98153 deleted from book.image by cmb
| From: | cmb@php.net | Date: | Sat, 13 Aug 2016 16:04:43 +0000 |
| Subject: | note 98153 deleted from book.image by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206271@lists.php.net to get a copy of this message | ||
Note Submitter: mac_doggie at hotmail dot com
----
A way to read the color of a pixel:
<?php
$img = imagecreatefrompng("image1.png");
$w = imagesx($img);
$h = imagesy($img);
for($y=0;$y<$h;$y++) {
for($x=0;$x<$w;$x++) {
$rgb = imagecolorat($img, $x, $y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
echo "#".str_repeat("0",2-strlen(dechex($r))).dechex($r).
str_repeat("0",2-strlen(dechex($g))).dechex($g).
str_repeat("0",2-strlen(dechex($b))).dechex($b).",";
}
echo "<br />\r\n";
}
?>
[EDIT BY thiago: merged two notes from same submitter.]