Due to the Internet to find are borrowed from a third-party cloud processing to add a watermark, but I do not want to use, so he developed a plug-in
Hexo add a picture watermark Github Address
Currently in direct plug- hexo
official online search
The following content is in Github
the copied, the official version of my blog is currently mounted in my Github
warehouseblog
Hexo static for a blog site to add a picture watermark is generated.
Original does not have any impact, read in the original static page website building process, output watermarked images.
Does not exist in the original building static sites, there is only the watermark image.
Be sure to read the last hints matters, contain the situation and support the existing version of the feature will be added
Using npm
Plug
npm install hexo-images-watermark
In the site configuration file _config.yml
the following configuration:
watermark:
enable: true
textEnable: true
rotate: -45
gravity: centre
In hexo generate
will automatically run when you _post
add the watermark image in the catalog, new pictures will be placed in public
the position corresponding directory.
Necessary configuration parameters
enable
Default value : None
Description : true
will be executed pictures add a watermark, false
will not perform add
textEnable
Default value : false
Description : whether to add a text watermark (❌ Warning: does not currently support text and pictures at the same time add a watermark)
imageEnable
Default value : false
Description : Whether to use pictures to add a watermark (❌ Warning: does not currently support text and pictures at the same time add a watermark)
Other parameters
text
Default value : use profile url, url directly display the name of the author once does not exist (SpiritLing)
Description : When you use the text is too long, once converted image is larger than be watermarked image size, an error occurs.
color
Default value : rgb (169,169,167)
Description : Color can be used rgb, rgba, # xxxxxx and red style name. ⚠️ valid only for text
gravity
Default value : southeast
Description : Why place the watermark position direction, over north-west left and right to determine the East
Parameter values are available:
Types of | Explanation |
---|---|
centre | central |
north | north |
north | east |
north | south |
north | oo |
north | northeast |
north | southeast |
north | southwest |
north | northwest |
fontSize
Default value : 18
Description : Text size, ⚠️ valid only for text
watermarkImage
Default value : watermark.png
Description : watermark image, the picture is placed in the path name of the source file in the root; ⚠️ not exceed the size of any article in a picture, or an error occurs, it can be use with zoom
width
Default value : 50
Description : The image to zoom. ⚠️ valid only for image
height
Default value : 50
Description : The image to zoom. ⚠️ valid only for image
rotate
Default : 0
Description : rotation angle, such as 45
representatives of 45 degrees counterclockwise, -45
representative of clockwise 45 degrees
background
Default value : transparent
Description : with text and rotate to refer to a text-to-image rotation will be superfluous once the blank, set the color of these places, you can generally transparent color
Precautions ⚠️⚠️⚠️
- Not too long text is too large, the watermark image is not too large (too large can use the zoom, ⚠️ but the scale is global), otherwise an error will terminate generate static pages
- Does not support adding images and text together
- Currently only supports
*.jpg
,*.png
two formats pictures, and only supportssource/_posts
picture folder, which is the local paper pictures; they also do not support remote images - Watermark image does not support file for remote and non-soucre root path is only supported
*.jpg
,*.png
two formats picture - It does not support the full cycle diagram to add a watermark
- Please use the
1.1.x
above version1.0.x
is used when Hexo api-related test, version disorganized, use1.0.x
version any problems, almost ignore
TODO LIST
- [X] text watermark
- [X] custom text, color, size
- [] Custom fonts
- [] Cycle support added
- [] Overrun processing
- [X] picture watermark
- [X] custom watermark image
- [] Remote watermark image
- [] Cycle support added
- [] Overrun processing
- [X] position
- [X] fixed position: nine directions
- [] Custom top, left
- [X] of rotation
- [X] Zoom (Picture only)
- [] Other formats supported
Author: SpiritLing
Disclaimer: All articles in this blog unless otherwise specified, are used BY-NC-SA 4.0 license. Please indicate the source!
Blog website
starting address