Reply to Re: jpeg image decompiling

Your name:

Reply:


Posted by Rik Wasmus on 08/30/07 13:44

On Thu, 30 Aug 2007 15:20:12 +0200, William Gill <noreply@example.invali=
d> =

wrote:

> I have found a couple of sites that allow a visitor to upload an image=
=

> and the site returns either the "average color", or a palette of color=
s. =

> Several of them use PHP to accomplish this. I have requested the sour=
ce =

> code, but have not gotten a response (even though one site states =

> "source code available on request"). It is obvious that they read the=
=

> colors of each pixel and them manipulate that data. I would like to =
be =

> able to do something similar.
>
> I'm not very familiar with the PHP image functions, but have been able=
=

> to figure out how to read pixel color on indexed color images, but not=
=

> on jpegs. The best I can do now is convert a jpeg to a 256 indexed =

> color image, and then read pixel color. Unfortunately too much of the=
=

> original data gets lost.
>
> Does anyone know how to determine the color of jpeg pixels, or can you=
=

> point me to a good tutorial on PHP image functions.

<http://nl3.php.net/imagecolorat>

$im =3D imagecreatefromjpeg("/your/image/file");

$pixels =3D array();
for($x =3D 0; $x < imagesx($im); $x++){
for($y =3D 0; $y < imagesy($im);$y++){
$rgb =3D imagecolorat($im, $x, $y);
//either:
$pixels[$x][$y] =3D imagecolorsforindex($im,$rgb);
//or:
$r =3D ($rgb >> 16) & 0xFF;
$g =3D ($rgb >> 8) & 0xFF;
$b =3D $rgb & 0xFF;
$pixels[$x][$y] =3D array($r,$g,$b);
}
}

-- =

Rik Wasmus

My new ISP's newsserver sucks. Anyone recommend a good one? Paying for =

quality is certainly an option.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация