Skip to content

Commit 7bf0258

Browse files
authored
Add temp image validation for CI (#26)
1 parent 114398d commit 7bf0258

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pkg/validation/image.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ const (
1717
minH = 128
1818
)
1919

20+
// TODO: Fix all logos in "assets" and then we can use ValidatePngImageDimension in CI.
21+
// Old logo's have dimensions like 195x163, 60x60 and etc. This method is used only in CI.
22+
// ValidatePngImageDimensionForCI should be removed after logo's fixing.
23+
func ValidatePngImageDimensionForCI(file io.Reader) error {
24+
img, err := png.DecodeConfig(file)
25+
if err != nil {
26+
return fmt.Errorf("failed to decode image: %w", err)
27+
}
28+
29+
// TODO: If we fix all incorrect logos in assets repo, we could use "|| img.Width != img.Height" in addition.
30+
if img.Width > maxW || img.Height > maxH || img.Height < minH {
31+
return fmt.Errorf("%w: max - %dx%d, min - %dx%d; given %dx%d",
32+
ErrInvalidImgDimension, maxW, maxH, minW, minH, img.Width, img.Height)
33+
}
34+
35+
return nil
36+
}
37+
2038
func ValidatePngImageDimension(file io.Reader) error {
2139
img, err := png.DecodeConfig(file)
2240
if err != nil {

0 commit comments

Comments
 (0)