fixed import_image not generating in CLI

This commit is contained in:
TomTkacz
2025-03-10 20:34:23 -05:00
parent fa25da3d39
commit f9aa4f9577
2 changed files with 7 additions and 1 deletions
+1
View File
@@ -408,6 +408,7 @@ public:
Image generate(const Options&) const override;
bool operator == (const GeneratedImage& that) const override;
inline String toString() { return filepath; }
inline String ExternalImage::toCode() const override { return "<image>"; }
private:
String filepath;
};
+6 -1
View File
@@ -19,6 +19,7 @@
#include <data/format/formats.hpp>
#include <gfx/generated_image.hpp>
#include <render/symbol/filter.hpp>
#include <cli/text_io_handler.hpp> // for MSE_CLI
void parse_enum(const String&, ImageCombine& out);
@@ -45,8 +46,12 @@ SCRIPT_FUNCTION(to_card_image) {
}
SCRIPT_FUNCTION(import_image) {
SCRIPT_PARAM(Set*, set);
SCRIPT_PARAM(String, path);
return make_intrusive<ExternalImage>(path);
auto extImg = make_intrusive<ExternalImage>(path);
if (cli.haveConsole()) // makes sure generate() is called, but only once, when using the CLI
extImg->generate(GeneratedImage::Options(0, 0, set->stylesheet.get(), set));
return extImg;
}
// ----------------------------------------------------------------------------- : Image functions