Watermark removal, please help [solved]
Watermark removal, please help [solved]
Hi,
I have a number of B+W photos that I need to remove a watermark from.
Unfortunately I lost the backup of the original images and only have the watermarked copies.
I am able to do this by layering the watermarked photos with the watermark in paint.net and performing a "difference."
However I have nearly 1200 images to do this for, and it would take me an eternity to do it by hand.
So I was hoping that I can achieve something similar in ImageMagick, running it as a batch?
E.g
Watermarked Image:
http://i1219.photobucket.com/albums/dd4 ... fp7j2k.png
Watermark:
http://i1219.photobucket.com/albums/dd4 ... dm6zdg.png
Difference Image:
http://i1219.photobucket.com/albums/dd4 ... gdp604.png
Inverted (final) Image:
http://i1219.photobucket.com/albums/dd4 ... opqyng.png
Can someone please help me with this? I'm really out of my depth.
I currently have ImageMagick-7.0.5-4.x86_64.rpm, and am using Windows 7 Pro.
Thanks,
BradLee
I have a number of B+W photos that I need to remove a watermark from.
Unfortunately I lost the backup of the original images and only have the watermarked copies.
I am able to do this by layering the watermarked photos with the watermark in paint.net and performing a "difference."
However I have nearly 1200 images to do this for, and it would take me an eternity to do it by hand.
So I was hoping that I can achieve something similar in ImageMagick, running it as a batch?
E.g
Watermarked Image:
http://i1219.photobucket.com/albums/dd4 ... fp7j2k.png
Watermark:
http://i1219.photobucket.com/albums/dd4 ... dm6zdg.png
Difference Image:
http://i1219.photobucket.com/albums/dd4 ... gdp604.png
Inverted (final) Image:
http://i1219.photobucket.com/albums/dd4 ... opqyng.png
Can someone please help me with this? I'm really out of my depth.
I currently have ImageMagick-7.0.5-4.x86_64.rpm, and am using Windows 7 Pro.
Thanks,
BradLee
Last edited by BradLee on 2017-04-11T19:27:19-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Watermark removal, please help.
If the watermark contains fully opaque pixels, these will have overwritten the input, so we can't calculate them. A hole-filling ("inpainting") technique might guess them.
If your watermark contains no fully-opaque pixels, and was effectively applied with "-compose Over -composite", and you know exactly where is was applied, the inverse process can easily be applied get the source image back.
Can you post the watermark image, and a watermarked image (or at least the portion that contains the watermark). You can upload to somewhere like dropbox.com and paste the URLs here.
EDIT: While I was replying, you uploaded them. I'll take a look.
If your watermark contains no fully-opaque pixels, and was effectively applied with "-compose Over -composite", and you know exactly where is was applied, the inverse process can easily be applied get the source image back.
Can you post the watermark image, and a watermarked image (or at least the portion that contains the watermark). You can upload to somewhere like dropbox.com and paste the URLs here.
EDIT: While I was replying, you uploaded them. I'll take a look.
snibgo's IM pages: im.snibgo.com
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Watermark removal, please help.
Your watermark is fully opaque, so it clearly wasn't applied with "-compose Over -composite". Do you know how it was applied?
snibgo's IM pages: im.snibgo.com
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Watermark removal, please help.
I'm using IM 7.0.5-4 on Windows 10 64. I downloaded your example image with the watermark, and your example watermark image, then I ran this command...
Code: Select all
magick image-with-watermark.png watermark.png -compose difference -composite -negate output.png
Re: Watermark removal, please help.
Yes, that works. Thanks.GeeMack wrote: ↑2017-04-11T09:17:00-07:00The result appears to be the original image with the watermark removed.Code: Select all
magick image-with-watermark.png watermark.png -compose difference -composite -negate output.png
Now is there any way I can perform this on a whole folder of images?
Cheers.
EDIT: I think i should be using:
Code: Select all
magick *.png watermark.png -compose difference -composite -negate
EDIT2: It would be even better if I could save the output over the top of each of the files, so that they kept the same file names.
Last edited by BradLee on 2017-04-11T09:51:04-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Watermark removal, please help.
Try mogrify (IM 6) and magick mogrify (IM 7) with -draw to do the composite. See http://www.imagemagick.org/Usage/basics ... fy_compose. Use difference rather than dst_in.
Mogrify will process all images in a folder. I suggest you create a new folder to hold your output before running mogrify, but it will allow you to keep the same names.
Note that the watermark image should not be in the same folder as your other images, since all are png.
EDIT: I forgot the -negate. So I have modified the above to add it.
Mogrify will process all images in a folder. I suggest you create a new folder to hold your output before running mogrify, but it will allow you to keep the same names.
Code: Select all
magick mogrify -path path2/newfolder -format png -draw "image difference 0,0 0,0 'path2/watermark.png'" -negate *.png
EDIT: I forgot the -negate. So I have modified the above to add it.
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Watermark removal, please help.
If the watermark is the same size and location, in other words if you can use the same single image as your watermark template, and all your original images are the same size and orientation, you should be able to run a whole folder with a command something like this...
Code: Select all
magick *.png -set filename:f "%[t]" null: watermark.png ^
-compose difference -layers composite -negate "cleaned\%[filename:f].png"
Edited to add: As fmw42 mentioned above, since your watermark image will also match "*.png", you may want to call it in from a location other than the folder with your working images.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Watermark removal, please help.
Always good to see multiple ways to do the same thing. IM 7 is more powerful than IM 6 and thus GeeMack's solution shows how a simple magick command can replace mogrify.
Re: Watermark removal, please help.
All the images are the same size and the watermark is in the same location. (luckily)
I think I'll attempt this tomorrow when it's not so late and my head is a little less lumpy.
Thanks GeeMack, fmw42 and snibgo for your help.
I think I'll attempt this tomorrow when it's not so late and my head is a little less lumpy.
Thanks GeeMack, fmw42 and snibgo for your help.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Watermark removal, please help.
You have 1200 images, each 791x1024 pixels. The solution starting with "magick *.png" needs 7.7 GB of memory just to read the images. If you run out of memory, this will be slow, or might fail.
The solution that starts with "magick mogrify" won't have that problem.
The solution that starts with "magick mogrify" won't have that problem.
snibgo's IM pages: im.snibgo.com
Re: Watermark removal, please help.
@fmw42
Trying your code above gives me the following errors:
Trying your code above gives me the following errors:
Code: Select all
magick mogrify -path C:\Users\Brad\Downloads\padded -format png -draw "image difference 0,0 0,0 'C:\Users\Brad\Downloads\watermark\watermark.png'" -negate *.png
mogrify: unable to open image '*.png': Invalid argument @ error/blob.c/OpenBlob/
3094.
mogrify: unable to open file `*.png' @ error/png.c/ReadPNGImage/4354.
Last edited by BradLee on 2017-04-12T05:59:04-07:00, edited 1 time in total.
Re: Watermark removal, please help.
@GeeMack
Using your code above gives me the following errors:
Using your code above gives me the following errors:
Code: Select all
magick *.png -set filename:f "%[t]" null: watermark\watermark.png -compose difference -layers composite -negate "cleaned\%[filename:f].png"
Although I don't think I have the usage right at all?magick: unable to open image '*.png': Invalid argument @ error/blob.c/OpenBlob/3
094.
magick: unable to open file `*.png' @ error/png.c/ReadPNGImage/4354.
magick: no image to apply a property "%w" @ warning/property.c/GetMagickProperty
Letter/2561.
magick: unknown image property "%w" @ warning/property.c/InterpretImagePropertie
s/3499.
magick: no image to apply a property "%h" @ warning/property.c/GetMagickProperty
Letter/2449.
magick: unknown image property "%h" @ warning/property.c/InterpretImagePropertie
s/3499.
magick: no image to apply a property "%m" @ warning/property.c/GetMagickProperty
Letter/2480.
magick: unknown image property "%m" @ warning/property.c/InterpretImagePropertie
s/3499.
Re: Watermark removal, please help.
I have 16GB RAM and the images are in folders of roughly 200 each, so running out of memory shouldn't be a problem if I can get either solution to work properly.snibgo wrote: ↑2017-04-11T10:31:03-07:00 You have 1200 images, each 791x1024 pixels. The solution starting with "magick *.png" needs 7.7 GB of memory just to read the images. If you run out of memory, this will be slow, or might fail.
The solution that starts with "magick mogrify" won't have that problem.
Re: Watermark removal, please help.
@GeeMack,
I thought I ran it from the right directory?
Let me check again.
EDIT: My mistake. It works just fine.
I'm a bit of a dunce when it comes to command line stuff.
Thanks again for your help!
I thought I ran it from the right directory?
Let me check again.
EDIT: My mistake. It works just fine.
I'm a bit of a dunce when it comes to command line stuff.
Thanks again for your help!