Map image to tmx


#1

Hi there,
I was looking for something to convert *.png map files into tmx files for game recreation purposes.
And I could not find anything working or “ready to go”, so I have made my own and I want to share it with You all.

Maybe some of You find it useful.
here it is:
https://mega.nz/#!BxVVVK6B!_07OnBopjgIq0txgB9CORT97sIezzqXUIIvo4aTkPcY

It is made in java
operate from command line with command

java -jar Img2Tmx.jar tileWidth tileHeight TileSet.png MapFile.png

after processing both files it will display result in new window and save it to *.tmx file

unrecognized tiles will show as pink in result display.
In Tiled You just need to point to *.tsx file and You are done.

any questions, please ask.

Quick update
I have added separation into 4 layers.
new version:
https://mega.nz/#!Q1MkQKZT!VgMsMygGa9LFM3esHjaia9FaqAFF9NKkoKd6GhM_OIA

using by the same command
java -jar Img2Tmx.jar tileWidth tileHeight TileSet.png MapFile.png

To get tiles in new layers put tile’s tile set number in txt file attached to program (they need to be in the same folder as jar file).
numbers needs to be in 1 column like:

1
2
3
4

make sure there is no empty line at the end.

and here:
https://mega.nz/#!soUzhbgZ!6TgrPECMXiEjimjKXrcbDIwmypeQqJ_KTnSWplw0E_c
zip with Mario 1-1 example with batch file to fire it up.


Import complete Maps from RPG Maker to Tiled
(Darkhog) #2

Cool little tool. Maybe as a next step it could autogenerate the tileset from tiles in the image? You already can recognize if the tile exists, so you can use that code to prevent generation of dupe tiles (if tile is in set, use it, if it isn’t create it as a new one and add at the end of the tileset, creating new row if necessary).


#3

Cheers,
It should be easy to do. Although it brings some issues.
Tile set would be populated with tiles that not suppose to be there, like overlapping-transparent tiles or artifacts.
Also would be a mess to look at it.
I prefer to handcraft tile set by adding necessary tiles.
But I think I will implement auto generation for purpose of to get started.

Update:
So here it is:
https://mega.nz/#!89cnCTYK!qbMDxTDO4Zn-PCeIKOVeDVIxlhjLDQeWMz-tMrBrvoY

to get it to work just change tileSetFile.png to genNewSet.

command:
java - jar Img2Tmx_v3.jar tilex tiley genNewSet mapFile.png

it will generate new tile set base on the map.


(Darkhog) #4

Thanks. The reason I’ve asked for this is that many emulators allow for map export, layer by layer so overlaped tiles aren’t a problem. Also not everyone has technical know-how to dump the tilesets from a ROM (especially if they’re using any sort of compression to fit more on the cartridge), so generating tiles from screenshots is a next best thing. As for artifacts - you shouldn’t generate your map from a JPG anyway and some digital camera manufacturers have even started using PNGs for the camera because they have higher quality than JPGs and are still small, so JPGs in future will stop being used for photos as well.

Finally, the tileset looking like a mess, well that’s a tradeoff you may want to live with if you can’t track original set down and have to generate it from screenshots. Certainly beats sitting for hours and manually ripping tiles from screenshots.


(Thorbjørn Lindeijer) #5

Nice tool! It’s an often requested feature so eventually I do hope to get around to building this right into Tiled as some kind of “import map from image” feature.

Btw, I’m a bit wary of running binaries (which includes .jars), since there is no way to know what it’ll do. What about publishing the source code?

Other tools that cover this use-case are Map-Tiler, ShoeBox and the scripts covered in this wiki page.


#6

Thanks,
It would be useful feature, there are still planty people working on old games.
Providing *.jar was on purpose to avoid installing frameworks/libraries/compilators, but I understand Your worries.
I have made it as a tool for my project, therefore code is not elegant. But I will put it on github once I get myself to clean it up.


(Thorbjørn Lindeijer) #7

I would say since you felt the program is good enough to release in binary form, it must be good enough to release the source code as well.


#8

hehe, it works but it is not pretty.
Nether less it is available now on:
https://github.com/GregSam/Img2Tmx