aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Photo.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2016-04-27 16:12:52 +0100
committerMatthew Somerville <matthew@mysociety.org>2016-05-03 13:48:56 +0100
commit7cc15b8bcfa2af55757a4b183ac8cfe645ddb1cb (patch)
treeb197d217d3f5606ab9e11d59d4de8b8f3351790f /perllib/FixMyStreet/App/Controller/Photo.pm
parent6b84622fb7d58531baa7943abdcc7620999c34ee (diff)
Switch external jhead call to use IPC::Open3.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Photo.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm
index a2ec7d4c8..ae0be9d8a 100644
--- a/perllib/FixMyStreet/App/Controller/Photo.pm
+++ b/perllib/FixMyStreet/App/Controller/Photo.pm
@@ -9,6 +9,8 @@ use Digest::SHA qw(sha1_hex);
use File::Path;
use File::Slurp;
use Image::Size;
+use IPC::Cmd qw(can_run);
+use IPC::Open3;
use Path::Class;
use if !$ENV{TRAVIS}, 'Image::Magick';
@@ -181,7 +183,13 @@ sub process_photo_upload : Private {
# get the photo into a variable
my $photo_blob = eval {
my $filename = $upload->tempname;
- my $out = `jhead -se -autorot $filename 2>&1`;
+ my $out;
+ if (can_run('jhead')) {
+ my $pid = open3(undef, my $stdout, undef, 'jhead', '-se', '-autorot', $filename);
+ $out = join('', <$stdout>);
+ waitpid($pid, 0);
+ close $stdout;
+ }
unless (defined $out) {
my ($w, $h, $err) = Image::Size::imgsize($filename);
die _("Please upload a JPEG image only") . "\n" if !defined $w || $err ne 'JPG';