determine image information on image stored in MySQL BLOB

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kristofl

    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 = @imagecreatefro mstring($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 imagecreatefrom string is not supported in gd2 and I tried several
    thinks. None of them worked ! :
    -
    $temp = tmpfile();
    list($width, $height, $type, $attr) = getimagesize($t emp);
    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($h andle);
    echo $attr;

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

    Doing this with imagecreatefrom gif($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





  • Randell D.

    #2
    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.s kynet.be...[color=blue]
    > 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 = @imagecreatefro mstring($r["foto"]);
    > return @imagesx($image );
    >
    > where $r["foto"] is the field selected from the db which contains the[/color]
    image.[color=blue]
    >
    > For GIFs however, its getting really on my nerves !!
    > I know imagecreatefrom string is not supported in gd2 and I tried several
    > thinks. None of them worked ! :
    > -
    > $temp = tmpfile();
    > list($width, $height, $type, $attr) = getimagesize($t emp);
    > echo $attr;
    >
    > gives me :Warning: getimagesize: Unable to open 'Resource id #6' for[/color]
    reading[color=blue]
    > -
    > $handle = fopen("/tmp/tmp.dat", "w+");
    > fwrite($handle, $r["foto"]);
    > list($width, $height, $type, $attr) = getimagesize($h andle);
    > echo $attr;
    >
    > gives me : Warning: getimagesize: Unable to open 'Resource id #6' for
    > reading[/color]

    Two things I'd try...

    <?
    $temp = tmpfile();
    $tmpArray = getimagesize($t emp);
    foreach($tmpArr ay 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($h andle);
    echo $attr;
    ?>


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


    Comment

    • kristofl

      #3
      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@pd7tw 2no...[color=blue]
      >
      > "kristofl" <kristof.loots@ skynet.be> wrote in message
      > news:3f7b33b8$0 $31719$ba620e4c @reader1.news.s kynet.be...[color=green]
      > > 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 = @imagecreatefro mstring($r["foto"]);
      > > return @imagesx($image );
      > >
      > > where $r["foto"] is the field selected from the db which contains the[/color]
      > image.[color=green]
      > >
      > > For GIFs however, its getting really on my nerves !!
      > > I know imagecreatefrom string is not supported in gd2 and I tried several
      > > thinks. None of them worked ! :
      > > -
      > > $temp = tmpfile();
      > > list($width, $height, $type, $attr) = getimagesize($t emp);
      > > echo $attr;
      > >
      > > gives me :Warning: getimagesize: Unable to open 'Resource id #6' for[/color]
      > reading[color=green]
      > > -
      > > $handle = fopen("/tmp/tmp.dat", "w+");
      > > fwrite($handle, $r["foto"]);
      > > list($width, $height, $type, $attr) = getimagesize($h andle);
      > > echo $attr;
      > >
      > > gives me : Warning: getimagesize: Unable to open 'Resource id #6' for
      > > reading[/color]
      >
      > Two things I'd try...
      >
      > <?
      > $temp = tmpfile();
      > $tmpArray = getimagesize($t emp);
      > foreach($tmpArr ay as $key=>$value)
      > { print("<br>$key = $value"); }
      > ?>
      >
      > Compare the output for jpegs, gifs, png images for the hell of it and see[/color]
      if[color=blue]
      > 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($h andle);
      > echo $attr;
      > ?>
      >
      >
      > Drop another byte and let us know if either of the above work/fail for
      > you...
      >
      >[/color]

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


      Comment

      Working...