mirror of
https://github.com/likelovewant/ollama-for-amd.git
synced 2025-12-22 06:43:57 +00:00
refactor: use builtin max and min
This commit is contained in:
committed by
Michael Yang
parent
967a82f52f
commit
4a48937ef1
@@ -73,7 +73,7 @@ func (p ImageProcessor) bestResolution(img image.Point, possibleResolutions []im
|
|||||||
for i, res := range possibleResolutions {
|
for i, res := range possibleResolutions {
|
||||||
scaleW := float64(res.X) / float64(w)
|
scaleW := float64(res.X) / float64(w)
|
||||||
scaleH := float64(res.Y) / float64(h)
|
scaleH := float64(res.Y) / float64(h)
|
||||||
scale := math.Min(scaleW, scaleH)
|
scale := min(scaleW, scaleH)
|
||||||
|
|
||||||
scales[i] = scale
|
scales[i] = scale
|
||||||
}
|
}
|
||||||
@@ -124,11 +124,11 @@ func (p ImageProcessor) maxResolution(imageRes, targetRes image.Point) image.Poi
|
|||||||
if scaleW < scaleH {
|
if scaleW < scaleH {
|
||||||
newRes = image.Point{
|
newRes = image.Point{
|
||||||
targetRes.X,
|
targetRes.X,
|
||||||
int(math.Min(math.Floor(float64(imageRes.Y)*scaleW), float64(targetRes.Y))),
|
int(math.Floor(float64(imageRes.Y)*scaleW), float64(targetRes.Y))),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newRes = image.Point{
|
newRes = image.Point{
|
||||||
int(math.Min(math.Floor(float64(imageRes.X)*scaleH), float64(targetRes.X))),
|
int(min(math.Floor(float64(imageRes.X)*scaleH), float64(targetRes.X))),
|
||||||
targetRes.Y,
|
targetRes.Y,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func (p ImageProcessor) fitToCanvas(imageSize, canvasSize image.Point) image.Poi
|
|||||||
tw := min(max(imageSize.X, p.imageSize), canvasSize.X)
|
tw := min(max(imageSize.X, p.imageSize), canvasSize.X)
|
||||||
th := min(max(imageSize.Y, p.imageSize), canvasSize.Y)
|
th := min(max(imageSize.Y, p.imageSize), canvasSize.Y)
|
||||||
|
|
||||||
r := math.Min(
|
r := min(
|
||||||
float64(tw)/float64(imageSize.X),
|
float64(tw)/float64(imageSize.X),
|
||||||
float64(th)/float64(imageSize.Y),
|
float64(th)/float64(imageSize.Y),
|
||||||
)
|
)
|
||||||
@@ -89,10 +89,10 @@ func (p ImageProcessor) optimalTiledCanvas(imageSize image.Point) image.Point {
|
|||||||
if minUpscale == 0 {
|
if minUpscale == 0 {
|
||||||
minUpscale = s
|
minUpscale = s
|
||||||
} else {
|
} else {
|
||||||
minUpscale = math.Min(minUpscale, s)
|
minUpscale = min(minUpscale, s)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
maxDownscale = math.Max(maxDownscale, s)
|
maxDownscale = max(maxDownscale, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user