>> And the most important is that I don’t want to know it and specify its size in the code because it can change in the future.
Catch-22. This is the source of your “problem”, which will persist in one form or another for as long as you force yourself to wear blinders.
In other words (as i said, as rob said) you (seem to) have access to all the information you need, but just refuse to use it, instead preferring to load images at run-time to rediscover that info, then ‘wishing’ there were some way you didn’t have to do so.
So why not build an “asset catalog” (you could even write a bit of lua as a dev-time utility to scan your files and produce it for you if you wanted), something like (just for ideas):
local assetCatalog = { ["image1.png"] = { w=210, h=190 }, ["image2.png"] = { w=100, h=100 }, -- etc } local cat = assetCatalog["image1.png"] print(cat.w, cat.h)
Then you could “look up” image dimensions as you wish. Sure, you’d have to regenerate your catalog if/when your assets change, but that’s a small price to pay at development-time to avoid a bigger price at run-time.