Skip to content

Instantly share code, notes, and snippets.

@shofel
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shofel/c26475675d394c257c5d to your computer and use it in GitHub Desktop.
Save shofel/c26475675d394c257c5d to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
# convert millimeters to pixels
use feature 'say';
# take params
my (@mm,$dpi,$px);
($dpi, @mm) = @ARGV;
die "usage: $0 dpi mm[ mm]\n" unless ($mm[0]*$dpi);
# give answer
say "dpi: $dpi";
say "mm: @mm";
say 'px: ', map {sprintf '%.2f ', $dpi / 25.4 * $_} @mm;
__END__
./mm2px.pl 300 34 46
dpi: 300
mm: 34 46
px: 401.57 543.31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment