in reply to Re^3: How to upload bulk images
in thread How to upload bulk images

I would not recommend using Image::Magick modules and instead just directly using the command line magick tools (eg. convert). We have had difficulty compiling perlmagick and once installed segfaults on some servers. I have found just wrapping convert with the proper parameters a bit more stable and, interestingly, faster.

Replies are listed 'Best First'.
Re^5: How to upload bulk images
by WoodyWeaver (Monk) on Jan 04, 2008 at 21:45 UTC
    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