#!/usr/bin/perl # I need to adjust an image to a minimum size, but without distoring it, # so I basically want to add space evenly around the existing image. # Using Resize is out since that will distort the image, so I gave # "Composite" a shot, use Image::Magick; use strict; use warnings; my $im = Image::Magick->new(); my $bg = Image::Magick->new(size => "200x400"); my $rc = $bg->Read("xc:white"); $rc = $im->Read($ARGV[0]); die $rc if $rc; $rc = $im->Resize("200x400"); warn $rc if $rc; $rc = $bg->Composite(gravity => "Center", image => $im); warn $rc if $rc; $rc = $bg->Write("$ARGV[0]-resized.png"); die $rc if $rc;