determine image information on image stored in MySQL BLOB

This is a discussion on determine image information on image stored in MySQL BLOB within the PHP Language forums, part of the PHP Programming Forums category; Hi all, I store images in my DB as BLOB. When I want to place them in an html table, ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-01-2003
kristofl
 
Posts: n/a
Default determine image information on image stored in MySQL BLOB

Hi all,

I store images in my DB as BLOB. When I want to place them in an html
table, I want to determine the width of the image in order to asign the
correct width to the column inside table.
For JPEGs this is working fine, this is my code:

$image = @imagecreatefromstring($r["foto"]);
return @imagesx($image);

where $r["foto"] is the field selected from the db which contains the image.

For GIFs however, its getting really on my nerves !!
I know imagecreatefromstring is not supported in gd2 and I tried several
thinks. None of them worked ! :
-
$temp = tmpfile();
list($width, $height, $type, $attr) = getimagesize($temp);
echo $attr;

gives me :Warning: getimagesize: Unable to open 'Resource id #6' for reading
-
$handle = fopen("/tmp/tmp.dat", "w+");
fwrite($handle, $r["foto"]);
list($width, $height, $type, $attr) = getimagesize($handle);
echo $attr;

gives me : Warning: getimagesize: Unable to open 'Resource id #6' for
reading
-

Doing this with imagecreatefromgif($temp); wont work either !


Can somebody help me out please? by telling me what I'm doing wrong or what
I should do.


Regards,


Kristof





Reply With Quote
  #2 (permalink)  
Old 10-02-2003
Randell D.
 
Posts: n/a
Default Re: determine image information on image stored in MySQL BLOB


"kristofl" <kristof.loots@skynet.be> wrote in message
news:3f7b33b8$0$31719$ba620e4c@reader1.news.skynet .be...
> Hi all,
>
> I store images in my DB as BLOB. When I want to place them in an html
> table, I want to determine the width of the image in order to asign the
> correct width to the column inside table.
> For JPEGs this is working fine, this is my code:
>
> $image = @imagecreatefromstring($r["foto"]);
> return @imagesx($image);
>
> where $r["foto"] is the field selected from the db which contains the

image.
>
> For GIFs however, its getting really on my nerves !!
> I know imagecreatefromstring is not supported in gd2 and I tried several
> thinks. None of them worked ! :
> -
> $temp = tmpfile();
> list($width, $height, $type, $attr) = getimagesize($temp);
> echo $attr;
>
> gives me :Warning: getimagesize: Unable to open 'Resource id #6' for

reading
> -
> $handle = fopen("/tmp/tmp.dat", "w+");
> fwrite($handle, $r["foto"]);
> list($width, $height, $type, $attr) = getimagesize($handle);
> echo $attr;
>
> gives me : Warning: getimagesize: Unable to open 'Resource id #6' for
> reading


Two things I'd try...

<?
$temp = tmpfile();
$tmpArray = getimagesize($temp);
foreach($tmpArray as $key=>$value)
{ print("<br>$key = $value"); }
?>

Compare the output for jpegs, gifs, png images for the hell of it and see if
there is a difference in the output above.


And... just for the hell of it - if the above doesn't work, try and close
after you created the tmp file... thus

<?
$handle = fopen("/tmp/tmp.dat", "w+");
fwrite($handle, $r["foto"]);
fclose($handle); // You don't need fopen for getimagesize to work

list($width, $height, $type, $attr) = getimagesize($handle);
echo $attr;
?>


Drop another byte and let us know if either of the above work/fail for
you...


Reply With Quote
  #3 (permalink)  
Old 10-04-2003
kristofl
 
Posts: n/a
Default Re: determine image information on image stored in MySQL BLOB


"Randell D." <you.can.email.me.at.randelld@yahoo.com> wrote in message
news:B_Meb.3498$9l5.1207@pd7tw2no...
>
> "kristofl" <kristof.loots@skynet.be> wrote in message
> news:3f7b33b8$0$31719$ba620e4c@reader1.news.skynet .be...
> > Hi all,
> >
> > I store images in my DB as BLOB. When I want to place them in an html
> > table, I want to determine the width of the image in order to asign the
> > correct width to the column inside table.
> > For JPEGs this is working fine, this is my code:
> >
> > $image = @imagecreatefromstring($r["foto"]);
> > return @imagesx($image);
> >
> > where $r["foto"] is the field selected from the db which contains the

> image.
> >
> > For GIFs however, its getting really on my nerves !!
> > I know imagecreatefromstring is not supported in gd2 and I tried several
> > thinks. None of them worked ! :
> > -
> > $temp = tmpfile();
> > list($width, $height, $type, $attr) = getimagesize($temp);
> > echo $attr;
> >
> > gives me :Warning: getimagesize: Unable to open 'Resource id #6' for

> reading
> > -
> > $handle = fopen("/tmp/tmp.dat", "w+");
> > fwrite($handle, $r["foto"]);
> > list($width, $height, $type, $attr) = getimagesize($handle);
> > echo $attr;
> >
> > gives me : Warning: getimagesize: Unable to open 'Resource id #6' for
> > reading

>
> Two things I'd try...
>
> <?
> $temp = tmpfile();
> $tmpArray = getimagesize($temp);
> foreach($tmpArray as $key=>$value)
> { print("<br>$key = $value"); }
> ?>
>
> Compare the output for jpegs, gifs, png images for the hell of it and see

if
> there is a difference in the output above.
>
>
> And... just for the hell of it - if the above doesn't work, try and close
> after you created the tmp file... thus
>
> <?
> $handle = fopen("/tmp/tmp.dat", "w+");
> fwrite($handle, $r["foto"]);
> fclose($handle); // You don't need fopen for getimagesize to work
>
> list($width, $height, $type, $attr) = getimagesize($handle);
> echo $attr;
> ?>
>
>
> Drop another byte and let us know if either of the above work/fail for
> you...
>
>


None of the above worked, I'm still trying. Any ideas?


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:13 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0