Reputation: 21
Hi I am having trouble finding any info on how to list images by pixel width or height with Image Magick. what I want to do is filter out images that are less than a specified size of pixel width or height. This is done through a perl script and any help is appreciated.
Upvotes: 2
Views: 972
Reputation: 9016
Based on some code I use for other stuff:
use strict;
use warnings;
use Image::Magick;
use Win32::Autoglob;
my $max_cols = 640;
my $max_rows = 480;
IMAGE:
for my $image_name (@ARGV) {
my $image = Image::Magick->new;
my $result = $image->Read($image_name);
die "Failed to read $image_name - $result" if $result;
my ($cols, $rows) = $image->Get('columns', 'rows');
next IMAGE if $cols > $max_cols;
next IMAGE if $rows > $max_rows;
# your processing here...
}
Upvotes: 3
Reputation: 2017
Install the PerlMagick perl module from http://www.imagemagick.org/script/perl-magick.php
Use code similar to the Example Script examples from that web page to read each image.
Query the number of rows and columns in each image using
$image->Get('rows')
and
$image->Get('columns')
and skip images that are too small.
Upvotes: 0
Reputation: 677
Use identify
utility from ImageMagick to obtain width and height.
Upvotes: 0