[Israel.pm] creating an image

Shlomi Fish shlomif at iglu.org.il
Tue Jun 8 06:09:41 PDT 2004


On Tuesday 08 June 2004 15:25, Shlomi Bakish wrote:
> Hi
>
> I need to write a scipt in perl tk that takes some ascii data and plots
> it as a graphic image.
> Suppose I do that - how can I save this output as a file image (jpg, gif
> etc..) ?

Well, you have several options:

1. Plot the data to the screen using TK's mechanisms and separately use 
ImageMagick or GD to create a bitmap image out of it.

2. Plot the data to the screen using TK's mechanisms and separately generate a 
vector graphics file, like SVG or EPS. SVG can be converted to an image using 
the rsvg library and command line client and EPS can be converted to an image 
using ghostscript. You should also be able to find some mecahnisms to convert 
SVGs to EPSes. (GNOME's Sodipodi can do that, at least for SVGs it can 
understand.)

There's a Perl Tk example that demonstrates this. (it's even for an 
interactive plot)

3. Use some charting or plotting module from CPAN (GD::Graph, one of the 
gnuplot modules, SVG::TT::Graph, etc.) I never used any of them.

> (Eventualy it would have to be processed without a display - just input
> of ascii file and output of  image file)
>

In this case, you just have to make sure you can generate the data using one 
of the modules. Note that some GUI toolkits (notably Qt and Win32) allow you 
to write to a printer (or an EPS file) with the same primitives you write to 
the screen. I don't know if Tk supports this.

Regards,

	Shlomi Fish

-- 

---------------------------------------------------------------------
Shlomi Fish      shlomif at iglu.org.il
Homepage:        http://shlomif.il.eu.org/

Quidquid latine dictum sit, altum viditur.
        [Whatever is said in Latin sounds profound.]



More information about the Perl mailing list