A way to get image size from a file

Things that we aren't going to implement
Post Reply
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2919
Joined: Sat Jun 11, 2016 6:41 am
Contact:

A way to get image size from a file

Post by Optera »

What?
A function to check dimensions directly from a png during data stage.

Why?
I have icons of different sizes and would like to automatically set icon.size and icon.mipmaps according to png dimensions.
Currently I can get away with smart sorting and deriving that information from the path with lookup tables.

Factorio already loads and checks dimensions of files designated by icon, sprite.filename, asf so there shouldn't be an added security issue exposing the function like

Code: Select all

local width, height = get_sprite_dimensions(filename)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13248
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: A way to get image size from a file

Post by Rseding91 »

Factorio only loads an image once when the game starts *after* all data stage has been finished and all final image file paths are provided and deduplicated. If that existed it would have to load it every time that line was executed - and would have to - in the middle of parsing data go check if that image exists on disk, load it, process it into RAM, check the dimensions, and then throw it all out.

That's just never going to happen. That's why the size has to be given through lua.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Won't implement”