Texture Management in Defold

Resize images

This post is a response to the post Scale factor in Atlas settings - #8 by dasannikov. I often see images that are too big - here are some of my workflows to resize the images.


Macs Automator

Mac has a powerful and under utilized tool called Automator. We can set that up to give us a quick context command to scale images in the finder.

Automator setup

Start the Automator and you will be greeted by a view to chose your type. We want a service, as that will be added to the context menu. Select it and pick Choose.

You will then see a empty view where we will build our workflow. In the Service receives selected [ ] in [ ] pick “image files” and “Finder” respectively.

Search for “scale”

Drag “Scale Image” into the workflow, switch to “By Percentage” and set a value you want, in my case I want to be able to scale down the images by 10% so say “Scale the image to 90%”. Then simply save it by doing “File” → “Save”.

I named mine “Scale down 10%”, you can now right click on a image and find the resize option under “Services”

Resize all images in an atlas

I have a script that I use myself if I decide I want to resize all images in an atlas by a certain percentage. It have a couple of dependencies - DefTree to parse the Defold files (atlas) and Pillow to resize the image.
pip install deftree and pip install Pillow

Usage: python resize_atlas.py --root "path/to/project" --atlas "path/to/project/atlases/game.atlas" -p 10

Using Image Magick

If I want to resize a folder of images I would use ImageMagicks mogrify command. Simply open a terminal/command line window and cd to the texture folder and then run.
mogrify -resize 90% *.png

Using 3d party applications on Windows

Windows doesn’t have Automator so to add a right click resize option we can use something like Image Resizer.

The standard image viewer in any OS always leaves a bit to be desired, on Windows I have used Irfanview for years and you are able to resize images directly in that. Though, because I already have a lot of other ways to do this (mainly mogrify), I have never used it myself.

12 Likes