Skip to content

importing as regular images (en)

nklbdev edited this page Aug 6, 2023 · 1 revision

Importing files as regular images

en ru

Each of the configured integrations can import the source files of the target application not only as special Godot resources, but also as regular images by integrating into the Godot import system using ImageFormatLoaderExtension.

But there are a lot of other graphic formats that cannot be imported as animations, but you would like to import them as regular images too. To do this, Importality has a built-in Custom Image Loader - an extension that allows you to import files with any extensions using external command line utilities. This opens up unlimited import possibilities, because any self-written scripts can be used as a utility.

To configure the Custom Image Loader open the Importality settings in Project Settings->General->Advanced Settings->Importality. Here you will find the settings line "Command Building Rules for Custom Image Loader". This setting is an array of strings. Increase the size of the array and enter your own rules for constructing commands.

Logo

Command building rules

Each command building rule has the following format:

<extension1> [<extension2>...]:<command_template>

The line starts with a list of extensions. You can list them separated by commas or/and spaces. They are followed by a colon character (:) followed by a command template. A command template is a regular string into which values can be inserted using tags:

  • {in_path} - full path to source file

  • {in_path_b} - full path to source file with backslash as delimiter (\)

  • {in_path_base} - full path to source file without extension

  • {in_path_base_b} - full path to source file without extension with backslash as delimiter (\)

  • {in_file} - source file name

  • {in_file_base} - source file name without extension

  • {in_dir} - full path to source file directory

  • {in_dir_b} - full path to source file directory with backslash as delimiter (\)

  • {in_ext} - source file extension

  • {out_path} - full path to the output temporary PNG image file, which will be read by the engine after the command is executed and deleted

  • {out_path_b} - full path to the output file with backslash as delimiter (\)

  • {out_path_base} - full path to the output file without extension

  • {out_path_base_b} - full path to the output file without extension with backslash as delimiter (\)

  • {out_file} - output file name

  • {out_file_base} - output file name without extension

  • {out_dir} - full path to source file directory

  • {out_dir_b} - full path to source file directory with backslash as delimiter (\)

  • {out_ext} - output file extension (png)

After configuring file extensions and command templates to process, you need to restart the plugin in order for it to recalculate all the extensions that it will process.

Before using the rule in a plugin, test the functionality of your command in the command line terminal.

If the command building rule is entered incorrectly, error messages will be displayed in the console. Read them carefully and correct the command building rule. If you're having trouble with this, create a ticket in this repository, and attach to it:

  • The original image file you would like to import
  • A line of command building rule for calling an external utility
  • Type and version of your operating system
  • Godot engine version
  • A link to the external utility that your command should call

Examples

There are many popular utilities for converting and modifying images. Here is an incomplete list:

To import a GIMP document (file with xcf extension) using ImageMagick, enter the following line (correct the path to the utility to match yours):

xcf: C:\Utils\imagemagick\convert.exe {in_path_b} {out_path_b}

To import a Paint.NET document (file with pdn extension) using pdn2png utility from CoolUtils' Total Image Converter, enter the following line (correct the path to the utility to match yours):

pdn: "C:\Program Files (x86)\CoolUtils\TotalImageConverter\pdn2png.exe" /outfile={out_path_b} {in_path_b}

Restrictions

Unfortunately, no utility was found that can convert PSD (Adobe PhotoShop Document) files to PNG with transparent background. They all make the background white. If you find one, please let us know, you will help the project a lot!

Clone this wiki locally