本文整理汇总了Golang中github.com/ctripcorp/nephele/imgsvr/img4g.Image.DigitalWatermark方法的典型用法代码示例。如果您正苦于以下问题:Golang Image.DigitalWatermark方法的具体用法?Golang Image.DigitalWatermark怎么用?Golang Image.DigitalWatermark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ctripcorp/nephele/imgsvr/img4g.Image
的用法示例。
在下文中一共展示了Image.DigitalWatermark方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Process
func (this *DigitalWatermarkProcessor) Process(img *img4g.Image) error {
log.Debug("process digitalwatermark")
var err error = nil
format, err := img.GetFormat()
if err != nil {
return err
}
if strings.ToLower(format) != "jpg" && strings.ToLower(format) != "jpeg" {
info := make(map[string]string)
info["format"] = format
logEvent(this.Cat, "DigitalWatermarkRefuse", "NotSupportFormat", info)
return nil
}
width, err := img.GetWidth()
if err != nil {
return err
}
if width < 256 {
info := make(map[string]string)
info["width"] = strconv.Itoa(int(width))
logEvent(this.Cat, "DigitalWatermarkRefuse", "NotSupportSize", info)
return nil
}
height, err := img.GetHeight()
if err != nil {
return err
}
if height < 256 {
info := make(map[string]string)
info["height"] = strconv.Itoa(int(height))
logEvent(this.Cat, "DigitalWatermarkRefuse", "NotSupportSize", info)
return nil
}
upr := ((int(math.Min(float64(width), float64(height))) / 100.0) + 1) * 100
tran := this.Cat.NewTransaction("DigitalWatermark", "Min(width, height)<"+strconv.Itoa(int(upr)))
tran.AddData("size", "width: "+strconv.Itoa(int(width))+"height: "+strconv.Itoa(int(height)))
defer func() {
this.Copyright.DestoryWand()
tran.SetStatus(err)
tran.Complete()
}()
if err = this.Copyright.CreateWand(); err != nil {
return err
}
err = img.DigitalWatermark(this.Copyright)
return err
}