mirror of
https://github.com/willnorris/imageproxy.git
synced 2024-12-16 21:56:43 -05:00
primitive: limit input image to 256 px
This commit is contained in:
parent
0d5d8aa202
commit
b951a9ccc3
1 changed files with 6 additions and 0 deletions
|
@ -322,10 +322,16 @@ func transformImage(m image.Image, opt Options) image.Image {
|
|||
func transformPrimitive(m image.Image, opt Options) *primitive.Model {
|
||||
// set size to the longest of height or width
|
||||
size := m.Bounds().Size().X
|
||||
o := Options{Width: 256}
|
||||
if h := m.Bounds().Size().Y; size < h {
|
||||
size = h
|
||||
o = Options{Height: 256}
|
||||
}
|
||||
|
||||
// scale image down to no larger than 256, which is all we need for the
|
||||
// primitive algorithm
|
||||
m = transformImage(m, o)
|
||||
|
||||
bg := primitive.MakeColor(primitive.AverageImageColor(m))
|
||||
model := primitive.NewModel(m, bg, size, runtime.NumCPU())
|
||||
for i := 0; i < opt.Primitive.Count; i++ {
|
||||
|
|
Loading…
Reference in a new issue