aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm41
-rw-r--r--templates/web/default/admin/report_edit.html5
2 files changed, 46 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index a34737844..c988b23c1 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -572,6 +572,9 @@ sub report_edit : Path('report_edit') : Args(1) {
elsif ( $c->req->param('banuser') ) {
$c->forward('ban_user');
}
+ elsif ( $c->req->param('rotate_photo') ) {
+ $c->forward('rotate_photo');
+ }
elsif ( $c->req->param('submit') ) {
$c->forward('check_token');
@@ -1161,6 +1164,31 @@ sub check_email_for_abuse : Private {
return 1;
}
+=head2 rotate_photo
+
+Rotate a photo 90 degrees left or right
+
+=cut
+
+sub rotate_photo : Private {
+ my ( $self, $c ) =@_;
+
+ my $direction = $c->req->param('rotate_photo');
+
+ return unless $direction =~ /Left/ or $direction =~ /Right/;
+
+ my $photo = _rotate_image( $c->stash->{problem}->photo, $direction =~ /Left/ ? -90 : 90 );
+
+ if ( $photo ) {
+ $c->stash->{rotated} = 1;
+ $c->stash->{problem}->photo( $photo );
+ $c->stash->{problem}->update();
+ }
+
+ return 1;
+}
+
+
=head2 check_page_allowed
Checks if the current catalyst action is in the list of allowed pages and
@@ -1207,6 +1235,19 @@ sub trim {
return $e;
}
+sub _rotate_image {
+ my ($photo, $direction) = @_;
+ use Image::Magick;
+ my $image = Image::Magick->new;
+ $image->BlobToImage($photo);
+ my $err = $image->Rotate($direction);
+ return 0 if $err;
+ my @blobs = $image->ImageToBlob();
+ undef $image;
+ return $blobs[0];
+}
+
+
=head1 AUTHOR
Struan Donald
diff --git a/templates/web/default/admin/report_edit.html b/templates/web/default/admin/report_edit.html
index 470ad311a..79207192d 100644
--- a/templates/web/default/admin/report_edit.html
+++ b/templates/web/default/admin/report_edit.html
@@ -43,6 +43,11 @@
[% IF problem.photo %]
[% photo = problem.get_photo_params %]
<li><img alt="" height="[% photo.height %]" width="[% photo.width %]" src="[% c.cobrand.base_url %][% photo.url %]">
+<br>
+[% IF rotated %]Photo may be cached. View image directly to check<br>[% END %]
+<input type="submit" name="rotate_photo" value="Rotate Left" />
+<input type="submit" name="rotate_photo" value="Rotate Right" />
+<br>
<input type="checkbox" id="remove_photo" name="remove_photo" value="1">
<label for="remove_photo">[% loc("Remove photo (can't be undone!)") %]</label></li>
[% END %]