TMX is a library for creating, parsing and editing tmx files. The main purpose is to parse a tmx file and save the parsed file as image file.
The tmx format is used by the program Tiled. The format is explained here.
Install the latest version with
$ composer require kreemer/tmx
<?php
use Tmx\Service\Parser;
use Tmx\Service\Printer;
$parser = new Parser();
$map = $parser->parse('filename.tmx');
echo $map->getWidth(); // get width of map
echo $map->getHeight(); // get height of map
$printer = new Printer();
$printer->print($map, 'output.png'); // save map to output.png
See here for additional documentation.
- Tmx works with PHP 7.4 or above.
- You have to install the imagick extension, gd support is currently under development
- If you want to parse zlib or zstd compressed maps, you have to install these extensions
Bugs and feature request are tracked on GitHub
This library uses Serene village revamped tiles for automatic tests. The tileset is under the Creative commons license.
Please support the original developer for this wonderful tileset.
Tmx is licensed under the MIT License - see the LICENSE file for details.