Page 2 of 2

Re: Animated gif

Posted: 2008-02-03T16:33:12-07:00
by anthony
cssEXp wrote:as i said before the following doesn't work,

Code: Select all

exec("convert $image null: \( \"$watermark\" -coalease -channel A -evaluate multiply .5 \) -gravity SouthEast -layers composite -layers Optimize $image");
It is probably failing as you have another layer of quoting involved
due to the PHP wrapper around the shell command.

You not only need to change " to \"
but you need to double any existing '\' in the command so that \( will need to become \\( so that the shell sees the backslash!

Alternatively use single quotes '(' around the parenthesis for either a direct shell command, OR as in your case a PHP quoted command. The single quotes do not require any extra backslash escaping.
how do i set opacity for the one with -draw, consider the following
The -draw command has a option called fill-opacity but I do not know if this effects a draw image. See
http://imagemagick.org/Usage/draw/#mvg_settings

If that does not work however. your only solution is to pre-process the static image, as -draw will only read images from a 'image read source'.
For example using a pipeline...

Code: Select all

convert "$watermark" -channel A -evaluate .3 +channel miff:- |\
  convert $image -coalesce -gravity north-west \
       -draw 'image over 0,0 0,0 "-" $image
(Add the PHP quote wrapper as appropriate)

Alternatively you can do it in one command using the Image Processing Register "mpr:" See
http://imagemagick.org/Usage/files/#mpr

Code: Select all

convert "$watermark" -channel A -evaluate .3 +channel \
      -write mpr:wmark  +delete \
      $image -coalesce -gravity north-west \
       -draw 'image over 0,0 0,0 "mpr:wmark" $image
Remember -draw will only work for a static image. Though you can underlay (DstOver)that static image, as described in IM Examples
http://imagemagick.org/Usage/anim_mods/#compose_draw


NOTE: All the examples in IM examples are generated almost daily, using the code that is actually shown on the page itself (it is extracted from the web page and executed!) using images provided or generated by previous examples. The results you see in IM examples, IS the result you should get, IF your IM is up-to-date.

Re: Animated gif

Posted: 2008-02-04T07:53:46-07:00
by cssEXp
after all the effort you put into explaining it to me i still can't get it working, guess i'm doing something wrong.

i tried all the following.

Code: Select all

exec("convert \"$watermark\" -channel A -evaluate $opacity +channel \\ -write mpr:wmark +delete \\ $image -coalesce -gravity center \\ -draw 'image over 0,0 0,0 \"mpr:wmark\" $image");

Code: Select all

exec("convert \"$watermark\" -channel A -evaluate $opacity +channel \ -write mpr:wmark +delete \ $image -coalesce -gravity center \ -draw 'image over 0,0 0,0 \"mpr:wmark\" $image");

Code: Select all

exec("convert \"$watermark\" -channel A -evaluate $opacity +channel -write mpr:wmark +delete $image -coalesce -gravity center -draw 'image over 0,0 0,0 \"mpr:wmark\" $image");
still not working, i know you can't be wrong, i'm doing something wrong, but can't understand what i'm going wrong.

Re: Animated gif

Posted: 2008-02-04T17:30:53-07:00
by anthony
Now why are you backslashing a space?
The backslash at the end of lines are to get shells to ignore the newline and continue the command on the next line. I use multiple lines, to break up the command into stages of operation, making the command easier to follow. They should not exist in the above commands as you have them. You are also missing a final single quote on the draw command.

EG This

Code: Select all

exec("convert \"$watermark\" -channel A -evaluate $opacity +channel \\ -write mpr:wmark +delete \\ $image -coalesce -gravity center \\ -draw 'image over 0,0 0,0 \"mpr:wmark\" ' $image");
should probably be this...

Code: Select all

exec("convert \"$watermark\" -channel A -evaluate $opacity +channel -write mpr:wmark +delete $image -coalesce -gravity center -draw 'image over 0,0 0,0 \"mpr:wmark\" ' $image");
or even this

Code: Select all

exec("convert \"$watermark\" -channel A -evaluate $opacity +channel" .
      " -write mpr:wmark +delete $image -coalesce -gravity center" .
      " -draw 'image over 0,0 0,0 \"mpr:wmark\" ' $image");
I think you problem is that you are NOT seeing the error output from the command. As such you can't correct your errors.

See the RubbleWeb site which contains hints and methods for collecting and seeing these error returns from PHP shell command calls.
http://www.rubblewebs.co.uk/imagemagick/

Re: Animated gif

Posted: 2008-02-04T21:34:18-07:00
by cssEXp
i see the problem, i just blindly changed your code to single line without adding the -draw end quote you accidentally missed.

your code

Code: Select all

convert "$watermark" -channel A -evaluate .3 +channel \
      -write mpr:wmark  +delete \
      $image -coalesce -gravity north-west \
       -draw 'image over 0,0 0,0 "mpr:wmark" $image
changed it to

Code: Select all

exec("convert \"$watermark\" -channel A -evaluate $opacity +channel -write mpr:wmark +delete $image -coalesce -gravity center -draw 'image over 0,0 0,0 \"mpr:wmark\" $image");
I feel really silly about overlooking that, thanks for all your time. I should be more observant. :)

Re: Animated gif

Posted: 2008-05-06T18:33:54-07:00
by anthony
the -watermark is not directly available in the "convert" command.

However -watermark is not a good composition method in my oppion in any case.

See http://imagemagick.org/Usage/annotating/#wmark_image

As for the single command I would read 'Animation Modifications' in IM examples. overlaying a image is dealt earily, but the later section on multi-image composition will allow you to translate the single image watermarking to animation water marking.
http://imagemagick.org/Usage/anim_mods/#mods
and
http://imagemagick.org/Usage/anim_mods/#composite