Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on May 07, 2012
@rjray Fixed so that default output now catches errors.
Previously, you would get an "undefined" warning if there was an error in
parsing/sizing the input file.
282245f
@rjray Merge branch 'master' of github.com:rjray/image-size 1d9793c
Showing with 14 additions and 4 deletions.
  1. +14 −4 imgsize
View
18 imgsize
@@ -1,8 +1,8 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
###############################################################################
#
-# This file copyright (c) 2010 by Randy J. Ray, all rights reserved
+# This file copyright (c) 2010-2012 by Randy J. Ray, all rights reserved
#
# Copying and distribution are permitted under the terms of the Artistic
# License 2.0 (http://www.opensource.org/licenses/artistic-license-2.0.php) or
@@ -22,7 +22,7 @@ use Getopt::Std;
use Image::Size qw(:all);
-$VERSION = '1.000';
+$VERSION = '1.001';
$VERSION = eval $VERSION; ## no critic(ProhibitStringyEval)
my $cmd = basename $0;
@@ -38,7 +38,7 @@ if ($opts{h} || (! @ARGV) ||
die "Usage: $cmd [ -r | -a | -f fmt ] file ...\n";
}
-$rtn = \&html_imgsize;
+$rtn = \&return_html;
$opts{a} &&
($rtn = \&return_attr);
$opts{r} &&
@@ -60,6 +60,16 @@ else
exit 0;
+sub return_html
+{
+ my $file = shift;
+
+ my ($width, $height, $err) = imgsize($file);
+
+ return (defined $width) ?
+ qq(width="$width" height="$height") : "error: $err";
+}
+
sub return_attr
{
my $file = shift;

No commit comments for this range

Something went wrong with that request. Please try again.