in reply to Re: ChatGPT's solution (was: Re: Create email tracking image)
in thread Create email tracking image
Your first example works and makes sense to me because the transparent method is called with an allocated color and this causes it to return the index of the transparent color: 0 instead of -1.
You second example works but since the transparent method is not called transparent continues to return -1 which according to the doc means transparency is disabled, so how is it transparent?
The answer from gpt looks like it should work like your first example works: the allocated alpha "color" of 127 (transparent) is passed to the transparent method, but instead of returning 0 or -1 or something else, the transparent method now returns 2130706432 which is... two gigabytes?
Output:#!/usr/bin/perl use strict; use warnings; use GD; # First working example my $image = GD::Image->new(1, 1); my $transparent = $image->colorAllocate(0, 0, 0); warn $image->transparent; $image->transparent($transparent); warn $image->transparent; # Second working example $image = GD::Image->newTrueColor(1, 1); $image->alphaBlending(0); $image->saveAlpha(1); $transparent = $image->colorAllocateAlpha(0, 0, 0, 127); warn $image->transparent; $image->setPixel(0, 0, $transparent); warn $image->transparent; # Broken ChatGPT example $image = GD::Image->newTrueColor(1, 1); $image->alphaBlending(0); $image->saveAlpha(1); $transparent = $image->colorAllocateAlpha(0, 0, 0, 127); warn $image->transparent; $image->transparent($transparent); warn $image->transparent;
-1 at line 9. 0 at line 11. -1 at line 18. -1 at line 20. -1 at line 27. 2130706432 at line 29.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: ChatGPT's solution (was: Re: Create email tracking image)
by Anonymous Monk on Mar 23, 2023 at 23:30 UTC |