/usr/share/perl5/Shutter/Pixbuf/Load.pm is in shutter 0.93.1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | ###################################################
#
# Copyright (C) 2008-2013 Mario Kemper <mario.kemper@gmail.com>
#
# This file is part of Shutter.
#
# Shutter is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Shutter is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Shutter; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
###################################################
package Shutter::Pixbuf::Load;
#modules
#--------------------------------------
use utf8;
use strict;
use warnings;
use Gtk2;
#fileparse and tempfile
use File::Basename qw/ fileparse dirname basename /;
use File::Temp qw/ tempfile tempdir /;
#Glib
use Glib qw/TRUE FALSE/;
#--------------------------------------
##################public subs##################
sub new {
my $class = shift;
#constructor
my $self = { _common => shift, _window => shift, _no_error_dialog => shift };
bless $self, $class;
return $self;
}
sub load {
my $self = shift;
my $filename = shift;
my $width = shift;
my $height = shift;
my $sratio = shift;
my $rotate = shift;
my $pixbuf = undef;
eval{
if(defined $width && defined $height && defined $sratio){
$pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_scale($filename, $width, $height, $sratio);
}elsif(defined $width && defined $height){
$pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_size($filename, $width, $height);
}else{
$pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($filename);
}
};
#handle possible error messages
if ($@) {
unless(defined $self->{_no_error_dialog} && $self->{_no_error_dialog}){
#import shutter dialogs
my $current_window = $self->{_window} || $self->{_common}->get_mainwindow;
my $sd = Shutter::App::SimpleDialogs->new( $current_window );
#gettext variable
my $d = $self->{_common}->get_gettext;
#parse filename
my ( $name, $folder, $type ) = fileparse( $filename, qr/\.[^.]*/ );
#nice error dialog, more detailed messages are shown with a gtk2 expander
my $response = $sd->dlg_error_message(
sprintf( $d->get("Error while opening image %s."), "'" . $name.$type . "'"),
$d->get("There was an error opening the image."),
undef, undef, undef,
undef, undef, undef,
$@->message
);
}
}
#read exif and rotate accordingly
if($rotate && $pixbuf){
$pixbuf = $self->auto_rotate($pixbuf);
}
return $pixbuf;
}
sub get_option {
my $self = shift;
my $pixbuf = shift;
my $option = shift;
return FALSE unless (defined $pixbuf && defined $option);
return $pixbuf->get_option($option);
}
sub auto_rotate {
my $self = shift;
my $pixbuf = shift;
my %orientation_flags = (
1 => 'none,-1',
2 => 'none,1',
3 => 'upsidedown,-1',
4 => 'none,0',
5 => 'clockwise,1',
6 => 'clockwise,-1',
7 => 'clockwise,0',
8 => 'counterclockwise,-1',
);
my $option = $self->get_option($pixbuf, 'orientation');
if(defined $option && exists $orientation_flags{$option}){
my ($rotate, $flip_horiz) = split ",", $orientation_flags{$option};
#~ print $option, "\n";
if(defined $rotate){
$pixbuf = $pixbuf->rotate_simple($rotate);
}
if(defined $flip_horiz && $flip_horiz > -1){
$pixbuf = $pixbuf->flip($flip_horiz);
}
}
return $pixbuf;
}
1;
|