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, ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
"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... |
|
|||
|
"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? |