MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / fixWebpSize

Function fixWebpSize

processing/fix_size.go:20–38  ·  view source on GitHub ↗
(img *vips.Image)

Source from the content-addressed store, hash-verified

18)
19
20func fixWebpSize(img *vips.Image) error {
21 webpLimitShrink := float64(max(img.Width(), img.Height())) / webpMaxDimension
22
23 if webpLimitShrink <= 1.0 {
24 return nil
25 }
26
27 scale := 1.0 / webpLimitShrink
28 if err := img.Resize(scale, scale); err != nil {
29 return err
30 }
31
32 slog.Warn(fmt.Sprintf(
33 "WebP dimension size is limited to %d. The image is rescaled to %dx%d",
34 int(webpMaxDimension), img.Width(), img.Height(),
35 ))
36
37 return nil
38}
39
40func fixHeifSize(img *vips.Image) error {
41 heifLimitShrink := float64(max(img.Width(), img.Height())) / heifMaxDimension

Callers 1

fixSizeMethod · 0.85

Calls 4

ResizeMethod · 0.80
WarnMethod · 0.80
WidthMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected