Help:Making Icon Images

From Starbounder - Starbound Wiki
Jump to: navigation, search

This guide covers the details of making icons for the {{Itembox}}. This is a valuable part of any item page, even for bare-bone stubs, and should be among the first things contributed to an item-page.

Basics

This guide assumes the reader has operational knowledge of their choice of image editing program, focusing instead on methods than detailed steps.

  1. Locate the icon image in question
    Here is a guide on unpacking game assets
    Raw game icons are 16×16px, and are in itemnameicon.png format
  2. Double the size of the icon to 32×32px
    Here is a guide on resizing game sprites properly
  3. Expand your image to 36×36px around your sprite without resizing it
    The steps and terms for this vary on program
  4. Insert the rarity-appropriate border behind the sprite
    Paste in the border image from below
  5. In necessary, adjust the sprite to align with the border's larger pixel grid
  6. Optimize your newly created icon to an indexed GIF or PNG format
    Here is a guide for optimizing pixel-art
    PNG images are the stylistic standard on this wiki for non-animated images
    Lower case file extensions are the stylistic standard on this wiki, and should always be used
  7. Save your image in Page_Name_Icon format (very important!)
    If properly optimized, your new icon should be smaller than 500 bytes
    Be sure to save with transparency
  8. Upload your new icon to the wiki
    Here is a guide on uploading images to this wiki
    Be sure the image is uploaded with the correct file name!

Borders


These borders are available in game, but as of Upbeat Giraffe their use is not known.

Advanced: Creating Item Icons with ImageMagick

ImageMagick is a powerful command-line tool, which can be used to batch process huge numbers of image files. The command-line options are quite complex, though, often leading to a "trial and error" approach to achieve the desired effect. This short guide is here to reduce the number of "trails". Some basic command-line familiarity is required, nonetheless.

ImageMagick installation

Windows installers (and portables) can be found here: https://www.imagemagick.org/script/download.php. For Linux users, imagemagick is usually available via the package manager, e.g. apt-get install imagemagick.

Setup

So, we are trying to put the border icons into the background of several item icons. The item icons can be found in the unpacked game files. A guide for unpacking the game files can be found here: Modding:Basics#Step 1 - Unpacking Assets.

Let's assume we have the following directory structure: STARBOUND_DIRECTORY/assets/unpacked/.

Then the border icons can be found in assets/unpacked/interface/inventory/. They have a transparent background, so we'll need assets/unpacked/interface/inventory/empty.png as a background image. (The blueprint icon is here: assets/unpacked/items/generated/blueprint.png.)

Next, we'll create a short script which does the actual processing.

Scripts

Here's a short overview over the ImageMagick command-line call:

magick -background none
       INPUT_DIRECTORY/*.png null: ( BACKGROUND_IMG BORDER_IMG -flatten )
       -gravity center -extent 18x18 
       -compose dst-over -layers composite
       -interpolate nearest -filter point -resize 36x36
       -strip
       -set filename:out OUTPUT_DIRECTORY/%t
       %[filename:out].png

This command combines the background and border images and puts them behind each PNG file in the INPUT_DIRECTORY, and scales the result up to 36×36 pixels (twice the size). The created images will be written into the OUTPUT_DIRECTORY. The -strip option removes all metadata, which brings the (average) file size down to less than 500 Bytes. The -layers composite option does the main work; it might be a good idea to read the documentation for it.

For older version of ImageMagick (< 7.x.x, I think), the magick command-line tool might not be available, and convert has to be used instead.

The next sections show some actual usable scripts.

Windows, Batch

@echo off

setlocal

if "%~3"=="" (
	echo Usage: %~nx0 INPUT_DIRECTORY BORDER_TYPE OUTPUT_DIRECTORY
	exit /b 1
)

set starbound_directory=C:\Replace\this\with\the\path\to\your\Stabound\folder

set input_directory=%starbound_directory%\assets\unpacked\%1
set border_type=%2
set output_directory=%3

set background="%starbound_directory%\assets\unpacked\interface\inventory\empty.png"

if /i "%border_type%"=="blueprint" (
	set border="%starbound_directory%\assets\unpacked\items\generated\blueprint.png"
) else (
	set border="%starbound_directory%\assets\unpacked\interface\inventory\itemborder%border_type%.png"
)

magick -background none ^
       "%input_directory%\*.png" null: ( %background% %border% -flatten ) ^
	-gravity center -extent 18x18 ^
	-compose dst-over -layers composite ^
	-interpolate Nearest -filter point -resize 36x36 ^
	-strip ^
	-set filename:out "%output_directory%\\%%t-%border_type%-icon" ^
	%%[filename:out].png

Save this as a batch file, e.g. create_icons.bat and call it via the Windows command prompt (cmd).

Usage example: create_icons.bat items\generic\mechparts\body blueprint imagemagick_out

This will create blueprint icons for all Mech body parts and place them in the folder imagemagick_out (which has to be created beforehand.)

Linux, Bash

#!/bin/bash

starbound_directory="/replace/this/with/the/path/to/your/Starbound/folder"

input_directory="$starbound_directory/assets/unpacked/$1"
border_type=$2
output_directory=$3

if [ "$#" -ne 3 ]; then
	echo Usage $0 INPUT_DIRECTORY BORDER_TYPE OUTPUT_DIRECTORY
	exit 1
fi

background="$starbound_directory/assets/unpacked/interface/inventory/empty.png"

case $border_type in 
	blueprint) border="$starbound_directory/assets/unpacked/items/generated/blueprint.png" ;;
	*) border="$starbound_directory/assets/unpacked/interface/inventory/itemborder${border_type}.png"
esac

magick -background none \
       "$input_directory/*.png" null: \( "$background" "$border" -flatten \) \
	-gravity center -extent 18x18 \
	-compose dst-over -layers composite \
	-interpolate Nearest -filter point -resize 36x36 \
	-strip \
	-set filename:out "$output_directory/%t-$border_type-icon" \
	%[filename:out].png

Save this a a shell script, e.g. create_icons.sh and call it via terminal. Don't forget to make it executable with chmod u+x create_icons.sh.

Usage example: ./create_icons.sh items/generic/produce legendary icons_out

This will put the legendary (purple) background behind all produce icons, and put them into the icons_out folder (which has to be created beforehand).