Page 1 of 1

Getting rid of white background after rotate

Posted: 2013-11-26T11:48:41-07:00
by DanEspen
I'm trying to take an input file with a shaped image (transparent background) and create a new image showing the original image rotated around the center axis. As this code stands, I only get clear background when the image is rotated an even multiple of 90 degrees.

This is the code I'm using:

Code: Select all

use Image::Magick;
my $image     = Image::Magick->new;
my $new_image = Image::Magick->new;
my ($my_w, $my_h) = $image->Get('columns', 'rows');
my $new_h = $my_h*16;
$new_image->Read("xc:none");	# none=transparent

foreach my $i (0..15) {
    my $rot_image = Image::Magick->new;
#   fixme, need a way to control the background area:
    undef $rot_image;
my $x = $new_image->Write("$ARGV[1]");
warn "Write failed: $x" if "$x";
I've tried setting a background of none in the Composite command, but debug tells me background isn't a valid option.
I tried setting png:OutsideOverlay to false, but got nothing out of that either.

Clearly I need help. I would have included an image, but so far I don't see how to do that.
On request I'll upload the image to a sharing site.

Re: Getting rid of white background after rotate - solved.

Posted: 2013-11-26T19:15:57-07:00
by DanEspen
Looks like I'm going to answer my own question, the answer seem to be to include color=>'none' in the rotate command. Sorry I couldn't figure that out from the documentation. I just started wondering why color was an argument to the rotate command.