Skip to content

Commit

Permalink
[Brent] Convert uploaded photos to JPEGs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Sep 26, 2023
1 parent 2915d5a commit dfa9170
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion perllib/FixMyStreet/App/Model/PhotoSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,15 @@ has ids => ( # Arrayref of $fileid tuples (always, so post upload/raw data proc
return ();
}

my %params;
# Brent has a quite-small file size limit, make sure we convert to JPEGs
if ($self->c->cobrand->moniker eq 'brent') {
$params{magick} = 'JPEG';
}

# we have an image we can use - save it to storage
$photo_blob = try {
FixMyStreet::ImageMagick->new(blob => $photo_blob)->shrink('2048x2048')->as_blob;
FixMyStreet::ImageMagick->new(blob => $photo_blob)->shrink('2048x2048')->as_blob(%params);
} catch { $photo_blob };
return $self->storage->store_photo($photo_blob);
}
Expand Down
3 changes: 2 additions & 1 deletion perllib/FixMyStreet/ImageMagick.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ sub crop {

sub as_blob {
my $self = shift;
my %params = @_;
return $self->blob unless $self->image;
my @blobs = $self->image->ImageToBlob();
my @blobs = $self->image->ImageToBlob(%params);
$self->_set_image(undef);
return $blobs[0];
}
Expand Down

0 comments on commit dfa9170

Please sign in to comment.