Actually, I would recommend using Image::Magick modules.

I would go farther in use of the database, actually. Consider "I get 100s of images every month that needs to be uploaded to the server." The approach seems to be to just toss them in piles on the floor, with "the image path and file name from the DB table". Boo.

I like storing the actual images in a DB. Makes it easier to manipulate, record attributes, etc. For example, in a current project, I'm storing a bunch of process maps. The maps correspond to annotated visio diagrams. We trot them out, tart them up based on state the users have reported, and then let the users get a visual image on how their process is going.

The visio's get converted into PNG's, and dumped into a file directory on someone's local drive. They are then read into the SQL server for general use. Here is the sample code that stores the images into the database:

my $sth = $dbh->prepare("SELECT processID, processCode FROM processLis +t") or die "bad db: ".$dbh->errstr(); $sth->execute or die "worse DB: ".$dbh->errstr(); my $sth2 = $dbh->prepare("UPDATE blobs SET graphic = ? WHERE processID + = ?") or die "ugly DB: ".$dbh->errstr(); while (my $ref = $sth->fetchrow_hashref) { my $processID = $ref->{'processID'}; my $processCode = $ref->{'processCode'}; my @names = glob($processCode . "_*.PNG"); if ($#names != 0) { die "problem with $processCode, got ", join(", ", @names); } my $image = Image::Magick->new; my $rv = $image->Read($names[0]); die $rv if $rv; my $blob = $image->ImageToBlob(); $sth2->execute($blob, $processID) or die "can't store blob for $name +s[0] under processID $processID: $!"; print "Stored blob $names[0] for processID $processID\n"; }
There is a little bit of overhead -- for example, a PNG that is 73,648 bytes on disk comes out to 748880 as the blob, but that shouldn't be too bad. And what we pick up are the native manipulations as part of the SQL operations; accesibility, easy manipulation, annotations, etc.

--woody


In reply to Re^5: How to upload bulk images by WoodyWeaver
in thread How to upload bulk images by Anonymous Monk

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.