Graphics::Magick is now the standard graphics package in WebGUI, but

Image::Magick will be supported for backwards compatibility. See gotcha.txt
   for details.
This commit is contained in:
JT Smith 2007-07-26 03:23:47 +00:00
parent 168ba28ccf
commit bde1a7a941
6 changed files with 55 additions and 10 deletions

View file

@ -10,6 +10,9 @@
- api: You may now use a customDrawMethod attribute in your asset properties - api: You may now use a customDrawMethod attribute in your asset properties
list that will enable you to add custom display options for that fields when list that will enable you to add custom display options for that fields when
the edit form is automatically generated. the edit form is automatically generated.
- Graphics::Magick is now the standard graphics package in WebGUI, but
Image::Magick will be supported for backwards compatibility. See gotcha.txt
for details.
- Added file attachments to the Wiki. - Added file attachments to the Wiki.
- Added a new attachments form control. - Added a new attachments form control.
- Added a form control skeleton. - Added a form control skeleton.

View file

@ -33,6 +33,17 @@ save you many hours of grief.
Class::InsideOut Class::InsideOut
HTML::TagCloud HTML::TagCloud
* WebGUI now uses Graphics::Magick instead of Image::Magick for
image processing functions. However, for the next few versions you
will still be able to use Image::Magick if you already have it
installed, to make the transition easier. Graphics::Magick is a
fork of Image::Magick, but it's focus is stability and compatibility
over adding new features. Another note will be added to this file
when support for Image::Magick is officially removed. That will
most likely happen in WebGUI 7.6.0. Note that WRE 0.8.0 includes
Graphics::Magick, so if you upgrade to WRE 0.8.0 then you'll
automatically be ready for the future.
* Any customizations made to the Inbox or Inbox/Message tempalates * Any customizations made to the Inbox or Inbox/Message tempalates
will be lost. Please back up your custom templates before running will be lost. Please back up your custom templates before running
the upgrade the upgrade

View file

@ -1,8 +1,23 @@
package WebGUI::Image; package WebGUI::Image;
use strict; use strict;
use Image::Magick;
use WebGUI::Image::Palette; use WebGUI::Image::Palette;
use Carp qw(croak);
eval 'use Graphics::Magick';
my $graphicsMagickAvailable = ($@) ? 0 : 1;
eval 'use Image::Magick';
my $imageMagickAvailable = ($@) ? 0 : 1;
my $graphicsPackage = '';
if ($imageMagickAvailable) {
$graphicsPackage = "Image::Magick";
}
elsif ($graphicsMagickAvailable) {
$graphicsPackage = "Graphics::Magick";
}
else {
croak "You must have either Graphics::Magick or Image::Magick installed to run WebGUI.\n";
}
=head1 NAME =head1 NAME
@ -173,7 +188,7 @@ sub new {
my $width = shift || 300; my $width = shift || 300;
my $height = shift || 300; my $height = shift || 300;
my $img = Image::Magick->new( my $img = $graphicsPackage->new(
size => $width.'x'.$height, size => $width.'x'.$height,
); );

View file

@ -1118,8 +1118,8 @@ sub processDataset {
} }
my $dataIndex = 0; my $dataIndex = 0;
my $divisor = scalar(@{$self->getDataset}) || 1; # avoid division by zero
my $stepsize = ($self->getTopHeight + $self->getBottomHeight) / scalar(@{$self->getDataset}); my $stepsize = ($self->getTopHeight + $self->getBottomHeight) / $divisor;
foreach (@{$self->getDataset}) { foreach (@{$self->getDataset}) {
$self->addSlice({ $self->addSlice({
percentage => $_ / $total, percentage => $_ / $total,

View file

@ -14,10 +14,25 @@ package WebGUI::Storage::Image;
=cut =cut
use Image::Magick;
use strict; use strict;
use WebGUI::Storage; use WebGUI::Storage;
use WebGUI::Utility; use WebGUI::Utility;
use Carp qw(croak);
eval 'use Graphics::Magick';
my $graphicsMagickAvailable = ($@) ? 0 : 1;
eval 'use Image::Magick';
my $imageMagickAvailable = ($@) ? 0 : 1;
my $graphicsPackage = '';
if ($imageMagickAvailable) {
$graphicsPackage = "Image::Magick";
}
elsif ($graphicsMagickAvailable) {
$graphicsPackage = "Graphics::Magick";
}
else {
croak "You must have either Graphics::Magick or Image::Magick installed to run WebGUI.\n";
}
our @ISA = qw(WebGUI::Storage); our @ISA = qw(WebGUI::Storage);
@ -62,7 +77,7 @@ sub addFileFromCaptcha {
srand; srand;
$challenge.= ('A'..'Z')[rand(26)] foreach (1..6); $challenge.= ('A'..'Z')[rand(26)] foreach (1..6);
my $filename = "captcha.".$self->session->id->generate().".png"; my $filename = "captcha.".$self->session->id->generate().".png";
my $image = Image::Magick->new(); my $image = $graphicsPackage->new();
$image->Set(size=>'105x26'); $image->Set(size=>'105x26');
$image->ReadImage('xc:white'); $image->ReadImage('xc:white');
$image->AddNoise(noise=>"Multiplicative"); $image->AddNoise(noise=>"Multiplicative");
@ -144,7 +159,7 @@ sub generateThumbnail {
$self->session->errorHandler->warn("Can't generate a thumbnail for something that's not an image."); $self->session->errorHandler->warn("Can't generate a thumbnail for something that's not an image.");
return 0; return 0;
} }
my $image = Image::Magick->new; my $image = $graphicsPackage->new;
my $error = $image->Read($self->getPath($filename)); my $error = $image->Read($self->getPath($filename));
if ($error) { if ($error) {
$self->session->errorHandler->error("Couldn't read image for thumbnail creation: ".$error); $self->session->errorHandler->error("Couldn't read image for thumbnail creation: ".$error);
@ -211,7 +226,7 @@ sub getSizeInPixels {
$self->session->errorHandler->error("Can't check the size of something that's not an image."); $self->session->errorHandler->error("Can't check the size of something that's not an image.");
return 0; return 0;
} }
my $image = Image::Magick->new; my $image = $graphicsPackage->new;
my $error = $image->Read($self->getPath($filename)); my $error = $image->Read($self->getPath($filename));
if ($error) { if ($error) {
$self->session->errorHandler->error("Couldn't read image to check the size of it: ".$error); $self->session->errorHandler->error("Couldn't read image to check the size of it: ".$error);
@ -303,7 +318,7 @@ sub resize {
$self->session->errorHandler->error("Can't resize with no resizing parameters."); $self->session->errorHandler->error("Can't resize with no resizing parameters.");
return 0; return 0;
} }
my $image = Image::Magick->new; my $image = $graphicsPackage->new;
my $error = $image->Read($self->getPath($filename)); my $error = $image->Read($self->getPath($filename));
if ($error) { if ($error) {
$self->session->errorHandler->error("Couldn't read image for resizing: ".$error); $self->session->errorHandler->error("Couldn't read image for resizing: ".$error);

View file

@ -94,7 +94,8 @@ checkModule("DateTime",0.2901);
checkModule("Time::HiRes",1.38); checkModule("Time::HiRes",1.38);
checkModule("DateTime::Format::Strptime",1.0601); checkModule("DateTime::Format::Strptime",1.0601);
checkModule("DateTime::Format::Mail",0.2901); checkModule("DateTime::Format::Mail",0.2901);
checkModule("Image::Magick",6.0); checkModule("Image::Magick","6.0",2);
checkModule("Graphics::Magick","1.1.7",2);
checkModule("Log::Log4perl",0.51); checkModule("Log::Log4perl",0.51);
checkModule("Net::LDAP",0.25); checkModule("Net::LDAP",0.25);
checkModule("HTML::Highlight",0.20); checkModule("HTML::Highlight",0.20);