Jump to content

Image dimensions


Adam W

Recommended Posts

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

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

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

[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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.