in reply to GD::Image trueColor() hangup...

The docs for GD say that GD::Image->trueColor(1) is for backwards compatibility and also that it needs to be done before creating new images.

I have a feeling you'll want to ditch that option altogether and specify what type of new image you want with something like:

my $blank_rgb_image = GD::Image->newTrueColor( $width, $height );

or

my $blank_palette_image = GD::Image->newPalette( $width, $height );
explicitly.

I've never tried to get the package-wide palette/truecolor option to work in new code, since GD.pm has offered specific methods for both for quite a while now.

You'll probably also want to get rid of the indirect object syntax in your code. It my not bite you now, but it's better to get into a habit of using direct syntax and not worry about it. In case you're wondering what that means, change for example:

my $foo = new GD::Image;
to
my $foo = GD::Image-new;
which does not suffer from the type of ambiguous parsing of the former.

Replies are listed 'Best First'.
Re^2: GD::Image trueColor() hangup...
by kalchas (Acolyte) on Mar 26, 2008 at 23:01 UTC
    Hi Mr. M, Thanks for the response... I've gotten rid of the indirect syntax (at least I think I've gotten rid of all of it), which certainly is aesthetically pleasing to me :-). However, I'm still not able to get the script working. I'm all for creating the image without bringing trueColor() into the mix separately. But in order to know the height and width of the image, I need to be able to getbounds() on the source image. The code I've pieced together does this after making $buildable. Is there another way to get the height and width of the original image? Cheers, K.
      I don't see any problem with calling getbounds() where you do. The only problems I see are that you've got '=>' instead of '->' and that there's a space between that and the name of the method.

      IOW, change $buildable=> getbounds() to $buildable->getbounds().

      You might also want to change from  (my $width, my $height) to my ( $width, $height ) on that line. The syntax you're using gets the job done, but it's not the way you'll see most people writing that.