What is wrong in my code

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
nicolass

What is wrong in my code

Post by nicolass »

Hi,

I try to crop image from x=0 and y=0 (from top to some Y position ie. middle) but I get allways crop from "middle" of image.

this is what I now have: Image

but I wanna this: Image

And this is part of my php code who crop image:

Code: Select all

$exec = $app->cfg['ImageMagick']['path'] . 'convert ' . '"' . $params['file_from'] . '"' . ' -resize x' . $params['need_y'] . '  -quality 85 -gravity ' . $params['gravity'] . ' -crop ' . $params['need_x'] . 'x' . $params['need_y'] . '+0+0 +repage ' . '"' . $params['file_to'] .  '"';
Can you tell me what to insert to get result like on image 2.
Ande please if you know give me and what to insert in that code to get watermatk on bottom.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: What is wrong in my code

Post by Bonzo »

You could try:

Code: Select all

$exec = $app->cfg['ImageMagick']['path'] . 'convert ' . '"' . $params['file_from'] . '"' . ' -resize x' . $params['need_y'] . '  -quality 85 -crop ' . $params['need_x'] . 'x' . $params['need_y'] . '+0+0 +repage -pointsize 50 -font Arial -fill rgba\(0,0,0,0.4\)  -gravity South ' . $params['file_to'] .  '"';
nicolass

Re: What is wrong in my code

Post by nicolass »

Bonzo wrote:You could try:

Code: Select all

$exec = $app->cfg['ImageMagick']['path'] . 'convert ' . '"' . $params['file_from'] . '"' . ' -resize x' . $params['need_y'] . '  -quality 85 -crop ' . $params['need_x'] . 'x' . $params['need_y'] . '+0+0 +repage -pointsize 50 -font Arial -fill rgba\(0,0,0,0.4\)  -gravity South ' . $params['file_to'] .  '"';

hmm..when I copy and paste that in my source file..nothing happens..even I dont get any image like output...and when I return my old code, abowe, all is ok..?

Maybe is some syntax error in your code?
nicolass

Re: What is wrong in my code

Post by nicolass »

any one?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: What is wrong in my code

Post by Bonzo »

Try this; you will need to adapt it to your method of coding but it works for me:

Code: Select all

$file_from = $params['file_from'];
$need_y = $params['need_y'];
$need_x = $params['need_x'];
$file_to = $params['file_to'];

exec("convert $file_from -resize x{$need_y} -quality 85 -crop {$need_x}x{$need_y}+0+0 +repage -pointsize 10 -font Arial -fill black  -gravity South -annotate +0+0 'Rubblewebs' $file_to"); 
This may also work which is closer to your code:

Code: Select all

exec("convert {$params['file_from']} -resize x{$params['need_y']} -quality 85 -crop {$params['need_x']}x{$params['need_y']}+0+0 +repage -pointsize 10 -font Arial -fill black  -gravity South -annotate +0+0 'Rubblewebs' {$params['file_to']}"); 
I think its a lot easer to read the code the way I write it than the way you are doing it; but its down to personal preferance in the end.
Post Reply