status-go/images/meta.go

61 lines
1.6 KiB
Go

package images
const (
UNKNOWN ImageType = 1 + iota
// Raster image types
JPEG
PNG
GIF
WEBP
)
const (
MaxJpegQuality = 80
MinJpegQuality = 50
smallDim = ResizeDimension(80)
largeDim = ResizeDimension(240)
smallDimName = "thumbnail"
largeDimName = "large"
)
var (
// ResizeDimensions list of all available image resize sizes
ResizeDimensions = []ResizeDimension{smallDim, largeDim}
// DimensionSizeLimit the size limits imposed on each resize dimension
// Figures are based on the following sample data https://github.com/status-im/status-react/issues/11047#issuecomment-694970473
DimensionSizeLimit = map[ResizeDimension]DimensionLimits{
smallDim: {
Ideal: 2560, // Base on the largest sample image at quality 60% (2,554 bytes ∴ 1024 * 2.5)
Max: 5632, // Base on the largest sample image at quality 80% + 50% margin (3,683 bytes * 1.5 ≈ 5500 ∴ 1024 * 5.5)
},
largeDim: {
Ideal: 16384, // Base on the largest sample image at quality 60% (16,143 bytes ∴ 1024 * 16)
Max: 38400, // Base on the largest sample image at quality 80% + 50% margin (24,290 bytes * 1.5 ≈ 37500 ∴ 1024 * 37.5)
},
}
// ResizeDimensionToName maps a ResizeDimension to its assigned string name
ResizeDimensionToName = map[ResizeDimension]string{
smallDim: smallDimName,
largeDim: largeDimName,
}
// NameToResizeDimension maps a string name to its assigned ResizeDimension
NameToResizeDimension = map[string]ResizeDimension{
smallDimName: smallDim,
largeDimName: largeDim,
}
)
type DimensionLimits struct {
Ideal int
Max int
}
type ImageType uint
type ResizeDimension uint