GD::Graph::_read_logo_file and export_format

GD::Graph::_read_logo_file and export_format

am 20.02.2007 21:20:13 von mason.g.zhwiti

I am working with version 1.4308 of GD::Graph and version 2.35 of the
perl GD module on Windows 2003 Server, perl build 5.8.8 (ActivePerl
build 820, specifically).

Previously I was using an older version of GD/GD::Graph on an earlier
version of Perl, and it was working fine.

Now when I am drawing charts, I receive an error at the point in my
code where I GD::Graph is reading in the logo file to display on the
chart. When I added some debugging print statements to GD::Graph, I
discovered the issue is that it (_read_logo_file() in GD::Graph) is
trying to load my logo file using newFromGif, even though the file is
a PNG file. _read_logo_file() determines filetype by calling $self-
>export_format. From what I can tell, export_format() only returns the
possible format(s), not the actual output format of the chart, which
you wouldn't know until the chart is exported as an image (right?). In
addition, I can find no way of telling GD::Graph what format the logo
file is in, or what format I want to export it in, until I export it.

Therefore I think _read_logo_file() needs to determine the image
format in some other way. I modified my copy of GD::Graph so that it
defaults to examining the logo filename itself, and then falls back to
its current method. So rather than:

my $gdimport = 'newFrom' . ucfirst($self->export_format);

I do:

my $gdimport = 'newFrom' . ($self->{logo} =~ /\.(\w+)$/) ?
ucfirst($1) : ucfirst($self->export_format);

Now my code works without any errors, although obviously I'd rather it
work using the stock Graph module.

Am I just missing something or is this a bug?

MGZ

Re: GD::Graph::_read_logo_file and export_format

am 20.02.2007 21:23:24 von mason.g.zhwiti

On Feb 20, 12:20 pm, "Mason G. Zhwiti"
wrote:
> So rather than:
>
> my $gdimport = 'newFrom' . ucfirst($self->export_format);
>
> I do:
>
> my $gdimport = 'newFrom' . ($self->{logo} =~ /\.(\w+)$/) ?
> ucfirst($1) : ucfirst($self->export_format);

Apologies, I copied from memory ... and left out the additional
parenthesis in my code:

my $gdimport = 'newFrom' . (($self->{logo} =~ /\.(\w+)$/) ?
ucfirst($1) : ucfirst($self->export_format));