aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-05-20 14:10:10 -0700
committerFuwn <[email protected]>2024-05-20 14:10:10 -0700
commitd9b15c2858b70771e720f2b0606cefccc7feb92a (patch)
tree2ddc70c1e0bc615201c38f701f235144c02ad1e9 /src
parent5fd1d1b3d215ef5244476cc260fec9c6aecd994f (diff)
downloadmayu-d9b15c2858b70771e720f2b0606cefccc7feb92a.tar.xz
mayu-d9b15c2858b70771e720f2b0606cefccc7feb92a.zip
refactor(image): cleaner return value
Diffstat (limited to 'src')
-rw-r--r--src/image.gleam14
-rw-r--r--src/svg.gleam3
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)
}
}