Help me to watermark

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

Help me to watermark

Post by nicolass »

Hi can enyone tell me what to insert in this part of php code to get watermark on image:

Code: Select all

$exec = $app->cfg['ImageMagick']['path'] . 'convert ' . '"' . $params['file_from'] . '"' . ' -resize x' . $params['need_y'] . '  -quality 70 -gravity ' . $params['gravity'] . ' -crop ' . $params['need_x'] . 'x' . $params['need_y'] . '+0+0 +repage ' . '"' . $params['file_to'] .  '"';
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Help me to watermark

Post by Bonzo »

I put some watermarking code in your previous post as you asked then.
nicolass

Re: Help me to watermark

Post by nicolass »

yes, but that code not work...and I post new message with "smaller" question...

can you tell me

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']}"); 
but I try to do that and nothing..even I dont get output image?

In your example I will get result new image with 'Rubblewebs' word on it?

I put this in my code with your suggestion:

Code: Select all


$exec = $app->cfg['ImageMagick']['path'] . 'convert ' . '"' . $params['file_from'] . '"' . ' -resize x' . $params['need_y'] . '  -quality 70 -gravity ' . $params['gravity'] . ' -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'] .  '"';


is that ok? maybe is escape code wrong \'Rubewebs\' ?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Help me to watermark

Post by Bonzo »

The code I posted in your other thread worked for me on my server; I find it a bit hard to read your code with all the ' " and . so I changed it ! Once you get it working you can then put it how you want it.
I am just using convert and I know from another recent post that you may need to use something like user/local/bin/convert depending on how your server is setup.

You can change my code to the example below and it should give you some idea of any errors.

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']} 2>&1", $array); 
echo "<pre>".print_r($array)."</pre>"; 
You may get 'Rubblewebs' as the watermark and in that case just remove the '
nicolass

Re: Help me to watermark

Post by nicolass »

nothing...

i do this:

Code: Select all

$exec = $app->cfg['ImageMagick']['path'] . 'convert ' . '"' . $params['file_from'] . '"' . ' -resize x' . $params['need_y'] . '  -quality 70 -gravity ' . $params['gravity'] . ' -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'] .  '"';
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Help me to watermark

Post by Bonzo »

WHY HAVE YOU PUT -gravity ' . $params['gravity'] back in? If you take that out your code may work.

Code: Select all

$file_from = 'sunflower.jpg';
$need_y = '100';
$need_x = '100';
$file_to = 'nicolass1.jpg';

exec("convert $file_from -resize x{$need_y} -quality 70 -crop {$need_x}x{$need_y}+0+0 +repage -pointsize 10 -font Arial -fill black -gravity South -annotate +0+0 Rubblewebs $file_to");
This works for me.
nicolass

Re: Help me to watermark

Post by nicolass »

Work..finaly :)

tnx guys...

code look now like this:

Code: Select all

$exec = $app->cfg['ImageMagick']['path'] . 'convert ' . '"' . $params['file_from'] . '"' . ' -resize x' . $params['need_y'] . '  -quality 70 -gravity ' . $params['gravity'] . ' -crop ' . $params['need_x'] . 'x' . $params['need_y'] . '+0+0 +repage -pointsize 10 -font Arial -fill black  -gravity South -annotate +0+0 WWW.MYSITE.COM ' . '"' . $params['file_to'] .  '"';
Can you tell me can I watermark with some image? Can I only replace this word with path to some transparent image or I must use diferent code?
Post Reply