Merge commit '41575d24bb' into webgui8. Some tests still failing.

Conflicts:
	docs/gotcha.txt
	lib/WebGUI.pm
	lib/WebGUI/Asset.pm
	lib/WebGUI/Asset/File/GalleryFile/Photo.pm
	lib/WebGUI/Asset/Post.pm
	lib/WebGUI/Asset/Template.pm
	lib/WebGUI/Asset/WikiPage.pm
	lib/WebGUI/Asset/Wobject/WikiMaster.pm
	lib/WebGUI/Cache.pm
	lib/WebGUI/Content/Setup.pm
	lib/WebGUI/Role/Asset/Subscribable.pm
	lib/WebGUI/Shop/Cart.pm
	lib/WebGUI/Shop/Pay.pm
	lib/WebGUI/Shop/PayDriver/ITransact.pm
	sbin/testEnvironment.pl
	t/Asset/WikiPage.t
	t/Shop/PayDriver.t
	t/Shop/PayDriver/ITransact.t
	t/Shop/PayDriver/Ogone.t
	t/Shop/TaxDriver/EU.t
	t/Shop/TaxDriver/Generic.t
	t/Workflow/Activity/RemoveOldCarts.t
	t/lib/WebGUI/Test.pm
This commit is contained in:
Colin Kuskie 2010-06-25 23:25:26 -07:00
commit 5febc0ebbc
258 changed files with 5528 additions and 2230 deletions

View file

@ -96,6 +96,10 @@ override applyConstraints => sub {
my $storage = $self->getStorageLocation;
my $file = $self->filename;
# Adjust orientation based on exif data. Do this before we start to
# generate resolutions so that all images have the correct orientation.
$self->adjustOrientation;
# Make resolutions before fixing image, so that we can get higher quality
# resolutions
$self->makeResolutions;
@ -110,6 +114,60 @@ override applyConstraints => sub {
super();
};
#----------------------------------------------------------------------------
=head2 adjustOrientation ( )
Read orientation information from EXIF data and rotate image if required.
EXIF data is updated to reflect the new orientation of the image.
=cut
sub adjustOrientation {
my $self = shift;
my $storage = $self->getStorageLocation;
# Extract orientation information from EXIF data
my $exifTool = Image::ExifTool->new;
$exifTool->ExtractInfo( $storage->getPath( $self->get('filename') ) );
my $orientation = $exifTool->GetValue('Orientation', 'ValueConv');
# Check whether orientation information is present and transform image if
# required. At the moment we handle only images that need to be rotated by
# (-)90 or 180 deg. Flipping of images is not supported yet.
if ( $orientation ) {
# We are going to update orientation information before the image is
# rotated. Otherwise we would have to re-extract EXIF data due to
# manipulation by Image Magick.
# Update orientation information
$exifTool->SetNewValue( 'Exif:Orientation' => 1, Type => 'ValueConv');
# Set the following options to make this as robust as possible
$exifTool->Options( 'IgnoreMinorErrors', FixBase => '' );
# Write updated exif data to disk
$exifTool->WriteInfo( $storage->getPath( $self->get('filename') ) );
# Log any errors
my $error = $exifTool->GetValue('Error');
$self->session->log->error( "Error on updating exif data: $error" ) if $error;
# Image rotated by 180°
if ( $orientation == 3 || $orientation == 4 ) {
$self->rotate(180);
}
# Image rotated by 90° CCW
elsif ( $orientation == 5 || $orientation == 6 ) {
$self->rotate(90);
}
# Image rotated by 90° CW
elsif ( $orientation == 7 || $orientation == 8 ) {
$self->rotate(-90);
}
}
}
#-------------------------------------------------------------------
=head2 generateThumbnail ( )