fix(image): better cell size calculation for non-HDPI displays

This commit is contained in:
Folke Lemaitre 2025-02-19 15:07:27 +01:00
parent 4e13b24e99
commit e146a66cb7
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 5 additions and 5 deletions

View file

@ -117,9 +117,9 @@ local defaults = {
---@type table<string,snacks.image.args>
magick = {
default = { "{src}[0]", "-scale", "1920x1080>" }, -- default for raster images
vector = { "-density", 300, "{src}[0]" }, -- used by vector images like svg
math = { "-density", 300, "{src}[0]", "-trim" },
pdf = { "-density", 300, "{src}[0]", "-background", "white", "-alpha", "remove", "-trim" },
vector = { "-density", 192, "{src}[0]" }, -- used by vector images like svg
math = { "-density", 192, "{src}[0]", "-trim" },
pdf = { "-density", 192, "{src}[0]", "-background", "white", "-alpha", "remove", "-trim" },
},
},
}

View file

@ -39,8 +39,8 @@ end
---@return snacks.image.Size
function M.norm(size)
return {
width = math.max(1, math.floor(size.width + 0.5)),
height = math.max(1, math.floor(size.height + 0.5)),
width = math.max(1, math.ceil(size.width)),
height = math.max(1, math.ceil(size.height)),
}
end