PSD (Photoshop, Krita, Gimp...) -> Godot.

Overview

limage v0.2.2

Features Getting Started Tags Settings Todo Customizer Changes Solutions

WARNING: Requires Python to be installed

PSD (Photoshop, Krita, Gimp...) -> Godot.

Example files included. You can delete everything outside the "addons" folder.

Design in your prefered art tool. How you lay it out is how you get it out!
layers1 layers3
Draw origins + spawn points to make life easier.
points1 points2

Auto generate convenient code.

layers2

Tell Godot what kind of node you want the layer to be.
node1 node2

Auto polygon scene generator (WIP)

polygons

Features

  • Convert PSD to images + layer info.
  • Auto-generate scene where layer positions, visibility, and opacity are preserved in Godot.
  • Add origins to make rotations easier.
  • Many image formats, like WEBP.
  • Scale, quantize, and optimize images.
  • Images auto cropped to minimum size.
  • Optionally merge layers at build time, so they can stay seperate in your psd.
  • Only builds if there were changes.
  • Helper scripts:
    • Button: Pixel perfect sprite clicking, without a mask. (Sprite can scale + rotate!).
    • Customizer: Script generator for customizable content.
    • Cursorize: Call set_layer_as_cursor("layer_name") to set any layer as the cursor. (Will use origin to offset).
  • Polygon generator. (WIP! see Tags)

Getting Started

pip3 install psd-tools
  • Create a layered_images folder in Godot. res://layered_images.
  • Add .psd files. (Krita and Gimp can export .psd)
  • Activate the plugin. (Project > Project Settings > Plugins > Limage)
  • Click Limage at top of screen. (next to 2D, 3D, Script, Asset Lib)
  • Click generate.
  • The textures will be placed in a textures folder, and the data in a data folder.

Populating Scene

  • Create a scene in Godot.
  • Add LimageNode.gd script to it.
  • Drag data/name-of-your-psd .tres into the limage field.
  • Click the force_update toggle twice.

That should work. You could remove the LimageNode.gd if you like.

Every time you double click force_update it will update. Useful if you made changes. But it won't delete nodes. You can manually delete all the children to clear, and do a fresh generation.

Tags

Add tags in layer names, between []: layer_name [tag_1 tag2 tag-3]

Use () to set tags for all children. layer_group [tag1] (tag2 tag3)

Use (()) to set tags for all descendants. buttons ((button))

Tags can have values: background [parallax=10] which you can then get in Godot with limage.get_layer("background").tags.get("parallax").

  • x: Completely ignore layer. (Wont export image or layer info.)
  • visible: Will make layer visible, regardless of it's state in the psd.
  • !visible: ^
  • point: Won't generate an image, but will create an empty node in the scene. Useful for spawn points.
  • origin: Sets the origin of the parent group. If no parent, sets the global origin.
  • poly: (WIP!) Will generate a polygon scene. (Requires opencv-python and numpy)
  • button: Makes a clickable sprite button.
  • node: Tells Godot what node to use. my_light [node=Light2D]

These tags can be used on group layers.

  • origins: Children will be treated as points and used for layer origins, for easier rotations + scaling.
  • merge: "Flatten" children into one image.
  • options: Treat children as options for a sprite. (good for customizable objects.)
  • toggles: Treat children as optional child sprites that will be added/removed if enabled/disabled.

Settings

Export settings can be tweaked by including a json file next to the psd, with an identical name.

So next to layered_images/my_picture .psd include layered_images/my_picture .json with your settings.

# default settings
"path": "",						# location of psd if not in directory. (not implemented yet)
"seperator": "-",				# change to "/" and images will be stored in subfolders instead.

"texture_dir": None,			# if set, saves textures here
"data_dir": "data",				# if set, saves layer data here

# rescale textures
"scale": 1,

# in range of 0.0 - 1.0. makes rotation + flipping easier.
# creating a layer with an "origin" tag will replace this. 
"origin": [0, 0],

# you can choose any image format pillow + Godot support.
# but PNG, WEBP, and JPG are probably the most common.
# https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html
# https://docs.godotengine.org/en/stable/getting_started/workflow/assets/importing_images.html
"format": "WEBP", # WEBP can be A LOT smaller than png. and Godot supports it.

# can really decrease file size, but at cost of color range.
# https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.quantize
"quantize": False,

# default texture format settings
"PNG": {
	"optimize": True,
},

"WEBP": {
	"lossless": True,
	"method": 3,
	"quality": 80
},

"JPEG": {
	"optimize": True,
	"quality": 80
}

Todo

  • Better documentation.
  • Finalize polygon generator.
  • Normal map generation.
  • Blend mode shaders.
  • Optional padding for textures.
  • Text placement + preservation. (I only work with krita, which doesn't preserve text info when converting to psd.)

Customizer

If you include an options or toggles tag in any layer, a Godot script will be generated to make layer manipulation easier.

You can then replace LimageNode.gd with it.

You should override this rather than add code to it, as it will be replaced when regenerating.

Changes

0.2.2

  • Added node tag, so you can tell Godot what Node to use.
  • LimageNode now properly uses local coordinates, so it can be a child, rotated, scaled, without problems.
  • LimageNode options and toggles fields now work in editor more stabily.
  • LimageNode toggles initial visibility is fixed.

0.2.1

  • Editor should reload files properly now.

0.2

  • Saving + loading should work better on Windows.
  • Fixed merge tag still generating child textures.
  • Fixed JPEG error because of no alpha channel.
  • Fixed polygon generation not working with some image formats.
  • If settings file is changed, image will be rebuilt.

Solutions

WEBP

If WEBP exporting isn't working, try installing, reinstalling, or updating PILLOW, and/or libwebp:

On Ubuntu:

sudo apt-get install -y libwebp-dev
You might also like...
Python library for parsing Godot scene files

Godot Parser This is a python library for parsing Godot scene (.tscn) and resource (.tres) files. It's intended to make it easier to automate certain

Owner
null
GIMP script to export bitmap as GRAPHICS 4 file (aka SCREEN 5)

gimpfu-msx-gr4.py GIMP script to export bitmap as GRAPHICS 4 file (aka SCREEN 5). GRAPHICS 4 specs are: 256x212 (or 256x192); 16 color palette (from 5

Pedro de Medeiros 4 Oct 17, 2022
Python-fu-cartoonify - GIMP plug-in to turn a photo into a cartoon.

python-fu-cartoonify GIMP plug-in to turn a photo into a cartoon. Preview Installation Copy python-fu-cartoonify.py into the plug-in folder listed und

Pascal Reitermann 6 Aug 5, 2022
Apply a perspective transformation to a raster image inside Inkscape (no need to use an external software such as GIMP or Krita).

Raster Perspective Apply a perspective transformation to bitmap image using the selected path as envelope, without the need to use an external softwar

s.ouchene 19 Dec 22, 2022
A pure python implementation of the GIMP XCF image format. Use this to interact with GIMP image formats

Pure Python implementation of the GIMP image formats (.xcf projects as well as brushes, patterns, etc)

FHPyhtonUtils 8 Dec 30, 2022
Convert Photoshop curves (acv) to xmp presets for Lightroom

acv2xmp Convert Photoshop curves (acv) to Lightroom preset (xmp) acv2xmp.py Basic command prompt that relies on standard library only and can be used

null 5 Feb 6, 2022
Some ideas and tools to develop Python 3.8 plugins for GIMP 2.99.4

gimp-python-development Some ideas and tools to develop Python 3.8 plugins for GIMP 2.99.4. GIMP 2.99.4 is the latest unstable pre-release of GIMP 3.

Ismael Benito 53 Sep 25, 2022
Tracy Profiler module for the Godot Engine

GodotTracy Tracy Profiler module for the Godot Engine git clone --recurse-submodules https://github.com/Pineapple/GodotTracy.git Copy godot_tracy fold

Pineapple Works 17 Aug 23, 2022
This is a Blender 2.9 script for importing mixamo Models to Godot-3

Mixamo-To-Godot This is a Blender 2.9 script for importing mixamo Models to Godot-3 The script does the following things Imports the mixamo models fro

null 8 Sep 2, 2022
GIMP script to export bitmap as GRAPHICS 4 file (aka SCREEN 5)

gimpfu-msx-gr4.py GIMP script to export bitmap as GRAPHICS 4 file (aka SCREEN 5). GRAPHICS 4 specs are: 256x212 (or 256x192); 16 color palette (from 5

Pedro de Medeiros 4 Oct 17, 2022
Python-fu-cartoonify - GIMP plug-in to turn a photo into a cartoon.

python-fu-cartoonify GIMP plug-in to turn a photo into a cartoon. Preview Installation Copy python-fu-cartoonify.py into the plug-in folder listed und

Pascal Reitermann 6 Aug 5, 2022