The first question is why are you trying to compress images? Most formats are already efficiently compressed so there is very little mileage in this*. Anyway if you read the DBI docs and conform to best practice you will use place holders:

When trying to insert long or binary values, placeholders should be used since there are often limits on the maximum size of an INSERT statement and the quote method generally can't cope with binary data.

$sth_q = $dbh->prepare_cached( 'SELECT Image FROM Table1 WHERE Id = ?' + ); $sth_u = $dbh->prepare_cached( 'UPDATE Table1 SET Image = ? WHERE Id = + ?' ); # blah $sth_u->execute( $image, $id );

* The main exception is M$ .BMP files which are not compressed by default. You can compress these very effectively and may well see compression of 95-98%. This only really serves to bring them towards the same size as an equivalent gif or png.....

cheers

tachyon


In reply to Re: Updating binary data through DBI by tachyon
in thread Updating binary data through DBI by EyeOpener

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.