Adam W Posted June 30, 2007 Share Posted June 30, 2007 I am trying to get the dimensions of an image by using GetImageSize() I am using this code $query = "SELECT data,filetype FROM uploads where id=$id"; $result = MYSQL_QUERY($query); $data = MYSQL_RESULT($result,0,"data"); $type = MYSQL_RESULT($result,0,"filetype"); $size = GetImageSize($data); I dont understand what is wrong but I get this error messsage Warning: getimagesize(): Unable to access ÿØÿá8EExif in /usr/local/psa/home/vhosts/......../Members/upload.php on line 16 Any ideas to help? Thanks Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/ Share on other sites More sharing options...
aim25 Posted June 30, 2007 Share Posted June 30, 2007 Well, first off php is case sensitive, so i don't think MYSQL_QUERY is the same as mysql_query. Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/#findComment-286715 Share on other sites More sharing options...
mkoga Posted June 30, 2007 Share Posted June 30, 2007 make sure that $data contains a correct path to the image. try printing it out to the screen just to check. Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/#findComment-286719 Share on other sites More sharing options...
Adam W Posted June 30, 2007 Author Share Posted June 30, 2007 Thanks Changed to all lower case - no difference If I print $data I get goobbledegook unless I use Header( "Content-type: image/jpeg"); so I geuss $data is not holding the file in a way GetImageSize can interpret it but how do I extract the image file from the MySql database? Thanks Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/#findComment-286727 Share on other sites More sharing options...
chocopi Posted June 30, 2007 Share Posted June 30, 2007 can you post your whole code please Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/#findComment-286730 Share on other sites More sharing options...
Adam W Posted June 30, 2007 Author Share Posted June 30, 2007 Sure <?php require '../config.php'; require '../OpenDb.php'; $query = "SELECT data,filetype FROM uploads where id=$id"; $result = mysql_query($query); $data = mysql_result($result,0,"data"); $type = mysql_result($result,0,"filetype"); //Header( "Content-type: $type"); //echo $data; $size = GetImageSize($data); if($size[0] > $size[1]) { $thumbnail_width = 100; $thumbnail_height = (int)(100 * $size[1] / $size[0]); } else { $thumbnail_width = (int)(100 * $size[0] / $size[1]); $thumbnail_height = 100; } echo "thumbnail_width = $thumbnail_width thumbnail_height = $thumbnail_height"; print "To upload another file <a href=http://www.mikesierra.co.uk/Members/formloader.html> Click Here</a>"; ?> Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/#findComment-286731 Share on other sites More sharing options...
chocopi Posted June 30, 2007 Share Posted June 30, 2007 try putting the image stuff along with the header inside another file and then include it Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/#findComment-286734 Share on other sites More sharing options...
redarrow Posted June 30, 2007 Share Posted June 30, 2007 [code] giv that a go please. <?php Header( "Content-type: $type"); require '../config.php'; require '../OpenDb.php'; $query = "SELECT data,filetype FROM uploads where id='$id'"; $result = mysql_query($query); $data = mysql_result($result,0,"data"); $type = mysql_result($result,0,"filetype"); $size = GetImageSize($data); if($size[0] > $size[1]) { $thumbnail_width = 100; $thumbnail_height = (int)(100 * $size[1] / $size[0]); } else { $thumbnail_width = (int)(100 * $size[0] / $size[1]); $thumbnail_height = 100; } echo "thumbnail_width = $thumbnail_width thumbnail_height = $thumbnail_height"; print "To upload another file <a href=http://www.mikesierra.co.uk/Members/formloader.html> Click Here</a>"; ?> [/code] Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/#findComment-286744 Share on other sites More sharing options...
Adam W Posted June 30, 2007 Author Share Posted June 30, 2007 Still get a similar error message getimagesize(): Unable to access ÿØÿá8EExif in <b>/usr/local/psa/home/vhosts/etc I am sucessfully retrieving a file which is an image file but it seems to be in the wrong format for getimagesize() to read Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/#findComment-286894 Share on other sites More sharing options...
corbin Posted June 30, 2007 Share Posted June 30, 2007 It appears to me that the actual image data is being stored in the database. array getimagesize ( string $filename [, array &$imageinfo] ) Hmmm.... So you either need to find a function that can take the image contents (what you're pulling from your DB) and return the dimensions, or you're going to have to write temp files everytime you want to see the dimensions. Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/#findComment-286898 Share on other sites More sharing options...
Adam W Posted June 30, 2007 Author Share Posted June 30, 2007 I think writing temp files is about the only way I'm going to be able to do this - bit long winded but it should work! Link to comment https://forums.phpfreaks.com/topic/57864-image-dimensions/#findComment-286903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.