diff options
| author | Fuwn <[email protected]> | 2024-05-20 21:10:10 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-05-20 21:10:10 +0000 |
| commit | 54244a81cd8df525074f4a0ef123f7b80f5696c9 (patch) | |
| tree | 2ddc70c1e0bc615201c38f701f235144c02ad1e9 | |
| parent | refactor(image): deduce extension from information (diff) | |
| download | mayu-54244a81cd8df525074f4a0ef123f7b80f5696c9.tar.xz mayu-54244a81cd8df525074f4a0ef123f7b80f5696c9.zip | |
refactor(image): cleaner return value
| -rw-r--r-- | src/image.gleam | 14 | ||||
| -rw-r--r-- | src/svg.gleam | 3 |
2 files changed, 4 insertions, 13 deletions
diff --git a/src/image.gleam b/src/image.gleam index c1ba7cf..a418ed8 100644 --- a/src/image.gleam +++ b/src/image.gleam @@ -21,19 +21,11 @@ pub fn get_image_information(image) { _rest:bits, >> -> Ok(ImageInformation( - width_0 - |> int.bitwise_or( - width_1 - |> int.bitwise_shift_left(8), - ), - height_0 - |> int.bitwise_or( - height_1 - |> int.bitwise_shift_left(8), - ), + int.bitwise_or(width_0, int.bitwise_shift_left(width_1, 8)), + int.bitwise_or(height_0, int.bitwise_shift_left(height_1, 8)), "gif", )) - _ -> Error("Invalid PNG signature") + _ -> Error("Unsupported image format") } } diff --git a/src/svg.gleam b/src/svg.gleam index 3e0340d..b36a88d 100644 --- a/src/svg.gleam +++ b/src/svg.gleam @@ -38,7 +38,7 @@ fn images(theme, digits, width, height, svgs) { }, ) { - Ok(data) -> { + Ok(data) -> case image.get_image_information(data) { Ok(information) -> images( @@ -50,7 +50,6 @@ fn images(theme, digits, width, height, svgs) { ) Error(_) -> XmlImages(string_builder.to_string(svgs), width, height) } - } Error(_) -> XmlImages(string_builder.to_string(svgs), width, height) } } |