Autorotate image + delete EXIF tags (for more privacy)

This commit is contained in:
Luc Didry
2015-08-03 00:07:28 +02:00
parent e1840e96b0
commit b0a19e3e42
2 changed files with 16 additions and 0 deletions
+2
View File
@@ -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)
+14
View File
@@ -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,