WODA: FAQs

 Formatting Data

Can I Use ImageMagick with WODA?
ImageMagick works great with woda. Here an example how to resize an image after it has been uploaded. Of course any other image operation is possible using the same scheme.

1) Install ImageMagick/PerlMagick
2) Read the manual page for the syntax
3) put this code in your definition file
4) enjoy

Ziga, what do you think to add a paragraph about this in the woda manual?

=============================================================================

# this will prevent to have a server error if PerlMagick it is not installed
eval('use Image::Magick; $USE_IMAGE_MAGICK=1;');

$ImageGeometry='150x200>';
$MaxUpload=1000; #in kilobytes

$WBB{'afterTableModify'}='
if ($Action =~ /^cgiStore|^cgiChanged|^cgiAdmImport|^cgiAdmStoreMany/) {
&resizeImage($rec{image});
}';


$x='image'; # ------------------------------
$WBF{$x,srt}=$i--;
$WBF{$x,'type'} = 'IMAGE';
$WBF{$x} = 'm/gif$|jpg$|jpeg$|tif$|tiff$|png$|^$/i && length($CGI{image}) < ($MaxUpload*1000)';


sub resizeImage {
local($fname)=@_;
local($image, $x);

return unless ($USE_IMAGE_MAGICK && $fname);

$fname="$WBB{'dataDir'}/att/$fname";

$image = Image::Magick->new;
$x = $image->Read($fname);
&wbError("$x") if "$x";

$x = $image->Resize(geometry=>$ImageGeometry); #the image operation goes here
$x = $image->Write($fname);

&wbError("$x") if "$x";
return;
}


modify the informationdelete entire recordexplain the meaning of the fieldsbrowse recordsAdd a new questionHome page of this databaselogin Valid HTML 4.01 Transitional Valid CSS! Powered by WODA 4.6x trunk