#!/usr/bin/perl 

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

use strict;
use warnings;
use Image::JPEG::EstimateQuality;

my $q;
if (@ARGV) {
    $q = jpeg_quality($ARGV[0]);
} else {
    my $data = do { local $/; <> };
    $q = jpeg_quality(\$data);
}

print $q, "\n";
