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 12 26481
Randy Webb wrote: 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.
Yes, because PHP rocks! =)
The PHP manual has a bunch of info. on this topic. http://www.php.net/image
Regards,
- Dan http://www.dantripp.com/
"Randy Webb" <hi************@aol.com> wrote in message
news:xu********************@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
See my earlier post about a BMP to GD converter. There's code in there that
decodes a BMP file. Instead of packing the bytes into a GD scan line, append
it to a line of text instead. http://groups.google.com/groups?hl=e...fe=off&selm=a1
64f4b5.0311302128.40fb37f4%40posting.google.com
Uzytkownik "Randy Webb" <hi************@aol.com> napisal w wiadomosci
news:xu********************@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
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/snippetvi...v=img2text.php
--
Mike Bradley http://www.gzentools.com -- free online php tools
"CountScubula" <me@scantek.hotmail.com> wrote in message
news:zM*****************@newssvr25.news.prodigy.co m... "Randy Webb" <hi************@aol.com> wrote in message news:xu********************@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
CountScubula wrote: "Randy Webb" <hi************@aol.com> wrote in message news:xu********************@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);
With PHP 4.3.3, it gives me an error on that line.
Call to undefined function: imagecreatefromjpeg()
I am assuming it means I need GD for this to work?
If so, is there an FAQ type directions to installing GD?
--
Randy
Chance Favors The Prepared Mind
Chung Leong wrote: See my earlier post about a BMP to GD converter. There's code in there that decodes a BMP file. Instead of packing the bytes into a GD scan line, append it to a line of text instead.
http://groups.google.com/groups?hl=e...fe=off&selm=a1 64f4b5.0311302128.40fb37f4%40posting.google.com
I had actually found that thread in researching an answer to this, and
assumed I needed GD for it to work, and seem to lack the common sense
required to get GD to work.
--
Randy
Chance Favors The Prepared Mind
"Randy Webb" <hi************@aol.com> wrote in message
news:XN********************@comcast.com... With PHP 4.3.3, it gives me an error on that line. Call to undefined function: imagecreatefromjpeg() I am assuming it means I need GD for this to work? If so, is there an FAQ type directions to installing GD?
-- Randy Chance Favors The Prepared Mind
hmm, talk to your hosting company, this is a simple lib that, in my opionion
should be installed to do anything usefull with images, or get a new hosting
company
--
Mike Bradley http://www.gzentools.com -- free online php tools
CountScubula wrote: "Randy Webb" <hi************@aol.com> wrote in message news:XN********************@comcast.com...
With PHP 4.3.3, it gives me an error on that line. Call to undefined function: imagecreatefromjpeg() I am assuming it means I need GD for this to work? If so, is there an FAQ type directions to installing GD?
hmm, talk to your hosting company, this is a simple lib that, in my opionion should be installed to do anything usefull with images, or get a new hosting company
I am the hosting company. Well, sort of. Its a local copy of Apache and
PHP that I installed to try to learn PHP.
--
Randy
Chance Favors The Prepared Mind
> I am the hosting company. Well, sort of. Its a local copy of Apache and PHP that I installed to try to learn PHP.
-- Randy Chance Favors The Prepared Mind
I take it this is a windows copy?
I have not used this for a long time, I hear if you download the zip, not
the installer, you will have lots-o-.dll's to go with it, just copy the
correct one over to your machine, I think you may have to do something in
the .ini file as well
--
Mike Bradley http://www.gzentools.com -- free online php tools
are you using linux or windows ? maybe i could help you
If you are using linux, you have to install the GD library and recompile php
with GD support.
If you are using windows, and you dl php from php.net, GD is already
configured to work, just fallow the instruction again to see what you have
missing. The library is gd.dll, it's located in the extension directory in
php, it's already configured to work from here.
GD can be found here http://www.boutell.com/gd/
Savut
"CountScubula" <me@scantek.hotmail.com> wrote in message
news:L9*****************@newssvr27.news.prodigy.co m... I am the hosting company. Well, sort of. Its a local copy of Apache and PHP that I installed to try to learn PHP.
-- Randy Chance Favors The Prepared Mind
I take it this is a windows copy?
I have not used this for a long time, I hear if you download the zip, not the installer, you will have lots-o-.dll's to go with it, just copy the correct one over to your machine, I think you may have to do something in the .ini file as well
-- Mike Bradley http://www.gzentools.com -- free online php tools
Randy Webb wrote: Chung Leong wrote:
See my earlier post about a BMP to GD converter. There's code in there that decodes a BMP file. Instead of packing the bytes into a GD scan line, append it to a line of text instead.
http://groups.google.com/groups?hl=e...fe=off&selm=a1
64f4b5.0311302128.40fb37f4%40posting.google.com
I had actually found that thread in researching an answer to this, and assumed I needed GD for it to work, and seem to lack the common sense required to get GD to work.
I have it working now, thank you :)
--
Randy
Chance Favors The Prepared Mind
Savut wrote: are you using linux or windows ? maybe i could help you
If you are using linux, you have to install the GD library and recompile php with GD support.
If you are using windows, and you dl php from php.net, GD is already configured to work, just fallow the instruction again to see what you have missing. The library is gd.dll, it's located in the extension directory in php, it's already configured to work from here.
GD can be found here http://www.boutell.com/gd/
Thanks. A post in another thread "GD on PHP", directed me on how to
enable it, and now is working. And yes, its a Windows (ME) machine.
Without me replying to each and all, thanks to everybody who helped me
with it :)
--
Randy
Chance Favors The Prepared Mind This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Phil Powell |
last post by:
I have a PHP script that would read in a binary file and display it as if it
were <img src>, how would you do that w/o changing the header's MIME type?
The entire file does not need to be changed....
|
by: Thomas |
last post by:
Hi all,
Is there a faster way to read image dimensions other than something
like:
ImageOrig = System.Drawing.Image.FromFile(Filepath);
ImageOrigHeight = ImageOrig.Height;
ImageOrigWidth =...
|
by: Paul Loveless |
last post by:
Hi all, I would like to create a routine that retrieves specific properties
from an image file (ex. a jpeg) without having to open
the file. For example, in WinXP when you right-click a jpg file...
|
by: Daniel Mark |
last post by:
Hello all:
I have following code that works well under command line, but it
doesn't work after I convert it
as exe application.
############### file: testPath.py
import getopt, math, sys,...
|
by: Raghu Raman |
last post by:
Hi
i want to save the read the image file and show it on a image control of
a mobile webform .But the mobile control does not support html images
,so i am forced to use the server image control...
|
by: abumarwah |
last post by:
im new in this area using c++, and i want to write program read image and display it in form of array or matrix
|
by: quickcur |
last post by:
hi can anyone explain me to read image to memory from a url
it is very easy in java but it is hard to find an complete
solution in c/c++.
Thanks,
|
by: amritranjan |
last post by:
This is my Jsp code for image upload in database:
-----------Upload.jsp----------------
<html>
<head>
<title>Account Details </title>
</head>
<body bgproperties="fixed" bgcolor="#CCFFFF">...
|
by: premprakashbhati |
last post by:
hi, good evening..
i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button()
here is the code ...its work fine...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |