本文整理匯總了Golang中github.com/ctripcorp/nephele/imgsvr/img4g.Image.GetFormat方法的典型用法代碼示例。如果您正苦於以下問題:Golang Image.GetFormat方法的具體用法?Golang Image.GetFormat怎麽用?Golang Image.GetFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ctripcorp/nephele/imgsvr/img4g.Image
的用法示例。
在下文中一共展示了Image.GetFormat方法的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
}