Example #1
0
func (this *WaterMarkProcessor) Process(img *img4g.Image) error {
	l4g.Debug("process watermark")
	var err error = nil
	tran := this.Cat.NewTransaction(Image, "Watermark")

	defer func() {
		this.Logo.DestoryWand()
		tran.SetStatus(err)
		tran.Complete()
	}()
	this.Logo.CreateWand()
	if this.Location == 0 {
		this.Location = 9
	}
	if this.Location < 1 || this.Location > 9 {
		err = errors.New("Logo location(" + string(this.Location) + ") isn't right!")
		return err
	}
	var x, y int64
	x, y, err = getLocation(this.Location, img, this.Logo)
	if err != nil {
		return err
	}

	if this.Dissolve > 0 && this.Dissolve < 100 {
		this.Logo.Dissolve(this.Dissolve)
	}

	err = img.Composite(this.Logo, x, y)
	return err
}