I have a script which contains several links like so:
<img src="cgi-bin/image_serve.cgi?full+124236+pc_img1">
where the arguments change for every link.
'full' is the size of the view, '124236' is the ID (and the primary key in the database) and 'pc_img1' is the location.

The script returns an image, which is then put into the page on the fly. There are multiple different images on the page, all presented by the same program.

My concerns is that calling the 'image_serve.cgi' multiple times from the same page with different arguments is causing some kind of problem. Perhaps it simply takes too long for some of the images and the server times out?

When viewing the page with the multiple calls, some images show up, some do not and show broken link placeholders. This changes at random and will differ each time the script is run. Also, occasionally, all images show up. After the page is done loading, one can right-click and "Show Picture" on the images and they will display, so the data does exist.
The code for my 'image_serve.cgi' is below:

#!/usr/bin/perl BEGIN { $|=1; use CGI::Carp('fatalsToBrowser'); } use CGI qw(:all); use DBI; use DBD::mysql; use Image::Magick; my $database = "###"; my $username = "###"; my $password = "###"; my $hostname = "###"; my $tbl = "listings"; my $query = new CGI; my $location = $ARGV[0]; my $mls_id = $ARGV[1]; my $img = $ARGV[2]; my $dbh = DBI->connect("DBI:mysql:$database:$hostname",$username,$pass +word) or die "Unable to connect to listings Database: $DBI::errstr\n" +; my $sql = "SELECT $img FROM listings WHERE pc_mls_id = $mls_id"; my $sth = $dbh->prepare($sql) or die "Couldn't prepare: $DBI::errstr\n +"; $sth->execute; my $ref = $sth->fetchrow_hashref; my $raw_img_data = $$ref{$img}; $sth->finish; $dbh->disconnect; my $image = Image::Magick->new; open(IMAGE, $raw_img_data); $image->Read(file=>\*IMAGE); close(IMAGE); my ($x,$y); if ($location eq "detailed"){ $x = 250; $y = 226; } if ($location eq "med"){ $x = 150; $y = 113; } if ($location eq "small"){ $x = 75; $y = 57; } $image->Resize(width=>$x,height=>$y); print "Content-type: image/jpeg\n\n"; $image->Write('jpg:-');
Anything glaring I'm missing, or is the problem on the server or client end, and not Perl's problem?
Thanks,
cidaris

In reply to Multiple Script calls by cidaris

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.