github.com/status-im/status-go@v1.1.0/images/meta.go (about) 1 package images 2 3 const ( 4 UNKNOWN ImageType = 1 + iota 5 6 // Raster image types 7 JPEG 8 PNG 9 GIF 10 WEBP 11 ICO 12 ) 13 14 const ( 15 MaxJpegQuality = 80 16 MinJpegQuality = 50 17 18 SmallDim = ResizeDimension(80) 19 LargeDim = ResizeDimension(240) 20 21 BannerDim = ResizeDimension(800) 22 23 SmallDimName = "thumbnail" 24 LargeDimName = "large" 25 26 BannerIdentityName = "banner" 27 ) 28 29 var ( 30 // ResizeDimensions list of all available image resize sizes 31 ResizeDimensions = []ResizeDimension{SmallDim, LargeDim} 32 33 // DimensionSizeLimit the size limits imposed on each resize dimension 34 // Figures are based on the following sample data https://github.com/status-im/status-mobile/issues/11047#issuecomment-694970473 35 DimensionSizeLimit = map[ResizeDimension]FileSizeLimits{ 36 SmallDim: { 37 Ideal: 2560, // Base on the largest sample image at quality 60% (2,554 bytes ∴ 1024 * 2.5) 38 Max: 5632, // Base on the largest sample image at quality 80% + 50% margin (3,683 bytes * 1.5 ≈ 5500 ∴ 1024 * 5.5) 39 }, 40 LargeDim: { 41 Ideal: 16384, // Base on the largest sample image at quality 60% (16,143 bytes ∴ 1024 * 16) 42 Max: 38400, // Base on the largest sample image at quality 80% + 50% margin (24,290 bytes * 1.5 ≈ 37500 ∴ 1024 * 37.5) 43 }, 44 } 45 46 // ResizeDimensionToName maps a ResizeDimension to its assigned string name 47 ResizeDimensionToName = map[ResizeDimension]string{ 48 SmallDim: SmallDimName, 49 LargeDim: LargeDimName, 50 } 51 52 // NameToResizeDimension maps a string name to its assigned ResizeDimension 53 NameToResizeDimension = map[string]ResizeDimension{ 54 SmallDimName: SmallDim, 55 LargeDimName: LargeDim, 56 } 57 ) 58 59 type FileSizeLimits struct { 60 Ideal int 61 Max int 62 } 63 64 type ImageType uint 65 type ResizeDimension uint 66 67 func GetBannerDimensionLimits() FileSizeLimits { 68 return FileSizeLimits{ 69 Ideal: 307200, // We want to save space and traffic but keep to maximum compression 70 Max: 460800, // Can't go bigger than 450 KB 71 } 72 }