Another checkpoint.
This commit is contained in:
parent
2bbd1c8610
commit
3e5c9d04ae
4 changed files with 184 additions and 8 deletions
|
|
@ -1115,7 +1115,7 @@ sub crop {
|
|||
}
|
||||
|
||||
# Write our changes to disk
|
||||
$error = $image->Write($self->getPath('crop-'.$filename));
|
||||
$error = $image->Write($self->getPath($filename));
|
||||
if ($error) {
|
||||
$self->session->errorHandler->error("Couldn't resize image: ".$error);
|
||||
return 0;
|
||||
|
|
@ -1126,6 +1126,54 @@ sub crop {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 rotate ( filename [ degrees ] )
|
||||
|
||||
Rotates the image by the specified degrees.
|
||||
|
||||
=head3 filename
|
||||
|
||||
The name of the file to resize.
|
||||
|
||||
=head3 width
|
||||
|
||||
Number of degrees to rotate.
|
||||
|
||||
=cut
|
||||
|
||||
sub rotate {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $degree = shift || 0;
|
||||
unless (defined $filename) {
|
||||
$self->session->errorHandler->error("Can't rotate when you haven't specified a file.");
|
||||
return 0;
|
||||
}
|
||||
unless ($self->isImage($filename)) {
|
||||
$self->session->errorHandler->error("Can't rotate something that's not an image.");
|
||||
return 0;
|
||||
}
|
||||
my $image = Image::Magick->new;
|
||||
my $error = $image->Read($self->getPath($filename));
|
||||
if ($error) {
|
||||
$self->session->errorHandler->error("Couldn't read image for resizing: ".$error);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$self->session->errorHandler->info( "Rotating $filename by $degree degrees" );
|
||||
$image->Rotate( $degree );
|
||||
|
||||
# Write our changes to disk
|
||||
$error = $image->Write($self->getPath($filename));
|
||||
if ($error) {
|
||||
$self->session->errorHandler->error("Couldn't rotate image: ".$error);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 resize ( filename [, width, height ] )
|
||||
|
||||
Resizes the specified image by the specified height and width. If either is omitted the iamge will be scaleed proportionately to the non-omitted one.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue