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
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
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
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
Share on other sites

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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.