gowatermark

package module
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 9 Imported by: 0

README

goWatermark

This package allows you to add customizable watermarks to images using the Go programming language. It provides functionalities for positioning, repeating text, and adjusting font properties.

Installation
go get github.com/michaelwp/goWatermark
Example
package main

import (
	"fmt"
	"image/color"

	"github.com/michaelwp/goWatermark"
)

func main() {
	err := gowatermark.AddWatermark(
		&gowatermark.Watermark{
			Image:      "input1.jpeg",
			OutputFile: "output.jpeg",
			Text:       "79995782-PTGLOBALPRADANASEJAHTERA-227",
			Position: gowatermark.Position{
				PosAY: 10,
			},
			Font: gowatermark.Font{
				FontSize: 12,
			},
			Color: color.RGBA{
				R: 255,
				G: 255,
				B: 255,
				A: 80,
			},
			Align: gowatermark.AlignCenter,
			Repeat: gowatermark.Repeat{
				RepY: 20,
				RepX: 10,
			},
			LineSpacing: 25,
			Rotate:      -30,
			ImgSize: gowatermark.ImgSize{
				Width: 250,
			},
		},
	)
	if err != nil {
		fmt.Println("Error:", err)
	} else {
		fmt.Println("Watermark added successfully!")
	}
}

This example demonstrates how to configure and apply a watermark to an image using the go_watermark package. Adjust the parameters as needed to fit your specific use case.

for detail explanation visit: How to Add a Watermark onto an Image Using Go

Documentation

Overview

Package gowatermark allows you to add customizable watermarks to images using the Go programming language.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddWatermark

func AddWatermark(watermark *Watermark) error

func DrawWatermark

func DrawWatermark(font *truetype.Font, watermark *Watermark, dc *gg.Context, imgWidth, imgHeight float64)

Types

type Align

type Align int
const (
	AlignLeft Align = iota
	AlignCenter
	AlignRight
)

type Font

type Font struct {
	FontName string
	FontSize float64
}

type ImgSize

type ImgSize struct {
	Width, Height int
}

type Position

type Position struct {
	PosX  float64
	PosY  float64
	PosAX float64
	PosAY float64
}

type Repeat

type Repeat struct {
	RepX, RepY, WordSpacing int
}

type Watermark

type Watermark struct {
	Image      string
	OutputFile string
	Text       string
	Position
	Font
	Color       color.Color
	Align       Align
	LineSpacing float64
	Repeat
	Rotate float64
	ImgSize
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL