aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Photo.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-02-16 14:49:24 +0000
committerMatthew Somerville <matthew@mysociety.org>2015-02-16 14:49:24 +0000
commit9bbc76b814f2c7798bb008e626d59a788fc81c6e (patch)
treeddc11ceb1b97b368fb3d1b7487e924a1215086ec /perllib/FixMyStreet/App/Controller/Photo.pm
parentb1a719a95a736937f6d5c92bf81d95f0bc999152 (diff)
parent6bc3566f0281f4aede0e11e8ab5e21476bc0b674 (diff)
Merge in installation changes.
Fall back better if a couple of things aren't installed.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Photo.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm
index 09afabecf..d70be50e6 100644
--- a/perllib/FixMyStreet/App/Controller/Photo.pm
+++ b/perllib/FixMyStreet/App/Controller/Photo.pm
@@ -8,6 +8,7 @@ use DateTime::Format::HTTP;
use Digest::SHA qw(sha1_hex);
use File::Path;
use File::Slurp;
+use Image::Size;
use Path::Class;
use if !$ENV{TRAVIS}, 'Image::Magick';
@@ -181,7 +182,11 @@ sub process_photo_upload : Private {
my $photo_blob = eval {
my $filename = $upload->tempname;
my $out = `jhead -se -autorot $filename 2>&1`;
- die _("Please upload a JPEG image only"."\n") if $out =~ /Not JPEG:/;
+ 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';
+ }
+ die _("Please upload a JPEG image only") . "\n" if $out && $out =~ /Not JPEG:/;
my $photo = $upload->slurp;
return $photo;
};