writes:
> On Sun, 18 Oct 2009 15:49:48 +0200, Mart van de Wege <> wrote:
>
>>Hi,
>>
>>I'm trying to convert some graphs generated by SVG::TT::Graph to PNG,
>>using Image::Magick. However, I'm getting empty .png files back,
>>instead of PNG images.
>>
>>This is the code I am using:
>>
>>
>>sub output {
>> my $self = shift;
>> my $outdir = $self->{OutDir};
>> die "No output directory set." unless $self->{OutDir};
>> my $tempdir = tempdir;
>> foreach my $graph( keys %{$self->{Graphs}} ) {
>> my $svg = $self->{Graphs}->{$graph};
>> print "converting $graph, using tempdir $tempdir\n";
>> open(my $fh,">","$tempdir/$graph.svg") or die "$!";
> ^^^
> I would try binmode($fh) here.
> And examine the svg file.
>
The SVG files are fine. Note that I don't pass the { CLEANUP => 1 }
option to tempdir, so I can examine the intermediate output.
>> print $fh $svg;
>> close $fh;
>
> Otherwise for a test, starting here, hardcode a
> known svg file and do the conversion to png
> like you did with the script below.
>
>> open(FH,"<","$tempdir/$graph.svg") or die "$!";
>> my $image = Image::Magick->new(magick => 'svg');
> ^^
> sets the object type?
> The one Read file example doesen't set the object type
> when reading from a filehandle, nor does it put it into binmode FH.
> Try what works from the script below, change one thing at a time after
> it starts working.
Actually, I tried it without setting magick. Didn't work either.
However, I'll try and take your suggestions into account and hack on the
script some more, adding some debugging print statements.
Mart
--
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.