Re: Can PHP read an image file?
From: CountScubula (me_at_scantek.hotmail.com)
Date: 01/21/04
- Next message: Jochen Buennagel: "Re: Can I use php to talk with a web service ?"
- Previous message: R. Rajesh Jeba Anbiah: "Re: Sound Files in webpages?"
- In reply to: CountScubula: "Re: Can PHP read an image file?"
- Next in thread: Randy Webb: "Re: Can PHP read an image file?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 21 Jan 2004 07:50:49 GMT
Hmm, I do not know if this is the right place to post this, but after I did
that small piece of code for you I tweeked it and did an image 2 text, sorta
lika an ascii art.
check it out:
http://www.gzentools.com/test/img2text.php
the source is here:
http://www-3.gzentools.com/snippetview.php?c=Concepts&v=img2text.php
-- Mike Bradley http://www.gzentools.com -- free online php tools "CountScubula" <me@scantek.hotmail.com> wrote in message news:zMmPb.13934$D9.6222@newssvr25.news.prodigy.com... > "Randy Webb" <hikksnotathome@aol.com> wrote in message > news:xuCdnaXqGpfVbZDdRVn-vA@comcast.com... > > Running Apache2 and PHP 4.3.3 on Windows, is there any way that I can > > have PHP read an image file and out put its color content? > > > > Preferably, I would like for it to read a .bmp file and output a text > > file of the color codes for each pixel of the image. > > I can convert it to a .jpg or a .gif if need be, but I would prefer to > > stay with the .bmp if its possible. > > > > Any help is greatly appreciated. > > -- > > Randy > > Chance Favors The Prepared Mind > > > > Here you go, this one opens up a jpg file and spits out pixel by pixel. > > at the moment, the output is send to screen, you can open a file and dump it > there instead if you wish. > > the output is row by row, and 6 chr hex color > format: > rrggbbrrggbbrrggbb > > <?php > > $imgFile = "icon_ar.jpg"; > > $im = imagecreatefromjpeg($imgFile); > > $imgWidth = imagesx($im); > $imgHeight = imagesy($im); > > > print " File: $imgFile\n"; > print " Width: $imgWidth\n"; > print "Height: $imgHeight\n"; > print "Format: red:green:blue\n"; > print "\n"; > > for ($y=0; $y < $imgHeight; $y++) > { > for ($x=0; $x < $imgWidth; $x++) > { > $ndx = imagecolorat($im,$x,$y); > $aryColors = imagecolorsforindex($im,$ndx); > print substr("0".dechex($aryColors['red']),-2); > print substr("0".dechex($aryColors['green']),-2); > print substr("0".dechex($aryColors['blue']),-2); > } > print "\n"; > } > > > > ?> > > -- > Mike Bradley > http://www.gzentools.com -- free online php tools > >
- Next message: Jochen Buennagel: "Re: Can I use php to talk with a web service ?"
- Previous message: R. Rajesh Jeba Anbiah: "Re: Sound Files in webpages?"
- In reply to: CountScubula: "Re: Can PHP read an image file?"
- Next in thread: Randy Webb: "Re: Can PHP read an image file?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
Loading