Click here to get back home

GD::Graph::_read_logo_file and export_format

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
GD::Graph::_read_logo_file and export_format Mason G. Zhwiti 02-20-2007
Posted by Mason G. Zhwiti on February 20, 2007, 3:20 pm
Please log in for more thread options


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-> =~ /\.(\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


Posted by Mason G. Zhwiti on February 20, 2007, 3:23 pm
Please log in for more thread options


wrote:
> So rather than:
>
> my $gdimport = 'newFrom' . ucfirst($self->export_format);
>
> I do:
>
> my $gdimport = 'newFrom' . ($self-> =~ /\.(\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-> =~ /\.(\w+)$/) ?
ucfirst($1) : ucfirst($self->export_format));


Similar ThreadsPosted
GD::Graph - how to get rid of leading gap in line graph? October 1, 2004, 10:56 am
Graph.0.69 Module---how to get a DAG from graph with cycles January 23, 2006, 2:50 pm
GD::GRAPH two_axes December 8, 2004, 6:01 pm
GD::Graph isn't numeric etc. January 26, 2005, 7:43 pm
GD graph, Several Colors per Bar? May 30, 2005, 6:52 pm
Name for a new Tk Graph module April 4, 2007, 6:17 am
Perl GD::Graph module: bug? August 3, 2004, 8:42 pm
GD::Graph => How to set maximum value manually on Y ? October 6, 2004, 6:35 pm
Do we need Graph::Clique module? November 10, 2004, 2:58 pm
ANNOUNCE: Graph-ReadWrite 2.00 January 2, 2005, 9:17 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap