Re: Can PHP read an image file?

From: CountScubula (me_at_scantek.hotmail.com)
Date: 01/21/04


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
>
>


Relevant Pages

  • Re: Get RAW Bitmap Data from a file
    ... The code I used and presented in the original post was from the MS ... Robotic Lib SDK and does compile OK.. ... The various bits of code are tests I am trying to do to get PIXEL ... DATA in the right format and the right data from the BMP file. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: viewing photos at 100%
    ... But you can change that default to any of several behaviors in the General:Display Content page of the preferences. ... By default, Preview scales down a picture like that to the biggest size that will fit the screen, and View at Actual Size will expand it to a 1:1 pixel ratio. ... Some pictures seem to be tagged so that GC opens them at a small size, ...
    (comp.sys.mac.apps)
  • Re: Recover data from a bitmap and filling a matrix
    ... utility,i can't read correctly data bytes from a .bmp file to insert them in ... depth and so 3 bytes per pixel. ... with the single pixel value of the bitmap. ...
    (microsoft.public.dotnet.languages.vb)
  • Recover data from a bitmap and filling a matrix
    ... After i've tried to update a vb 6.0 project to vb.net, using visual studio utility,i can't read correctly data bytes from a .bmp file to insert them in a matrix to operate on. ... an image of 622*277 pixel has a matrix of 1868*277 bytes considering 24 bit depth and so 3 bytes per pixel. ... With Get function the bidimensional array,the matrix, was filled correctly, as visible using debugger, with the single pixel value of the bitmap. ...
    (microsoft.public.dotnet.general)
  • Recover data from a bitmap and filling a matrix
    ... After i've tried to update a vb 6.0 project to vb.net, using visual studio utility,i can't read correctly data bytes from a .bmp file to insert them in a matrix to operate on. ... an image of 622*277 pixel has a matrix of 1868*277 bytes considering 24 bit depth and so 3 bytes per pixel. ... With Get function the bidimensional array,the matrix, was filled correctly, as visible using debugger, with the single pixel value of the bitmap. ...
    (microsoft.public.dotnet.languages.vb)

Loading