playdate.graphics.image:getSize is returning a single value (not a w/h pair)

Using SDK 1.12.0

Problem: playdate.graphics.image:getSize() and playdate.graphics.imageSizeAtPath(path) seem to return only a single integer value.

Explanation:
I've tried both playdate.graphics.image:getSize() and playdate.graphics.imageSizeAtPath(path) but both exhibit the behavior. The getSize call returns what just appears to be the width of the image. Happy to send along the image if it's image specific.

Sample code:
function main()
local image = playdate.graphics.image.new("resources/images/splash.png")
if image ~= nil then
local size = image:getSize()
local w = size.width -- CRASH HERE
end
end

Try this:

local w, h = myImage:getSize()

Ah, thank you! That wasn't a Lua syntax I was familiar with. Happy to learn something new!

1 Like