Tileset Resizer v2.5 Readme
09-01-2011
Tileset Resizer is a collection of Octave Functions designed to resize Dwarf Fortress tilesets with minimum loss of quality.
The included functions are
resize_tileset
resize_tileset_tilebytile
resize_tileset_hqx
resize_tileset_hqx_tilebytile
See Forum Thread
http://www.bay12forums.com/smf/index.php?topic=87196.0 for examples of resized tilesets.
Note:
All Tileset Resizer functions can now resize RGB images as well as RGB+Alpha images. resize_tileset and resize_tileset_tilebytile also support grayscale images.
Dwarf Fortress enforces a hardcoded display of a minimum of 80 tiles in the horizontal direction.
Because of this the maximum tile size (in pixels) that can be displayed on a monitor is calculated the following way.
Maximum Tile Size = (Monitor Horizontal Resolution In Pixels)/80
See
http://www.bay12forums.com/smf/index.php?topic=87196.msg2582949#msg2582949 (Reply #10) for more information.
Requirements
--Octave - a opensource alternative to MatLab a command line computaional mathematics library.
Windows
http://octave.sourceforge.net/index.htmlThe Windows executable installer is for Octave 3.2.4 which is over a year old (current version is 3.4.x).
The oct2mat package included in this installer has a bug which prevents Octave from reading image files.
Tileset Resizer functions now detect incompatible packages and deactivate them automatically.
The spline interpolation function included in this version of Octave may not work with all images.
Mac OS X
http://octave.sourceforge.net/index.htmlLinux
Most linux distributions have a octave package available
--The Octave Package "Image" is required.
You can check what packages you have installed with
pkg list
Windows/Mac OS X
The Package can be found here
http://octave.sourceforge.net/image/Refer to this page for installation instructions.
http://octave.sourceforge.net/FAQ.htmlLinux
Some linux distributions come with this packge installed or as a addon package for Octave
If this is not the case the package can be found here
http://octave.sourceforge.net/image/Octave must be run as a superuser to install packages.
Refer to this page for installation instructions.
http://octave.sourceforge.net/FAQ.htmlClose Octave with exit and then restart as a normal user after installing the package.
--hqx - hqx is required to use resize_tileset_hqx and resize_tileset_hqx_tilebytile
Windows
The windows executable can be downloaded from here.
http://code.google.com/p/hqx/The contents of the windows zip file should be extraced to the windows directory in Tileset_Resizer_v2.5_arclance
if this is done correctly the hqx.exe file should be in the directory
Tileset_Resizer_v2.5_arclance\windows\hqx\bin
Linux/Mac OS X
The hqx source code can be downloaded from here.
http://code.google.com/p/hqx/The contents of the source zip file should be extracted to the Tileset_Resizer_v2.5_arclance folder.
The source must then be compiled in this location.
Using Tileset Resizer
1. Copy the tileset you want to resize to the Tileset_Resizer_v2.5_arclance directory.
2. Start Octave
3. Change directory to the Tileset_Resizer_v2.5_arclance directory (cd pathto/Tileset_Resizer_v2.5_arclance)
4. run one of the resizing functions as shown in the following examples
--resize_tileset is the simplest and fastest resizing function, but it produces the most errors when resizing.
resize_tileset(file_name,file_type,tileset_x_dimensions,tileset_y_dimensions,tile_x_size,tile_y_size,interp)
file_name = filename without extstension. ex. 'Phoebus_16x16'
file_type = file extenstion without period. ex 'png'
tileset_x_dimensions = width in tiles of the tileset. ex. 16 Set to 1 to resize a single tile. (for unit sets get from [PAGE_DIM:x:y])
tileset_y_dimensions = height in tiles of the tileset. ex. 16 Set to 1 to resize a single tile. (for unit sets get from [PAGE_DIM:x:y])
tile_x_size = width in pixels to resize the tiles to. ex. 24 (for unit sets get from [TILE_DIM:x:y])
tile_y_size = height in pixels to resize the tiles to. ex. 24 (for unit sets get from [TILE_DIM:x:y])
interp = the type of interpolation to use when resizing. interp can be ('nearest','linear','bilinear','cubic','bicubic','pchip', or 'spline') only nearest is recomended for upsizing with resize_tileset
An example of the correct input for resizing the Phoebus tileset to have 24x24 tiles using resize_tileset is shown below
resize_tileset('Phoebus_16x16','png',16,16,24,24,'nearest')
Examples of how this will appear in Octave can be found in Tileset_Resizer_Example.txt.
This produces an output file named Phoebus_16x16_nearest_tileset_dimensions_16x16_tile_size_24x24_tileset_size_384x384_minimum_horizontal_resolution_1920.png in the Resized_Tilesets directory inside of the Tileset_Resizer_v2.5_arclance directory.
The name of the output file can be used to confirm that the desired tileset size was produced.
To use the output file as a tileset rename it to match original tileset file and replace the original file with the output file in your Dwarf Fortress install.
If resizing a Unit Graphics Set the line
[TILE_DIM:X:Y]
in the corresponding text file for that Unit Graphics Set must be changed to
[TILE_DIM:NEW_X:NEW_Y]
or the unit tiles will not appear properly resized (resulting in blurry dwarfs).
--resize_tileset_tilebytile breaks the tileset up into its individual tiles and resizes them individually before recombining them again. This is slower than resize_tileset but produces better results.
resize_tileset_tilebytile(file_name,file_type,tileset_x_dimensions,tileset_y_dimensions,tile_x_size,tile_y_size,interp)
The same inputs are used as with resize_tileset and the recomendations about what interp to use are the same as well.
--resize_tileset_hqx resizes the tileset using the hqx resizing algorithm. The results of this resizing method are significantly different than from resize_tileset, examples can be found on the forum thread.
resize_tileset_hqx(file_name,file_type,tileset_x_dimensions,tileset_y_dimensions,tile_x_size,tile_y_size,interp)
The same inputs are used as with resize_tileset but different recomendations are given below for what interp to use.
interp can be ('nearest','linear','bilinear','cubic','bicubic','pchip','spline') spline, cubic, or bicubic should give the best results
--resize_tileset_hqx_tilebytile breaks the tileset up into its individual tiles and resizes them individually with the hqx resizing algorithm before recombining them again. This function is significantly slower than the others.
Resizing a tileset with dimensions of 16x16 (in tiles) takes approximately 10 minutes.
resize_tileset_hqx_tilebytile(file_name,file_type,tileset_x_dimensions,tileset_y_dimensions,tile_x_size,tile_y_size,interp)
The same inputs are used as with resize_tileset but different recomendations are given below for what interp to use.
interp can be ('nearest','linear','bilinear','cubic','bicubic','pchip','spline') spline, cubic, or bicubic should give the best results
Changelog
v2.5
All Tileset Resizer functions now detect known incompatible Octave Forge packages (oct2mat) and deactivates them with the "pkg unload package_name" command.
All Tileset Resizer functions now check if required Octave Forge packages (image) are installed and if they are activated. If they are not installed and error message is displayed. If the packages are not activated they are activated automatically with the "pkg load package_name" command.
Warning messages are given if a package is loaded or unloaded.
imresize and imremap updated to be able to resize RGB, RGB+Alpha, and grayscale images.
All Tileset Resizer functions can now resize RGB images as well as RGB+Alpha images. resize_tileset and resize_tileset_tilebytile also support grayscale images.
resize_tileset_hqx_tilebytile now includes workarounds for bugs in imread that appear when reading small image files (like individual tiles).
resize_tileset_hqx_tilebytile rewritten to be easier to modify and to check for incorrect user inputs before anything else.
All Tileset Resizer functions now save resized tilesets in the same filetype as the original image.
v2.0
resize_tileset now allows the user to select the interpolation method.
added resize_tileset_tilebytile -- breaks the tileset up into its individual tiles and resizes them individually before recombining them again.
added resize_tileset_hqx -- resizes the tileset using the hqx resizing algorithm. Requires download of hqx.
added resize_tileset_hqx_tilebytile -- breaks the tileset up into its individual tiles and resizes them individually with the hqx resizing algorithm before recombining them again. Requires download of hqx.
v1.1
Modified imresize and imremap to handle 4 channel images instead of 3 channel images, now processes whole image at once instead of each layer individualy.
imresize and imremap modification reduces distortion of images when resizeing by using relationships between layers to improve the interpolation result.
This is a simple rewrite and breakes support for 3 channel images, if 3 channel support is needed I will do a more extensive rewrite.