Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Re: [jaltuve] Thumbnailing + Imagemagick & Andy...

Quote Reply
Re: [jaltuve] Thumbnailing + Imagemagick & Andy... In reply to
This SUB can be used in the add success page. It accepts $ID as an argument and it will manipulate
the images based on the magick.cfg file located in the Plugins/ directory

Code for the Global

Code:
sub {
use Image::Magick;
my $cfg = do "$CFG->{admin_root_path}/Plugins/magick.cfg";
my $opts = shift || '0';
my $type = shift || 'Links'; if ($opts) {
my ($file,$width,$height,$bgcolor,$image,$quality);
# Read the Hash and iterate
while ( my ($field, $value) = each %$cfg) { $file = $DB->table($type)->file_info($field, $opts);
if ($file) { $width = $cfg->{$field}{width} || '100';
$height = $cfg->{$field}{height} || '100';
$bgcolor = $cfg->{$field}{bgcolor} || 'FFFFFF';
$quality = $cfg->{$field}{quality} || '60'; $image = Image::Magick->new;
$image->Read($file); # Image options...
$image->Scale(width=>$width,height=>$height);
$image->Set(quality=>$quality);
$image->Transparent(color=>$bgcolor); $image->Write($file);
undef $image;
}
}
}
return;
}


Contents of a sample magick.cfg file with two image fields (Image_Thumb and Image_Big)

Code:
{
'Image_Thumb' => {
'width' => 140,
'height' => 100,
'bgcolor' => 'FFFFFF',
'quality' => '60',
},
'Image_Big' => {
'width' => 800,
'height' => 600,
'bgcolor' => 'FFFFFF',
'quality' => '80',
},
}



This requires the Image Magick perl module installed....

Enjoy...

Last edited by:

jaltuve: Aug 18, 2003, 3:06 PM
Subject Author Views Date
Thread Thumbnailing + Imagemagick & Andy... jaltuve 3312 Aug 15, 2003, 10:21 PM
Post Re: [jaltuve] Thumbnailing + Imagemagick & Andy...
Andy 3227 Aug 16, 2003, 1:50 AM
Thread Re: [jaltuve] Thumbnailing + Imagemagick & Andy...
pugdog 3226 Aug 16, 2003, 9:17 AM
Thread Re: [pugdog] Thumbnailing + Imagemagick & Andy...
jaltuve 3193 Aug 17, 2003, 4:27 PM
Post Re: [jaltuve] Thumbnailing + Imagemagick & Andy...
Andy 3168 Aug 18, 2003, 12:41 AM
Post Re: [jaltuve] Thumbnailing + Imagemagick & Andy...
pugdog 3010 Sep 29, 2003, 1:47 PM
Post Re: [jaltuve] Thumbnailing + Imagemagick & Andy...
afinlr 3207 Aug 16, 2003, 10:30 AM
Thread Re: [jaltuve] Thumbnailing + Imagemagick & Andy...
jaltuve 3145 Aug 18, 2003, 3:04 PM
Thread Re: [jaltuve] Thumbnailing + Imagemagick & Andy...
cwschroeder 3095 Sep 25, 2003, 3:29 AM
Thread Re: [cwschroeder] Thumbnailing + Imagemagick & Andy...
jaltuve 3082 Sep 25, 2003, 4:04 AM
Thread Re: [jaltuve] Thumbnailing + Imagemagick & Andy...
cwschroeder 3064 Sep 25, 2003, 7:51 AM
Post Re: [cwschroeder] Thumbnailing + Imagemagick & Andy...
jaltuve 3043 Sep 25, 2003, 1:12 PM