Page 2 of 2

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

Posted: 2015-01-11T06:56:59-07:00
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

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

Posted: 2015-01-11T08:12:29-07:00
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>'; 
?>

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

Posted: 2015-01-11T12:44:16-07:00
by fmw42
On unix, you need to escape the parenthesis as \( .... \)

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

Posted: 2015-01-12T15:21:27-07:00
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.

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

Posted: 2015-01-12T15:25:48-07:00
by Bonzo
You can add some more -write filename.jpg into your code in strategic places and see if they were created.

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

Posted: 2015-01-12T15:39:49-07:00
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!!

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

Posted: 2015-01-12T16:31:48-07:00
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

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

Posted: 2015-01-12T18:44:54-07:00
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.

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

Posted: 2015-01-13T01:56:01-07:00
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 "\(".

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

Posted: 2015-01-13T06:22:25-07:00
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!

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

Posted: 2015-01-13T10:25:57-07:00
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