(none) imager-devel
/ help / lists / applications / search /

Background colour of rotated images

From: Andrew Green (
Date: Mon 26 Apr 2004 - 19:07:18 GMT

  • Next message: Tony Cook: "Re: Background colour of rotated images"


    I've just tried out Imager as a replacement for Image::Magick, and I'm
    really impressed. I'm stuck with one (hopefully minor) problem,

    In rotating an image by a couple of degrees, and then writing the
    result out as a JPEG, the extra pixels around the edge of the new,
    rotated image are set to black. I really need to be able to set them
    to a custom background colour, and I'd rather not have to achieve this
    by using a fountain fill.

    Here's a sample of the code I'm using:

        my $orig = Imager->new();
        $orig->open(file => $filename) or die $orig->errstr();
        my $rotated = $comp->rotate(degrees => 2);
        $rotated->write(file => $filename, type => 'jpeg')
                or die $rotated->errstr();

    Would it be possible to set the default background colour of $rotated
    to a named Imager::Color object? If so, how?

    Any advice would be very much appreciated -- particularly since the
    rotation algorithm used by Imager beats the one in Image::Magick into a
    cocked hat.


          article seven       Andrew Green
     automatic internet       11946@xyz.molar.is | www.article7.co.uk