function Render.GetTextureSize(texture)
assert(type(texture) == "string")
local id = texture:gsub("[^%d]", "")
if sizeCache[id] ~= nil then
return sizeCache[id]
end
if RunService:IsServer() then
local ok, result = HttpPromise.json("https://image-size.eryn.io/image-size/"..id):Then(function(data)
if data.error then
return Promise.rejected("Encountered an error while retrieving image size")
else
return Vector2.new(data.width, data.height)
end
end, function(data)
return Promise.rejected(tostring(data))
end):Yield()
if ok then
sizeCache[id] = result
return result
else
warn(result)
return Vector2.new(0, 0)
end
elseif RunService:IsClient() then
local ok, result = pcall(getImageSize.InvokeServer, getImageSize, id)
if ok then
sizeCache[id] = result
return result
else
warn(tostring(result))
return Vector2.new(0, 0)
end
end
end
This function retrieves the actual size of a given image. Unfortunately, this relies on a web API that no longer works. Are there any other ways to get the size of an image?