[a solution] image processing: remove watermark / add watermark - you must learn these methods. It's amazing~

🌄 Introduction

Hello, basin friends, mud sprouts well, stand on your own after winter 🌧🌦🌥 The temperature dropped sharply.

Today is Muzi who goes to work in a down jacket ⛲! The cold wind is biting. Remember to keep warm~

In the twinkling of an eye, November is almost a day away, and the end of the month. It's one step closer to the new year's Day holiday,

After a few months, it will be the new year ~ today we still have to try to move bricks for a living, otherwise it will be miserable when we go home for the New Year!

Yesterday, a friend who wrote a game article asked me to help with the watermark of the picture. He said that it was difficult to find the material. When he found the watermark, it was difficult to do

Let me help you find a way, ha ha ha - get ready for dark rubbing~​

The little ones want to go 🚥 Yes, some want to add watermark 🚦 Yes, it's all arranged for today~

Today, I recommend a method for programmers to add watermark + remove watermark! Expectation.jpg

​

​

🌅 text

So here it is. Let's follow Xiaobian and see what methods are there?

The article will write 2 ways to add watermark and remove watermark ~ full of dry goods to share, remember to pay attention to me!

​

🛬 1, Add watermark

1) Add watermark to OpenCV 🚀

​1.1   "May you meet a lover" after the original effect + watermark. ⚓

1.2 main codes attached ⚓

#Select the picture to be watermarked
img = cv2.imread('06.jpg')
# Add text watermark to picture
# Cv2.puttext (image, string to be added, coordinates to be drawn, font type, font size, font color, font thickness)
img2 = cv2.putText(img, 'May you meet a lover', (100, 100), cv2.LINE_AA, 2, (249, 249, 249), 2)
# Save picture
cv2.imwrite('wj.jpg', img2)
# The following is to display the generated picture in the pop-up window
cv2.imshow('img',img2)
cv2.waitKey(0)
cv2.destoryAllWindows('img')

2) PIL add watermark 🚀

2.1 after the original effect picture + watermark is added, "may you meet a lover, give you a happy city and a long song to warm your life." ⚓

2.2 main codes attached ⚓

im=Image.open('111.jpg')
draw=ImageDraw.Draw(im)
text = 'May you meet a lover,Give you joy City,Long songs warm floating life.'
Font=ImageFont.truetype(r'C:\Windows\Fonts\simsun.ttc',size=40)#Import font file
draw.ink = 0 + 0 * 256 + 255 * 256 * 256 # colour
draw.text([200,200],text,'red',font=Font) # Load text onto picture
im.save('12.png','png') #Save picture
im.show() #display picture

🛬 2, Remove watermark

1) OpenCV+Numpy watermark removal 🚀

1.1 with text watermark 'copy prohibited' + after removing the watermark ⚓

1.2 main codes attached ⚓

img = cv2.imread('test.png')

new = np.clip(1.4057577998008846*img-38.33089999653017, 0, 255).astype(np.uint8)

cv2.imwrite('removed.png', new)

2) PIL+itertools remove watermark 🚀

2.1 text watermark 'Caitu network correction' + after removing the watermark ⚓

2.2 main codes attached ⚓

img = Image.open('test1.png')
width, height = img.size
for pos in product(range(width), range(height)):
    if sum(img.getpixel(pos)[:3]) > 600:
        img.putpixel(pos, (255,255,255))
img.save('removed_1.png')

🌇 summary

OK so, that's what Kiki Ko brings to different methods: adding watermark + watermark, what do old fellow want to know?

You can leave a message in the comment area and tell Xiaobian ha ~ there will be new articles when you have time to study~

​

🎯 Complete free source code collection:

For the complete project source code + material source code base, see: # private letter editor 06# or click the blue text to add to get free benefits!

Your support is my biggest motivation!! Remember the third company ~mua   Welcome to read previous articles~

🍓 Recommended reading of previous articles——

Item 1.0     Cool running games every day

Is cool running every day really out of fire? Python releases the "cool run +" program.

Item 1.0 fireworks Rose (including multiple source codes)

  Python confession Code: "all the fireworks on the starry and moonlit nights belong to you, and I belong to you" (fireworks are in full bloom, with roses outside)

  Item 1.7   Love anniversary

[Python souvenir book] two people in one room have three meals and four seasons: "it's only xx years away from a hundred years of good marriage ~" how much? Just come in and have a look.

  Item 1.9   Confession collection 💘

[collection of Python expressing love] - "the story is very long. I'll make a long story short. I like you for a long time" (♡ ʟ ᴏᴠᴇ ᴜ ᴛ ʜʀ ᴇᴇ ᴛ ʜ ᴏᴜsᴀ ɴ ᴅ♡)

👑 Article summary——

Item 1.0   Python-2021 | summary of existing articles | continuously updated. It's enough to read this article directly

(more content + source code are summarized in the article!! welcome to read ~)

​

Tags: Python OpenCV AI

Posted on Mon, 29 Nov 2021 19:36:55 -0500 by Jay87