Better rotation handling

This commit is contained in:
Denis Fedoseev 2017-07-19 16:01:12 +09:00
parent bc94cf961d
commit 112aa4b48f

View file

@ -166,10 +166,11 @@ post '/upload' => (authenticated => 1)=> sub {
my $imager = Imager->new(); my $imager = Imager->new();
$imager->read(file => $image_file) or die $imager->errstr; $imager->read(file => $image_file) or die $imager->errstr;
#http://sylvana.net/jpegcrop/exif_orientation.html #http://sylvana.net/jpegcrop/exif_orientation.html
my $rotation_angle = $imager->tags( name => "exif_orientation"); #http://myjaphoo.de/docs/exifidentifiers.html
$self->app->log->info("Rotation angle [".$rotation_angle."]"); my $rotation_angle = $imager->tags( name => "exif_orientation") || 1;
$self->app->log->info("Rotation angle [".$rotation_angle."] [".$image->filename."]");
for my $scale (@scale_width) { for my $scale (@scale_width) {
if ($rotation_angle == 3) { if ($rotation_angle == 3) {
@ -187,7 +188,7 @@ post '/upload' => (authenticated => 1)=> sub {
$self->render(json => {files => [ $self->render(json => {files => [
{ {
name => $filename, name => $image->filename,
size => $image->size, size => $image->size,
url => sprintf('/images/orig/%s', $filename), url => sprintf('/images/orig/%s', $filename),
thumbnailUrl => sprintf('/images/200/%s', $filename), thumbnailUrl => sprintf('/images/200/%s', $filename),