This code is from an old application, you have to experiment a little with it, it should work but not tested lately.

Note that I used base64 encoding and the data was saved to a BLOB field of subtype text in a Firebird database.

use MIME::Base64; ... #- New Label my $label = $pane->Label( -width => 646, -height => 486 )->pack; #- Default empty image my $jpgimg = $label->Photo( -format => 'jpeg', -file => '', ); $label->configure( -image => $jpgimg ); #- Process image open my $fh, '<', $img_file or die "Can't open file ", $img_file, ": $!"; binmode $fh; my $photo = do { local $/; <$fh> }; close $fh; my $stream = encode_base64($photo) or die $!; #- Load image in Label $label->blank; $label->configure( -format => 'jpeg', -data => $stream ); #- Retrieve value for DB insert my $value = $label->cget( -data );

Regards, Stefan


In reply to Re: Save and Load Data from MySQL DB by stefbv
in thread Save and Load Data from MySQL DB by kean

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.