From b0a19e3e42dce3c4744d3886aaab830458d5c055 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 3 Aug 2015 00:07:28 +0200 Subject: [PATCH] Autorotate image + delete EXIF tags (for more privacy) --- Changes | 2 ++ lib/Lutim/Controller.pm | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Changes b/Changes index ad6d32a..e896500 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,8 @@ Revision history for Lutim - Remove deprecated (due to typo) option "provisionning". - Allow to upload svg images (no thumbnail for now, ImageMagick in Debian Jessie don't work with svg) (#47) - Allow to change location of the database (#48) + - Autorotate images + - Purge images from their EXIF tags (for more privacy) 0.6 2014-10-03 - Add OpenGraph tags in social page (ex-twitter page) diff --git a/lib/Lutim/Controller.pm b/lib/Lutim/Controller.pm index bff733a..b71acb8 100644 --- a/lib/Lutim/Controller.pm +++ b/lib/Lutim/Controller.pm @@ -2,6 +2,7 @@ package Lutim::Controller; use Mojo::Base 'Mojolicious::Controller'; use Mojo::Util qw(url_unescape b64_encode); +use Mojo::Asset::Memory; use DateTime; use Digest::file qw(digest_file_hex); use Text::Unidecode; @@ -285,6 +286,18 @@ sub add { if ($im_loaded && $mediatype ne 'image/svg+xml') { # ImageMagick don't work in Debian with svg (for now?) my $im = Image::Magick->new; $im->BlobToImage($upload->slurp); + + # Automatic rotation from EXIF tag + $im->AutoOrient(); + + # Remove the EXIF tags + $im->Strip(); + + # Update the uploaded file with it's auto-rotated clone + my $asset = Mojo::Asset::Memory->new->add_chunk($im->ImageToBlob()); + $upload->asset($asset); + + # Create the thumbnail $width = $im->Get('width'); $height = $im->Get('height'); $im->Resize(geometry=>'x85'); @@ -297,6 +310,7 @@ sub add { ($upload, $key) = $c->crypt($upload, $filename); } $upload->move_to($path); + $records[0]->update( path => $path, filename => $filename,