Re: [PHP] GetImageSize Problem
You can get this information from header of this image file. Structure of BMP is here: http://www.dcs.ed.ac.uk/home/mxr/gfx/2d/BMP.txt (found with google.com) M.N. --- [EMAIL PROTECTED] wrote: Hello, I'm PHPer from Korea. I have a problem with GetImageSize function. I wanted to know some information about BMP image. So, I tried to use GetImageSize on PHP 4.0.5 , Linux. But, it didn't work. GetImageSize function returned nothing. Then, I tried it on PHP 4.0.6, Windows2000. Ooops.. I worked.. -.-; I looked the php.net manual, but there's no mention about my problem. Does anyone know how to solve this problem.. ? Do you know @MESSAGE? Powered by 3R Soft, Inc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] GetImageSize() problem...
Eric Knudstrup [EMAIL PROTECTED] schreef in bericht [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am having an issue with 4.0.5 where the following code snippet: $orig = imagecreatefromjpeg($tmp); echo 'orig x: ' . imagesx($orig) . ' orig y: ' . imagesy($orig) . 'br'; $orig_size = getimagesize($tmp); echo orig x: $orig_size[0] orig y: $orig_size[1] br; produces: orig x: 1200 orig y: 1600 orig x: orig y: The test image was produced from my Canon S100 and the Canon image downloading software. I might have the same problem with PHP 4.0.5 (win2k). Some of the images from my Kodak DC-260 digital camera, are not recognized correctly by getimagesize for some reason.. Example: ?php $imagehw = GetImageSize(http://maasdelta.eve-software.com/foto/kinderspelen/P0007811.J PG); print $imagehw . BR; print $imagehw[0] . BR; print $imagehw[1] . BR; print $imagehw[3] . BR; ? IMG SRC=http://maasdelta.eve-software.com/foto/kinderspelen/P0007811.JPG; This image is just a normal JPG (1536x1024) taken directly from my camera. GetImageSize however, thinks it's dimensions are: 51088x38655 ??? This also happens when I access the file from a local drive. Anyone got a clue ? Edwin. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] GetImageSize() problem...
I might have the same problem with PHP 4.0.5 (win2k). Some of the images from my Kodak DC-260 digital camera, are not recognized correctly by getimagesize for some reason.. Example: ?php $imagehw = GetImageSize(http://maasdelta.eve-software.com/foto/kinderspelen/P0007811.J PG); print $imagehw . BR; print $imagehw[0] . BR; print $imagehw[1] . BR; print $imagehw[3] . BR; ? IMG SRC=http://maasdelta.eve-software.com/foto/kinderspelen/P0007811.JPG; This image is just a normal JPG (1536x1024) taken directly from my camera. GetImageSize however, thinks it's dimensions are: 51088x38655 ??? This also happens when I access the file from a local drive. Anyone got a clue ? I had a look at this problem in the plane coming back from Europe yesterday. There is definitely a problem in the code. The php_handle_jpeg() function is not hitting the right markers for some reason. My brain was too oxygen-deprived to see the cause, but I will try to get to it. As a workaround for now I suggest you use the read_exif_data() function instead. Compile using --enable-exif. That will definitely get you the right dimensions along with many other properties. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] GetImageSize() problem...
I think that was the first thing I tried. It might have something to do with the actual image itself. Images created with th PHP/GD routines come up with acceptable results. Thanks, Eric Quoting Dan Lowe [EMAIL PROTECTED]: Previously, Eric Knudstrup said: I am having an issue with 4.0.5 where the following code snippet: $orig = imagecreatefromjpeg($tmp); echo 'orig x: ' . imagesx($orig) . ' orig y: ' . imagesy($orig) . 'br'; $orig_size = getimagesize($tmp); echo orig x: $orig_size[0] orig y: $orig_size[1] br; have you tried this as the last line instead? echo 'orig x: ' . $orig_size[0] . ' orig y: ' . $orig_size[1] . 'br'; -dan produces: orig x: 1200 orig y: 1600 orig x: orig y: The test image was produced from my Canon S100 and the Canon image downloading software. Can anyone help? Thanks, Eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- All good technology should be used to piss off people's parents. -Neil Gaiman -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] GetImageSize problem
Hello! First - some ISP block you from get files from their server by a httpd request (that is what php does... I think!). To be sure if this is set or not, in the other ISP (not the one that the images are) write a simple html like this: htmlheadtitleloading images between servers/title/headbody brbr img src="http://Domain/ImagesDir/ImagesName.gif" /body/html In "http://Domain/ImagesDir/ImagesName.gif" be sure to put the correct domain and location of the image. This should show the image... If not you could have two problems: the link is wrong or the filter is set. Imagine this - I have a web site in an ISP with my domain like: http://www.mydomain.com and all the paths are gting the images from a free server like geocities.com so I don;t expend money on buying large amounts of bandwith for my site... If you think this way you know why they do that. if this works, just use thi path "http://Domain/ImagesDir/ImagesName.gif" in all your scripts for getimagesize... I expect that this helps. Rom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] GetImageSize problem
If you relly don't like the text jumping you can do a little script that can parse the width and height for each image, I mean get this info from the html files... But you will have to pin point each one... The good thing that the script is here... ? # ## GetURLImageSize( $urlpic ) determines the ## dimensions of local/remote URL pictures. ## returns array with ( $width,$height,$type ) ## ## Thanks to: Oyvind Hallsteinsen aka Gosub / ELq - [EMAIL PROTECTED] ## for the original size determining code ## ## PHP Hack by Filipe Laborde-Basto Oct 21/2000 ## FREELY DISTRIBUTABLE -- use at your sole discretion! :) Enjoy. ## (Not to be sold in commercial packages though, keep it free!) ## Feel free to contact me at [EMAIL PROTECTED] (http://www.rezox.com) # define(GIF_SIG, "\x47\x49\x46"); define(JPG_SIG, "\xff\xd8\xff"); define(PNG_SIG, "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"); define(JPG_SOF0, "\xc0"); /* Start Of Frame N */ define(JPG_SOF1, "\xc1"); /* N indicates which compression process */ define(JPG_SOF2, "\xc2"); /* Only SOF0-SOF2 are now in common use */ define(JPG_SOF3, "\xc3"); define(JPG_SOF5, "\xc5"); /* NB: codes C4 and CC are NOT SOF markers */ define(JPG_SOF6, "\xc6"); define(JPG_SOF7, "\xc7"); define(JPG_SOF9, "\xc9"); define(JPG_SOF10, "\xca"); define(JPG_SOF11, "\xcb"); define(JPG_SOF13, "\xcd"); define(JPG_SOF14, "\xce"); define(JPG_SOF15, "\xcf"); define(JPG_EOI, "\xd9"); /* End Of Image (end of datastream) */ define(JPG_SOS, "\xda"); /* Start Of Scan - image data start */ define(RD_BUF, 512); /* amount of data to initially read */ function GetURLImageSize( $urlpic $fd= @fopen($urlpic,"r"); fd){ #read in 1k, enough for GIF,PNG. #continue to read from file, if the JPG chunk exceeds this $imgData = fread( $fd,RD_BUF ); if( substr($imgData,0,3)==GIF_SIG $dim =unpack ("v2dim",substr($imgData,6,4) ); $width=$dim["dim1"]; $height=$dim["dim2"]; $type = 1; } elseif( substr($imgData,0,8)==PNG_SIG $dim =unpack ("N2dim",substr($imgData,16,8) ); $width=$dim["dim1"]; $height=$dim["dim2"]; $type = 3; } elseif( substr($imgData,0,3)==JPG_SIG # JPG CHUNK SCAN $imgPos = 2; $type = 2; $buffer = RD_BUF-2; while($imgPos strlen($imgData)) /* synchronize to the marker 0xFF */ $imgPos=strpos($imgData,0xFF,$imgPos)+1; $marker = $imgData[$imgPos]; do { $marker = ord($imgData[$imgPos++]); } while ($marker == 255); /* find dimensions of block */ switch (chr($marker)) /* Grab width/height from SOF segment (these are acceptable chunk types) */ case JPG_SOF0: case JPG_SOF1: case JPG_SOF2: case JPG_SOF3: case JPG_SOF5: case JPG_SOF6: case JPG_SOF7: case JPG_SOF9: case JPG_SOF10: case JPG_SOF11: case JPG_SOF12: case JPG_SOF13: case JPG_SOF14: case JPG_SOF15: $dim =unpack ("n2dim",substr($imgData,$imgPos+3,4) ); $height=$dim["dim1"]; $width=$dim["dim2"]; break 2; file://found it so exit case JPG_EOI: case JPG_SOS: return FALSE;/* End loop in case we find one of these markers */ default:/* We're not interested in other markers */ $skiplen = (ord($imgData[$imgPos++])8)+ord($imgData[$imgPos++])-2; /* if the skip is more than what we've read in, read more */ $buffer -= $skiplen; if( $buffer512 ){ #if the buffer of data is too low,read more file. $imgData .= fread( $fd,$skiplen+1024 ); $buffer += $skiplen+1024; }; $imgPos += $skiplen; break; }; file://endif check marker type }; file://endif loop through JPG chunks }; file://endif chk for valid file types # got the pic dimensions, close the file fclose ($fd); return array( $width,$height,$type ); } else return array( '','','' ); }; file://endif valid file pointer chk }; // end function ? Rom - Original Message - From: Sue Bailey [EMAIL PROTECTED] To: Romulo Roberto Pereira [EMAIL PROTECTED] Cc: php-general [EMAIL PROTECTED] Sent: Sunday, January 21, 2001 10:35 AM Subject: Re: [PHP] GetImageSize problem Thanks Rom - I can get the pics with an img src tag, which is why I assumed that Get
Re: [PHP] GetImageSize problem
On Sun, Jan 21, 2001 at 03:05:31PM +, Sue Bailey wrote: I have a bunch of images living on one ISP's server which I want to use on another page on another ISP's server, with GetImageSize. I RTFM, and see "The filename needs to be either relative to the current document, or an absolute filesystem path. Thus absolute URL paths will not work." which is absolutely correct - I get an error msg "cannot open file". $DOCUMENT_ROOT is obviously no use to me - does anyone know any way round this? try the latest snapshot of PHP 4 from snaps.php.net. it supports URLs in the getinagesize() function. tc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] GetImageSize problem
On Sun, Jan 21, 2001 at 07:02:07PM +0100, Thies C. Arntzen wrote: On Sun, Jan 21, 2001 at 03:05:31PM +, Sue Bailey wrote: I have a bunch of images living on one ISP's server which I want to use on another page on another ISP's server, with GetImageSize. I RTFM, and see "The filename needs to be either relative to the current document, or an absolute filesystem path. Thus absolute URL paths will not work." which is absolutely correct - I get an error msg "cannot open file". $DOCUMENT_ROOT is obviously no use to me - does anyone know any way round this? try the latest snapshot of PHP 4 from snaps.php.net. it supports URLs in the getinagesize() function. Hi Sue, Thies Arntzen made a typo, it is the getimagesize() function. Look at page 497 and use "string imagefile" in newer versions as URL. -Egon -- http://www.linuxtag.de/ http://php.net/books.php http://www.concert-band.de/ mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]