我正在尝试使用以下代码在 32 位 ubuntu 上将字符串转换为 uint。但是它总是在 uint64 中转换它,尽管在函数中显式地传递了 32 作为参数。下面的代码mw是image magick库的对象。uint当mw.getImageWidth()和mw.getImageHeight()被调用时返回。此外,它接受resize函数中的uint类型参数。
width := strings.Split(imgResize, "x")[0]
height := strings.Split(imgResize, "x")[1]
var masterWidth uint = mw.GetImageWidth()
var masterHeight uint = mw.GetImageHeight()
mw := imagick.NewMagickWand()
defer mw.Destroy()
err = mw.ReadImageBlob(img)
if err != nil {
log.Fatal(err)
}
var masterWidth uint = mw.GetImageWidth()
var masterHeight uint = mw.GetImageHeight()
wd, _ := strconv.ParseUint(width, 10, 32)
ht, _ := strconv.ParseUint(height, 10, 32)
if masterWidth < wd || masterHeight < ht {
err = mw.ResizeImage(wd, ht, imagick.FILTER_BOX, 1)
if err != nil {
panic(err)
}
}
错误是:
# command-line-arguments
test.go:94: invalid operation: masterWidth < wd (mismatched types uint and uint64)
goImageCode/test.go:94: invalid operation: masterHeight < ht (mismatched types uint and uint64)
goImageCode/test.go:100: cannot use wd (type uint64) as type uint in argument to mw.ResizeImage
goImageCode/AmazonAWS.go:100: cannot use ht (type uint64) as type uint in argument to mw.ResizeImage
慕码人8056858
相关分类