本文整理匯總了Golang中github.com/gographics/imagick/imagick.MagickWand.RotateImage方法的典型用法代碼示例。如果您正苦於以下問題:Golang MagickWand.RotateImage方法的具體用法?Golang MagickWand.RotateImage怎麽用?Golang MagickWand.RotateImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gographics/imagick/imagick.MagickWand
的用法示例。
在下文中一共展示了MagickWand.RotateImage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: convert
func convert(mw *imagick.MagickWand, request *ZRequest) error {
fmt.Println("【zscale】:調用convert()方法......處理圖片參數")
var result error
result = nil
mw.ResetIterator()
mw.SetImageOrientation(imagick.ORIENTATION_TOP_LEFT)
x := request.X
y := request.Y
cols := uint(request.Width)
rows := uint(request.Height)
fmt.Sprintf("image cols %d, rows %d \n", cols, rows)
if !(cols == 0 && rows == 0) {
//fmt.Println("call crop&scal function......")
/* crop and scale */
if x == -1 && y == -1 {
// fmt.Println("call crop&scal function......")
// fmt.Print(fmt.Sprintf("proportion(im, %d, %d, %d) \n", request.Proportion, cols, rows))
result = proportion(mw, request.Proportion, cols, rows)
if result != nil {
return result
}
} else {
// fmt.Print(fmt.Sprintf("crop(im, %d, %d, %d, %d) \n", x, y, cols, rows))
result = crop(mw, x, y, cols, rows)
if result != nil {
return result
}
}
}
/* rotate image */
if request.Rotate != 0 {
// fmt.Print(fmt.Sprintf("wi_rotate(im, %d) \n", request.Rotate))
background := imagick.NewPixelWand()
if background == nil {
result = fmt.Errorf("init new pixelwand faile.")
return result
}
defer background.Destroy()
isOk := background.SetColor("#ffffff")
if !isOk {
result = fmt.Errorf("set background color faile.")
return result
}
result = mw.RotateImage(background, float64(request.Rotate))
if result != nil {
return result
}
}
/* set gray */
if request.Gary == 1 {
// fmt.Print(fmt.Sprintf("wi_gray(im) \n"))
result = mw.SetImageType(imagick.IMAGE_TYPE_GRAYSCALE)
if result != nil {
return result
}
}
/* set quality */
//fmt.Print(fmt.Sprintf("wi_set_quality(im, %d) \n", request.Quality))
result = mw.SetImageCompressionQuality(uint(request.Quality))
if result != nil {
return result
}
/* set format */
if "none" != request.Format {
// fmt.Print(fmt.Sprintf("wi_set_format(im, %s) \n", request.Format))
result = mw.SetImageFormat(request.Format)
if result != nil {
return result
}
}
//fmt.Print(fmt.Sprintf("convert(im, req) %s \n", result))
return result
}