aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Model/PhotoSet.pm
diff options
context:
space:
mode:
authorM Somerville <matthew-github@dracos.co.uk>2020-11-13 14:24:54 +0000
committerM Somerville <matthew-github@dracos.co.uk>2020-11-16 02:39:36 +0000
commit628de40b877974eb553e0910753f2d4cd983d9de (patch)
treed74f5f8ad318db3feade0ea5b1bb852a4c3c7256 /perllib/FixMyStreet/App/Model/PhotoSet.pm
parent831332e4916aab75027bf794f5a1abb8d6f0b0dd (diff)
Add GitHub Actions.
We now have Image::Magick, so make sure that is handled better.
Diffstat (limited to 'perllib/FixMyStreet/App/Model/PhotoSet.pm')
-rw-r--r--perllib/FixMyStreet/App/Model/PhotoSet.pm31
1 files changed, 18 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/App/Model/PhotoSet.pm b/perllib/FixMyStreet/App/Model/PhotoSet.pm
index 76a287e71..85e457856 100644
--- a/perllib/FixMyStreet/App/Model/PhotoSet.pm
+++ b/perllib/FixMyStreet/App/Model/PhotoSet.pm
@@ -8,6 +8,7 @@ use Scalar::Util 'openhandle', 'blessed';
use Image::Size;
use IPC::Cmd qw(can_run);
use IPC::Open3;
+use Try::Tiny;
use FixMyStreet;
use FixMyStreet::ImageMagick;
@@ -149,7 +150,9 @@ has ids => ( # Arrayref of $fileid tuples (always, so post upload/raw data proc
}
# we have an image we can use - save it to storage
- $photo_blob = FixMyStreet::ImageMagick->new(blob => $photo_blob)->shrink('2048x2048')->as_blob;
+ $photo_blob = try {
+ FixMyStreet::ImageMagick->new(blob => $photo_blob)->shrink('2048x2048')->as_blob;
+ } catch { $photo_blob };
return $self->storage->store_photo($photo_blob);
}
@@ -201,18 +204,20 @@ sub get_image_data {
}
my $im = FixMyStreet::ImageMagick->new(blob => $image->{data});
- my $photo;
- if ( $size eq 'tn' ) {
- $photo = $im->shrink('x100');
- } elsif ( $size eq 'fp' ) {
- $photo = $im->crop;
- } elsif ( $size eq 'og' ) {
- $photo = $im->crop('1200x630');
- } elsif ( $size eq 'full' ) {
- $photo = $im
- } else {
- $photo = $im->shrink($args{default} || '250x250');
- }
+ my $photo = try {
+ if ( $size eq 'tn' ) {
+ $im->shrink('x100');
+ } elsif ( $size eq 'fp' ) {
+ $im->crop;
+ } elsif ( $size eq 'og' ) {
+ $im->crop('1200x630');
+ } elsif ( $size eq 'full' ) {
+ $im
+ } else {
+ $im->shrink($args{default} || '250x250');
+ }
+ };
+ return unless $photo;
return {
data => $photo->as_blob,