Professional Web Applications Themes

determine image information on image stored in MySQL BLOB - PHP Development

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

  1. #1

    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





    kristofl Guest

  2. #2

    Default Re: determine image information on image stored in MySQL BLOB


    "kristofl" <kristof.lootsskynet.be> wrote in message
    news:3f7b33b8$0$31719$ba620e4creader1.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. Guest

  3. #3

    Default Re: determine image information on image stored in MySQL BLOB


    "Randell D." <you.can.email.me.at.randelld> wrote in message
    news:B_Meb.3498$9l5.1207pd7tw2no...
    >
    > "kristofl" <kristof.lootsskynet.be> wrote in message
    > news:3f7b33b8$0$31719$ba620e4creader1.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?


    kristofl Guest

Similar Threads

  1. how to view a BLOB (image)
    By shahzad in forum Coldfusion Database Access
    Replies: 2
    Last Post: June 21st, 10:39 PM
  2. Image Scale Information
    By Amy_Phifer@adobeforums.com in forum Adobe Indesign Windows
    Replies: 2
    Last Post: August 19th, 01:21 AM
  3. BLOB Image from Interbase in ASP
    By Ray at in forum ASP Components
    Replies: 10
    Last Post: October 24th, 05:16 PM
  4. BLOB Image fron Interbase in ASP....
    By Ray at in forum ASP Database
    Replies: 1
    Last Post: October 23rd, 04:58 PM
  5. how to show image retrieved from BLOB on the web page
    By George lucas in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: July 6th, 01:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139