I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2007-06-12 10:43:25-07 by letox
Floating point exception when drawing text on png image
Hi.

I am using Imager for some time now and you do a great job.

I have got a problem now. When I open a png image and try to render text using arial.ttf I get a floating point exception.

I am using Debian sarge with the libfreetype6-dev 2.1.7-6 package and Imager 0.58.

The perl file looks like this:

use Imager; my $img = Imager->new (); $img->read (file => 'scaah_style4i7.png'); my $black = Imager::Color->new (0,0,0,255); my $font = Imager::Font->new (file => 'arial.ttf', color => $black, size => 11, aa => 1); $img->string (color => $black, font => $font, x => 10, y => 10, size => 11, sizew => 11, text => 't +est', aa => 1); $img->write (file => 'test.png');

If you need the image to reproduce the issue you can find it at http://www.lazyturtle.net/scaah_style4i7.png

At the moment I use the following workaround: I remove the alpha channel with convert (preset noalpha). Is there a way to re-apply the alpha channel after rendering the text? I could save it with convert (preset alpha) but I havent found a way to add a one-channel image as a new alpha channel to a three-channel image.

Thanks in advance,
Hendrik
Direct Responses: 5405 | 5442 | Write a response
Posted on 2007-06-12 12:19:42-07 by letox in response to 5403
Re: Floating point exception when drawing text on png image
I tried to pin down the issue and it works when I switch off anti-aliasing in "string" (aa = 0).

Hendrik
Direct Responses: 5407 | 5409 | Write a response
Posted on 2007-06-12 12:51:21-07 by tonyc in response to 5405
Re: Floating point exception when drawing text on png image

I've found the problem, I'm working on a fix for this now.

As a workaround you could draw to a blank 4 channel image and use the rubthrough() method to draw to the target image.

I'll post a link to the diff here when I have a good fix.

I'll release 0.59 in the next couple of days to fix this (and one other bug)

Direct Responses: Write a response
Posted on 2007-06-12 13:21:18-07 by tonyc in response to 5405
Re: Floating point exception when drawing text on png image

The fix

From looking at the code formatting it looked like I had something there at some point, but I must have goofed when editing it.

I was going to include the patch inline too, but the code formatting here is bad.

Direct Responses: Write a response
Posted on 2007-06-14 07:41:30-07 by tonyc in response to 5403
Re: Floating point exception when drawing text on png image

This is fixed in Imager 0.59, which I've just released.

Direct Responses: Write a response