Remove centered white-transparent Watermark - no copyright infrigment

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?".
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by snibgo »

The resizing isn't correct, so the letter edges are wrong, but the rest looks good:

Code: Select all

convert flowRoot2998.png ( flowRoot3051.png -resize 41.5% ( +clone -alpha extract +write mpr:WEX ) -compose Multiply -composite -negate ) -gravity center -compose ModulusAdd -composite ( mpr:WEX -negate ) -alpha off -compose DivideSrc -composite dewm.png
snibgo's IM pages: im.snibgo.com
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by Bonzo »

Is your PHP correct? Do you need to escape the parentheses ( and ) ?
On a Windows localhost you do not need to ecape the ( & ) but you do on a Linux type server. Note: not the exec( ).

You might get some errors returned using this method:

Code: Select all

<?php 
$array=array(); 
echo '<pre>'; 
exec("convert image1.png ( watermark.png ( +clone -alpha extract +write mpr:WEX ) -compose Multiply -composite -negate ) -gravity center -compose ModulusAdd -composite ( mpr:WEX -negate ) -alpha off -compose DivideSrc -composite dewm.png 2>&1", $array);  
echo '<br>'.print_r($array).'<br>';  
echo '</pre>'; 
?>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by fmw42 »

On unix, you need to escape the parenthesis as \( .... \)
strgg
Posts: 16
Joined: 2012-04-30T18:42:58-07:00
Authentication code: 13

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by strgg »

hi

Thanks all for your help.
@Bonzo
it just returns an empty array followed by a "1":

Code: Select all

Array
(
)
1
@snibgo @fred
I am under linux (CentOS/PHP), no need to escape the exec(..) parathensis;

the convert function seems to work under "other" conditions. i will try to narrow down by seperating some stuff.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by Bonzo »

You can add some more -write filename.jpg into your code in strategic places and see if they were created.
strgg
Posts: 16
Joined: 2012-04-30T18:42:58-07:00
Authentication code: 13

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by strgg »

Ok. I tried escaping the parenthensis within exec() and it works now: :oops:

Code: Select all

exec('convert image1.jpg \( watermark.png -resize 41.5% \( +clone -alpha extract +write mpr:WEX \) -compose Multiply -composite -negate \) -gravity center -compose ModulusAdd -composite \( mpr:WEX -negate \) -alpha off -compose DivideSrc -composite dewm.png');
So you were right it were the parathensis.
Its strange because usually in php within exec"bracket""apostroph" exec(' all the code can usually be taken literally UNTIL the next "apostroph", no need for escaping.

Thanks, i will fiddle and optimise the script and post before and after. THANKS for your time and help!!
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by pipitas »

strgg wrote:... all the code can usually be taken literally UNTIL the next "apostroph", no need for escaping.
It's already the code itself, that needs the escaping. Even if you wouldn't use PHP, but would type the command into a terminal window running a shell, you'd need
  • blanks around the parentheses
  • backslash-escaped parentheses
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by fmw42 »

It's already the code itself, that needs the escaping. Even if you wouldn't use PHP, but would type the command into a terminal window running a shell, you'd need
blanks around the parentheses
backslash-escaped parentheses
This is the case for Unix shell. Windows shell does not need the escapes for parens, as I understand it.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by snibgo »

Within convert, we always need a space on both sides of ( and ).

Convert itself doesn't want escape characters. But we have to ensure ( and ) are passed to the program. So the requirement for escaping depends on the shell.

Many shells are available for Windows. I generally use the cmd shell, either at the command prompt or in a BAT file. Neither of these need ( and ) to be escaped, unless the command is nested within parentheses caused by a FOR or IF or something else, in which case any close-parentheses within convert must be escaped, and I also escape the open-parentheses. See my web pages for many examples.

In Windows cmd, the escape character is caret ^ not backslash \. If cmd sees "\(", it treats these as normal characters and passes them to convert, which looks for an image named "\(".
snibgo's IM pages: im.snibgo.com
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by pipitas »

snibgo wrote:In Windows cmd, the escape character is caret ^ not backslash \. If cmd sees "\(", it treats these as normal characters and passes them to convert, which looks for an image named "\(".
Thanks for this clarification, snibgo!
strgg
Posts: 16
Joined: 2012-04-30T18:42:58-07:00
Authentication code: 13

Re: Remove centered white-transparent Watermark - no copyright infrigment

Post by strgg »

I did create a watermarked picture myself and used the given function to dewatermark.
This way we can see the best result possible to expect and if it is worth fiddeling. The result so far:

the result after the function used:
http://www.pic-upload.de/view-25838856/dewm.png.html
the origin image:
http://www.pic-upload.de/view-25838838/ ... s.jpg.html
the watermark white with 40% transparency:
http://www.pic-upload.de/view-25838848/ ... k.png.html
the picture watermarked:
http://www.pic-upload.de/view-25838844/watered.png.html

Conclusion: it works but i think requires postprocessing. Is there a way to neutralise the turkis-blue that is produced? Or even a smoother function?

Thanks,
Gerome
Post Reply