CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 ImageMagick syntax in CCS

Print topic Send  topic

Author Message
Viktor
Posted: 05/10/2005, 10:49 PM

Question:

How can I tie ImageMagick to CCS?

I want to process an uploaded image

i.e.

convert -size 120x90 input.jpg -thumbnail 120x90 output_thumbnail.gif

mogrify -format gif -size 120x90 -thumbnail 120x90 *.jpg

as in http://www.cit.gu.edu.au/~anthony/graphics/imagick6/thumbnails/

So far I have found the following topics but they don't cover this

http://forums.codecharge.com/posts.php?post_id=51639

http://forums.codecharge.com/posts.php?post_id=46787

Questions:

1. Shall I use "After Process File"?

2. How do I run 'mogrify' or 'convert' command from CSS?
Shall I use the following syntax?
system("convert ....");


Thanks in advance,

Viktor
Martin K.
Posted: 05/11/2005, 12:08 AM

Hello Victor:

You can do it like this.

In Before Inset from your Form with the FileUpload:

if ($YourForm->YourUploadField->Value <> "")
{
$max_width = 100;
$tempfile = "/tmp/" .$YourForm->YourUploadField->GetValue();
$new_file = "pictures/" .$YourForm->YourUploadField->GetValue();
createImage($max_width,$tempfile,$new_file);
}


An in your Common you must insert the Image Function:

$ImageTool = "im"; // Work with "im" or "gd"
function CreateImage($size,$source,$dest) {
$sourcedate = 0;
$destdate = 0;
global $convert;
if (file_exists($dest)) {
clearstatcache();
$sourceinfo = stat($source);
$destinfo = stat($dest);
$sourcedate = $sourceinfo[10];
$destdate = $destinfo[10];
}
if (!file_exists("$dest") or ($sourcedate > $destdate)) {
global $ImageTool;
$imgsize = GetImageSize($source);
$width = $imgsize[0];
$height = $imgsize[1];

$new_width = $size;
$new_height = ceil($size * $height / $width);
if ($ImageTool == "gd") {
$im = ImageCreateFromJPEG($source); // GD 2.0...
$new_im = ImageCreate($new_width,$new_height);

ImageCopyResized($new_im,$im,0,0,0,0,$new_width,$new_height,ImageSX($im),ImageSY($im));

ImageJPEG($new_im,$dest,75);
} elseif ($ImageTool == "im") {
system("/usr/bin/convert -scale $new_width" . "x" . "$new_height \"$source\" \"$dest\" 2>&1");
}
}
}


You must rename the Form and Fieldname to your Names!

good luck
martin
viktor
Posted: 05/11/2005, 1:35 AM

Thanks Martin

BUT

You have mentioned about
$ImageTool = "im"; // Work with "im" or "gd"

What about ImageMagick?

Thanks!

Viktor
Martin K.
Posted: 05/11/2005, 11:20 AM

Hello.
$ImageTool = "im"; // Work with "im" or "gd"
im = ImageMagick
gd = GD

greets
martin
viktor
Posted: 05/12/2005, 1:35 AM

Thanks Martin!

Will give a try.

Viktor
viktor
Posted: 05/12/2005, 2:11 AM

How / Where do I specify which width of the mew image should be?
Martin K.
Posted: 05/12/2005, 5:49 AM

Hello.
$max_width = 100;
The tumbnail will max 100 px wide.

greets martin
viktor
Posted: 05/16/2005, 6:28 AM

Hello again

I've tried - no luck.

So I've tried the way from simple-to-complex

(1) This command works from UNIX ok
===========
/usr/local/bin/convert /usr/home/<home>/public_html/files/para_images/200505161407210.Wine_Glass.jpg -resize 64x64 200505161407210.Wine_Glass.jpg

(2) I've tried it using online coding
In 'After Process File" added:

global $paragraph;
system("/usr/local/bin/convert /usr/home/<home>/public_html/files/para_images/\"$para_image\" -resize 64x64 \"$para_image\" ");

as well as

system("/usr/local/bin/convert /usr/home/<home>/public_html/files/para_images/$para_image -resize 64x64 $para_image ");

But no luck

Please advise,

Thanks in advance!

Viktor
Martin K.
Posted: 05/17/2005, 8:03 AM

Hello.
On Linux System the convert Directory is not allways the same.
It is hear:
'/usr/X11R6/bin/'
or hear
'/usr/local/bin/convert/'
or hear
'/usr/bin/'

Some Syntax for Image Magick .

/usr/bin/convert
-geometry
"150x150 "
-font Verdana -pointsize 15 -fill BLACK -border 1 -bordercolor BLACK -quality 100 -draw 'text 10,100 "STEMPELTEXT"
'
"/usr/local/httpd/htdocs/shop/images/MEINEQUELLE.GIF"
"/usr/local/httpd/htdocs/shop/images/STEMPEL.GIF"


In php:
$convert_path='/usr/bin/convert';

$convert_size_x=150;

$convert_size_y=150;

$convert_font='Verdana';

$convert_pointzize=15;

$convert_fontcolor='BLACK';

$convert_bordersize=1;

$convert_bordercolor='BLACK';

$convert_quality=100;

$convert_start_x=10;

$convert_start_y=100;

$convert_text='MEIN STEMPELTEXT';

$convert_source='/usr/local/httpd/htdocs/shop/images/MEINEQUELLE.GIF';

$convert_target='/usr/local/httpd/htdocs/shop/images/STEMPEL.GIF';

system($convert_path.' -geometry "'.$convert_size_x.'x'.$convert_size_y.' " -font '.$convert_font.' -pointsize '.$convert_pointzize.' -fill '.$convert_fontcolor.' -border '.$convert_bordersize.' -bordercolor '.$convert_bordercolor.' -quality '.$convert_quality.' -draw 'text '.$convert_start_x.','.$convert_start_y.' "'.$convert_text.'"' "'.$convert_source.'" "'.$convert_target.'"');


1. First only the Convert Directory:
2. Aktion: Like resize, scale, geometry..
3. Resize Or Scale height X wide.
4. More Actions.
5. Orginal File.
6. New File.

greets martin

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.