This is a creation in Article, where the information may have evolved or changed.
Original Image:
Add a watermark after the image:
//golang image watermark Processing//non-implementation of web uploads and other code ...//sam//2013.6.19//http://zituo.netpackage mainimport ("FMT" "Image" "Image/draw" " Image/jpeg "" Image/png "" OS ") Func main () {///original picture is SAM.JPGIMGB, _: = OS. Open ("Sam.jpg") img, _: = JPEG. Decode (IMGB) defer IMGB. Close () WMB, _: = OS. Open ("Text.png") watermark, _: = png. Decode (WMB) defer WMB. Close ()//write the watermark to the lower right corner, and offset to 0 coordinates of 10 pixels: = image. Pt (IMG. Bounds (). Dx ()-watermark. Bounds (). Dx () -10, IMG. Bounds (). Dy ()-watermark. Bounds (). Dy () -10) b: = img. Bounds () M: = image. Newnrgba (b) draw. Draw (M, B, IMG, image. ZP, Draw. SRC) draw. Draw (M, Watermark. Bounds (). ADD (offset), watermark, image. ZP, Draw. OVER)//generate new picture new.jpg, and set picture quality. IMGW, _: = OS. Create ("new.jpg") jpeg. Encode (IMGW, M, &jpeg. OPTIONS{100}) Defer IMGW. Close () fmt. PRINTLN ("Watermark added end, see new.jpg Pictures ...")}