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?".
strgg
Posts: 16
Joined: 2012-04-30T18:42:58-07:00
Authentication code: 13

Remove centered white-transparent Watermark - no copyright infrigment

Post by strgg »

Hi

We used a default script to create thumbs with watermark and unfortunately did not keep the origin image.

Image
http://www.pic-upload.de/view-25798013/ ... 8.png.html
the watermark is always the same text and centered across images.

I would be very happy if we could remove the watermark and show it on public servers.
How could this be done??

Thanks!!!!!! for any help and hint
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 »

You seem to be missing the image. Also could you provide your exact command line for this. It would be helpful to know the exact value for the text color and the blending factors.
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 »

As Fred suggests, the code that made the watermark can probably be reversed to remove it. It also demonstrates that you made the watermarked image.
snibgo's IM pages: im.snibgo.com
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 Fred. There was a GD function like this involved laying a half-transparent image over the image.

Code: Select all

<?php
$watermark = imagecreatefrompng('watermark.png');
$photo = imagecreatefromjpeg($_GET[photo]);
 // center watermark on the photo
$wx = imagesx($photo)/2 - imagesx($watermark)/2;
$wy = imagesy($photo)/2 - imagesy($watermark)/2;
 imagecopy($photo, $watermark, $wx, $wy, 0, 0, imagesx($watermark), imagesy($watermark));
imagejpeg($photo, NULL, 100);
?>
We (university) used that on all internaly images by default. Now we want to dewatermark a part of them for further use. My predecessor was only keeping the watermarked because thenadays (9 years back) he was concerned by disk space. :?

if you give me a hint i could maybe succeed with trial & error to make it look a lil better, in worst case we would mask the non-perfectness with a new semi-transparent logo from our university.

Which functions and how would you start?

Thanks for your help
Regards, Gerome
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 »

<?php
$watermark = imagecreatefrompng('watermark.png');
$photo = imagecreatefromjpeg($_GET[photo]);
// center watermark on the photo
$wx = imagesx($photo)/2 - imagesx($watermark)/2;
$wy = imagesy($photo)/2 - imagesy($watermark)/2;
imagecopy($photo, $watermark, $wx, $wy, 0, 0, imagesx($watermark), imagesy($watermark));
imagejpeg($photo, NULL, 100);
?>
As this is an Imagemagick forum, most of us are not very familiar with GD. What puzzles me is that the link you provided shows an image with the watermark partially transparent over the background image. I do not see any blending factor in your code above. Does the watermark.png image have partial transparency?

Perhaps you could create a new example from your code and provide the two input images and the output. That way we can test with a real example. Without knowing how much blending or transparency is involved, it would be hard to tell how to reverse it without lots of trial and error.
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 »

I suppose the transparency is in watermark.png. With that file, I expect the process can be reversed with IM (or GD, whatever that is).
snibgo's IM pages: im.snibgo.com
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 »

Please have a look at the linked picture in the starting post. this is exactly how it looks like. Yes, the watermark png is partially transparent. Unfortunately i couldn't find the watermark image on the server since they upgraded the CMS and the upload has been replaced by a non-watermark upload 4 years ago. the pictures concerned are from years back.

Starting with the linked image ... is there 1 approach which is best? which functions would you make use of?

Thanks for all your time and help.

Best regards,

Gerome
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 »

I would tackle this from two directions.

First, find the colour and general opacity of watermark.png. Experiment would find this, and it wouldn't take long.

Next, find the exact shapes of the letters, and the positions, in watermark.png. This is far more tedious. You might have to make many adjustments by hand.

Once you have watermark.png, converting the files is almost trivial. I don't understand your PHP & GD code, but if it is like IM's "-compose Over -composite", the inverse would be something like this (Windows BAT syntax):

Code: Select all

convert ^
  toeswm.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
... where toeswm.png is an image with watermark, and the output dewm.png is the de-watermarked image.
snibgo's IM pages: im.snibgo.com
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 »

Another thought: how many watermarked images do you have? You might find that averaging them all together, or something, gives a first approximation to the letter shapes.
snibgo's IM pages: im.snibgo.com
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 snibgo.

about 500 pictures. so we are able to detect the common repeating pattern and then create the watermark.png out of it?
that sounds powerful. if you give me a hint regarding functions i will try and show off the results.

Thanks
Regards,
Gerome
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 »

You'd need to experiment, but you might start with something like:

Code: Select all

convert ^
  image1.png ^
  image2.png ^
  image3.png ^
:
:
  image99.png ^
  -gravity Center -crop 160x50+0+0 +repage ^
  -evaluate-sequence Mean ^
  -auto-level ^
  out.png
The crop should capture just a bit more than watermark.

EDIT: I forgot to add "+0+0" to the crop.
snibgo's IM pages: im.snibgo.com
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

trying to get the watermark only results in a cut out of the watermark (which is white-transparent) with the whole background still in presence, code from post snibgo 2015.01-10T04:22:17.

so i recreated the watermark with inkscape since the font used is available. I now have a watermark pic in white color where i can variate the only unknown variable left ... which is the transparency.

Using this watermark with the function from snibgo 2015-01-10T02:30:14, it results in no error thrown but no processing either.

I use Version: ImageMagick 6.7.6-8 2012-05-02 Q16
My code is:

Code: Select all

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 dewatered.png');
Possible reasons i could think off:
- Version does not support functions used
- Functions syntax is not right
- image1.png (watermarked pic) is in orignal image1.JPG which i converted - maybe there
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 »

You need a space on both sides of every parenthesis ( ) .
snibgo's IM pages: im.snibgo.com
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 »

Thanks snibgo. Unfortunately it doesn't change the result, no processing nor error.

Code: Select all

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');
I try with this watermarked image
http://www.pic-upload.de/view-25798013/ ... 8.png.html

and here the watermark image
(45 % transparent white written, save or right click->"view image" to view whats hidden in the white background)
http://www.pic-upload.de/view-25817469/ ... 1.png.html

Is there a way i can debug what function is causing the problem?

Thanks for your time !
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 »

It works fine for me, at the command line, with IM v6.9.0-0, except that flowRoot2998.png is the wrong size. I can't see how to download the full-size version (I don't read German).

Is your PHP correct? Do you need to escape the parentheses ( and ) ?
snibgo's IM pages: im.snibgo.com
Post Reply