Jump to content

get image size and info from BLOB (MySQL) ?


feha

Recommended Posts

I do have stored images in mySQL blob field's.

 

I can display image by using:

function blob2image ($item_id = "03-07-12", $image_mode = "s")
{
//by feha
        $image = '';
	$db = new clsDBcms();
$image = CCDLookUp("Picture_Small", "items", "No=". $db->ToSQL(trim($item_id), ccsText), $db);
  	$db->close();

  	if(strlen($image))
{
//list($width, $height, $type, $attr) = $image; //This part don't work ok ?!

header ("Content-Type: image/jpeg");
echo $image;
}
}

 

Is there any way to get this info ?

Note: list($width, $height, $type, $attr) = getimagesize($image); don't work on this string ...

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/95702-get-image-size-and-info-from-blob-mysql/
Share on other sites

getimagesize only works on files, not raw data. You can use imagecreatefromstring() to recreate the image as a resource, then use functions like imagesx(),imagesy() image_type_to_extension() to get those bits of information. But if you need that information it would make more sense to store it in the database when you first save the image, since that will save you a lot of overhead.

  • 5 months later...

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.