diff --git a/doc/changelog.dox b/doc/changelog.dox index 4fc170535..ab5e20836 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -45,6 +45,9 @@ See also: - For better usability, the @ref magnum-imageconverter "magnum-imageconverter" utility now prints available importer/converter plugins when loading a plugin fails +- @ref magnum-imageconverter "magnum-imageconverter" can save raw imported + data instead of going through a converter plugins if you specify + `--converter raw` @section changelog-2019-10 2019.10 diff --git a/src/Magnum/Trade/imageconverter.cpp b/src/Magnum/Trade/imageconverter.cpp index cc10e5168..96a2697a4 100644 --- a/src/Magnum/Trade/imageconverter.cpp +++ b/src/Magnum/Trade/imageconverter.cpp @@ -81,6 +81,14 @@ Arguments: - `-c`, `--converter-options key=val,key2=val2,…` --- configuration options to pass to the converter +Specifying `--converter raw` will save raw imported data instead of using a +converter plugin. + +The `-i` / `--importer-options` and `-c` / `--converter-options` arguments +accept a comma-separated list of key/value pairs to set in the importer / +converter plugin configuration. If the `=` character is omitted, it's +equivalent to saying `key=true`. + @section magnum-imageconverter-example Example usage Converting a JPEG file to a PNG: @@ -145,6 +153,9 @@ int main(int argc, char** argv) { .addOption('c', "converter-options").setHelp("converter-options", "configuration options to pass to the converter", "key=val,key2=val2,…") .setGlobalHelp(R"(Converts images of different formats. +Specifying --converter raw will save raw imported data instead of using a +converter plugin. + The -i / --importer-options and -c / --converter-options arguments accept a comma-separated list of key/value pairs to set in the importer / converter plugin configuration. If the = character is omitted, it's equivalent to saying @@ -161,6 +172,24 @@ key=true.)") return 1; } + /* Set options, if passed */ + setOptions(*importer, args.value("importer-options")); + + /* Open input file */ + Containers::Optional image; + if(!importer->openFile(args.value("input")) || !(image = importer->image2D(0))) { + Error() << "Cannot open file" << args.value("input"); + return 3; + } + + Debug() << "Converting image of size" << image->size() << "and format" << image->format() << "to" << args.value("output"); + + /* Save raw data, if requested */ + if(args.value("converter") == "raw") { + Utility::Directory::write(args.value("output"), image->data()); + return 0; + } + /* Load converter plugin */ PluginManager::Manager converterManager{ args.value("plugin-dir").empty() ? std::string{} : @@ -172,18 +201,8 @@ key=true.)") } /* Set options, if passed */ - setOptions(*importer, args.value("importer-options")); setOptions(*converter, args.value("converter-options")); - /* Open input file */ - Containers::Optional image; - if(!importer->openFile(args.value("input")) || !(image = importer->image2D(0))) { - Error() << "Cannot open file" << args.value("input"); - return 3; - } - - Debug() << "Converting image of size" << image->size() << "and format" << image->format() << "to" << args.value("output"); - /* Save output file */ if(!converter->exportToFile(*image, args.value("output"))) { Error() << "Cannot save file" << args.value("output");