From add85f4c6d5dd1730491b76d0625b90e1ca1abbf Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 8 Dec 2025 20:21:36 +0100 Subject: [PATCH] Add new Lua function to query size of an image --- ext/ghoul | 2 +- src/engine/openspaceengine.cpp | 1 + src/engine/openspaceengine_lua.inl | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index 50315734cb..90240b2d5b 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 50315734cb1f3f5bd2fbfb60d599bccdfc2e8262 +Subproject commit 90240b2d5bda2c910ea04c29bc9d4210dbd339b4 diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 695cf04c9f..1b708175ec 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1738,6 +1738,7 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() { codegen::lua::RemoveTag, codegen::lua::DownloadFile, codegen::lua::CreateSingleColorImage, + codegen::lua::ImageSize, codegen::lua::SaveBase64File, codegen::lua::IsMaster, codegen::lua::Version, diff --git a/src/engine/openspaceengine_lua.inl b/src/engine/openspaceengine_lua.inl index 305450178c..5d880c6dd5 100644 --- a/src/engine/openspaceengine_lua.inl +++ b/src/engine/openspaceengine_lua.inl @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -209,6 +210,16 @@ namespace { return fileName; } +/** + * This function returns the size in pixels of an image file. + * + * \param path The location of the image file for which the pixel size will be returned + * \return The size of the image in pixels + */ +[[codegen::luawrap]] glm::ivec2 imageSize(std::filesystem::path path) { + return ghoul::io::TextureReader::ref().imageSize(path); +} + /** * This function takes a base64 encoded data string, decodes it and saves the resulting * data to the provided filepath.