2

I want to extract small rectangles from an image and then want to convert/roll the small rectanges into cylinders. No animation required. I just want to have the cylinders as images.

I am using Perlmagick as API for ImagemagicK.

Any help/suggestions shall be appreciated.

Brad Gilbert
  • 33,846
  • 11
  • 78
  • 129
Manisha Dugar
  • 189
  • 1
  • 1
  • 5

1 Answers1

1

Assuming you know the x,y coordinates and geometry of the rectangles you're trying to extract;

use Image::Magick;
...
my $image = Image::Magick->new();
my $x = $image->Read($filename);
    die "$x" if "$x";

# 100x100 is the size of the cropped image, the +40+40 are giving the x and y
# offsets (i.e. the upper-left coordinate of the cropped image)  
$image->Crop(geometry=>"100x100+40+40"); 

You'll have to be more specific about cylinders, but if it's what I think it is then check Fred's Cylinderize script. The examples given are ImageMagick command-line arguments so there's a bit of work to convert it to the perl equivalent (or you could call them using Perl's exec() function).

Nicholas McCarthy
  • 346
  • 1
  • 6
  • 15