Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
imagemagick shifting of an image
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
kortec
n00b
n00b


Joined: 20 Dec 2004
Posts: 68

PostPosted: Wed Aug 08, 2007 12:18 am    Post subject: imagemagick shifting of an image Reply with quote

I'm trying to use image magic from the command line (actually through the Image::Magick perl module, but it's more or less the same) to shift an image. Basically, I want to go from an image that looks like this:

http://i29.photobucket.com/albums/c275/kortec/wang_lhs.jpg

To an image that looks like this:

http://i29.photobucket.com/albums/c275/kortec/elephant20skelly20l.jpg

Anyone have some bright ideas? I'm running out.
Back to top
View user's profile Send private message
FishB8
l33t
l33t


Joined: 17 Mar 2003
Posts: 820

PostPosted: Wed Aug 08, 2007 1:04 am    Post subject: Reply with quote

First resize, then add the black border.

Start reading here: http://www.imagemagick.org/Usage/resize/#resize

and here: http://www.imagemagick.org/Usage/crop/#extent
_________________
"...as we enjoy great advantages from the inventions of others, we should be glad of an opportunity to serve others by any invention of ours, and this we should do freely and generously." -Benjamin Franklin
Back to top
View user's profile Send private message
kortec
n00b
n00b


Joined: 20 Dec 2004
Posts: 68

PostPosted: Thu Aug 09, 2007 12:59 am    Post subject: Reply with quote

Got it! Thanks. For posterity, here's the source of the perl script. It's more than a bit hackish, but I'm not real worried about it. =)

Code:

#!/usr/bin/perl -w
use strict;
use Image::Magick;
use File::Basename qw/fileparse/;

die "please pass in the image to splice on cmdline" unless ($ARGV[0] && -e $ARGV[0] && -f $ARGV[0]);
my ($name, $dirs, $suffix) = fileparse($ARGV[0],qr/(\..+)+/);

flex('l', '+0');
flex('r', '+1280');

#sadly, a destructive process
sub flex{
    my($side, $dim) = @_;
    my $img = Image::Magick->new;
    $img->Read("$ARGV[0]");
    $img->Set('mattecolor' => 'black');
    $img->Scale('geometry' => '2560x1024');
    $img->Frame('geometry' => sprintf("%sx0", int((2560-$img->Get('columns')) / 2)));
    $img->Crop('geometry' => sprintf("1280x1024%s+0", $dim));
    $img->Write(sprintf("%s%s_%shs%s", $dirs, $name, $side, $suffix));
    undef($img);
}
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum