Page 1 of 1

Newbie needs help... Please

Posted: 2007-02-19T16:07:18-07:00
by kpettit
I am getting an error 500 server error.

Code: Select all

#!/usr/bin/perl
 
use Image::Magick;
my($image, $x);
$image = Image::Magick->new;
$x = $image->Read('girl.png');
warn "$x" if "$x";
$x = $image->Crop(geometry=>'100x100+100+100');
warn "$x" if "$x";
$x = $image->Write('x.png');
warn "$x" if "$x";
I feel stupid even posting this but I program in PHP but am very green when it comes to .pl and imageMagick.

Thanks,
Ken..

Re: Newbie needs help... Please

Posted: 2007-02-19T16:24:25-07:00
by anthony
Reset the virtual canvas (page) geometry after the crop. PNG preserves the +100+100 offset, and IM also adds its one small meta-data to preserve the images original canvas size too.

Re: Newbie needs help... Please

Posted: 2007-02-19T18:11:48-07:00
by kpettit
What code do I need to add to reset the canvas?

Ken

Re: Newbie needs help... Please

Posted: 2007-02-19T18:33:03-07:00
by kpettit
Anthony,
Thanks for your help. At this point I am just looking to make sure ImageMagick is installed correctly.
The following code I copied from your site at http://www.imagemagick.org/Usage/draw/.

Code: Select all

  #!/usr/bin/perl
  
  # Rectangle

    convert -size 100x60 xc:skyblue -fill white -stroke black \
            -draw "rectangle 20,10 80,50"       draw_rect.gif
This also gives me an error 500. Which leads me to believe I'm doing something wrong.
To eliminate any programming errors on my part could you please post a simple .pl script you know works.

Thanks for your patients.

Ken...

Re: Newbie needs help... Please

Posted: 2007-02-19T20:24:32-07:00
by anthony
I gather that you are running this script as a web CGI (error 500 - server configuration error). In which case do the following...

Code: Select all

#!/usr/bin/sh
echo "content/type: image/gif"
echo ""
 
convert -size 100x60 xc:skyblue -fill white -stroke black \
            -draw "rectangle 20,10 80,50"     gif:-
Note that this is a shell script, not a perl script, and that web servers expect to know what type of data is being returned so needs a minimal two line header. The gif:- then outputs the GIF result to STDOUT, and the webserver to web client stream.

None of this is an IM fault however, just 'usage'.

Re: Newbie needs help... Please

Posted: 2007-02-20T01:31:32-07:00
by kpettit
Thanks!

That helped a bunch. I wrote a php script that called exec() to access the shell commands. So now I have access to the power of ImageMagick.

Code: Select all

<?php
// Create .sh command
$convert = "composite -compose Copy_Opacity greyscale.jpg  red2.jpg  compose_mask.tga";

// Execute .sh
exec($convert);

?>

Is there any way I can create an rgba Targa from a SVG with transparancies? Or do I need to do it as done above?

Sincerely,
Ken...

Re: Newbie needs help... Please

Posted: 2007-02-21T20:28:12-07:00
by anthony

Code: Select all

convert image.svg  image.tga
IM may use an external rsvg library or its builtin svg handler.