Newbie needs help... Please

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
kpettit

Newbie needs help... Please

Post by kpettit » 2007-02-19T16:07:18-07:00

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..

User avatar
anthony
Posts: 8878
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Newbie needs help... Please

Post by anthony » 2007-02-19T16:24:25-07:00

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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

kpettit

Re: Newbie needs help... Please

Post by kpettit » 2007-02-19T18:11:48-07:00

What code do I need to add to reset the canvas?

Ken

kpettit

Re: Newbie needs help... Please

Post by kpettit » 2007-02-19T18:33:03-07:00

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...

User avatar
anthony
Posts: 8878
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Newbie needs help... Please

Post by anthony » 2007-02-19T20:24:32-07:00

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'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

kpettit

Re: Newbie needs help... Please

Post by kpettit » 2007-02-20T01:31:32-07:00

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...

User avatar
anthony
Posts: 8878
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Newbie needs help... Please

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

Code: Select all

convert image.svg  image.tga
IM may use an external rsvg library or its builtin svg handler.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Post Reply