Soptq

Soptq

Probably a full-stack, mainly focusing on Distributed System / Consensus / Privacy-preserving Tech etc. Decentralization is a trend, privacy must be protected.
twitter
github
bilibili

The image watermark is indeed not suitable for me.

Some viewers may have noticed (although I don't think this blog has any other followers), Soptlog in the previous version had a watermark in the bottom left corner of all the images in the articles. However, in this version, all the watermarks have been removed. The initial motivation for adding the watermark was simple: first, to test the ability of Ruby to call Nodejs, and second, I found a blog that was copying and pasting my content without giving credit, so I wanted to use a watermark to "assert my ownership". Now it seems that it's not suitable for me.

Implementation method:

Considering that there may be some friends who want to implement similar functionality in the future, I will briefly describe the method of generating watermark images during Jekyll compilation.

The first principle is that I don't care about what the image looks like after compilation, but you can't modify my original image. So batch adding watermarks to the original images is not feasible, and we can only process the images during the process of generating the Jekyll site. Therefore, the key method to hook is the copy_file(dest_path) method in Jekyll::StaticFile, which is mainly used to copy static files from the original address to the site address _site/. We just need to intercept all the images in this process and use our method to copy them.

Considering that Ruby's image processing mainly relies on imageMagick, and I don't want to install a somewhat "heavy" library for every remote CI, so image processing is mainly done in Nodejs using Sharp.

Ruby's invocation mainly relies on SystemCall, so it is relatively slow. I thought of a better method later and will supplement it later. SystemCall is too slow, so I changed it to Socket invocation, and the speed instantly increased by 8 times.

Why it's not suitable for me:

I am very concerned about aesthetics, and adding a watermark is just too ugly.

Alternative method:

I still want to add a watermark, but I want to add it in a "very elegant" way. I am currently considering steganography and may implement my own encryption algorithm. I will supplement it when there is progress in the future. The current implementation method is to use steganography on the images during the compilation process.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.