[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Problem with Perl version of GD



Hi all.  I hope that someone on this list might be able to shed some light
on the following problem or bug with the Perl version of GD.

The plan here is to load one GIF, then load a second GIF and overlay it on
top of the first GIF in a specified location, then save the composite image
to disk.  Everything works as desired if this process runs once.

The problem pops up when the process runs twice in a row (see code below)
with different coordinates for the overlay in each sequence.  Both
sequences result in identical output: the one produced by the first
sequence run.  If the sequences are reversed, then the output changes, but
both instances of the output still match one another, although now they
look like the results expected from sequence #2 instead of #1.

Should the first sequence destroy the GIF it created or remove it from
memory somehow?  In the C version of GD there's a command to destroy the
image, but there is not one documented for the Perl version.  I've tried
giving MacPerl and the CGI script that use GD up to 12 megs of RAM, but
this does not change the results.

This problem is very frustrating!  It works great if run once.  Any
constructive suggestions for working around it would be most appreciated!

Software:
  GD version 1.14 (see
http://www-genome.wi.mit.edu/ftp/pub/software/WWW/GD.html)
  MacPerl version 5.1.0r2
  MacOS version 7.5.3
Hardware: Apple PowerMac 7200/90


Best wishes for a prosperous 1997!
-Ken
kps1@cornell.edu

#####################

# Perl code that produces output as described above:

# sequence 1
open (GIF, "background.gif") || die;
$finalimage = newFromGif GD::Image(GIF) || die;
close GIF;

open (GIF, "testicon.gif") || die;
$overlay = newFromGif GD::Image(GIF) || die;
close GIF;

$finalimage->copy($overlay,200,50,0,0,25,23);

open (GIF, ">composite.gif") || die;
print GIF $finalimage->gif;
close GIF;


# sequence 2
open (GIF, "background.gif") || die;
$finalimage2 = newFromGif GD::Image(GIF) || die;
close GIF;

open (GIF, "testicon.gif") || die;
$overlay2 = newFromGif GD::Image(GIF) || die;
close GIF;

$finalimage2->copy($overlay2,50,200,0,0,25,23);

open (GIF, ">composite2.gif") || die;
print GIF $finalimage2->gif;
close GIF;

# both sequences result in a GIF that has the background overlaid by the
testicon,
# but the position of the icon depends on which of these sequences is run
# before the other, with the result being both appear to be generated by the
# one run first

--- message ends ---