Tmxrasterizer problems

Two questions:

  1. tmxrasterizer just seems to flat out not work… it gives no errors, but the output file is nowhere to be seen
  2. does it export object layers? If so, is there any way to make it ignore them?

I need some way to export each layer as its own image, only tile layers

How do you call tmxrasterizer? If you call it like tmxrasterizer map.tmx output.png it should render the map to the output.png. That works here at least.

No it currently does not render object layers. How should it render them anyway? Object layers mainly extend the map with additional information… Though tmxrasterizer should probably export tile objects. I am not sure if it does that at the moment, it might not.

You can specify --hide-layer for hiding a specific layer name.

Here is the output of tmxrasterizer --help:

  tmxrasterizer [options] [input file] [output file]

  -h --help               : Display this help
  -v --version            : Display the version
  -s --scale SCALE        : The scale of the output image (default: 1)
  -t --tilesize SIZE      : The requested size in pixels at which a tile is rendered
                            Overrides the --scale option
  -a --anti-aliasing      : Smooth the output image using anti-aliasing
     --ignore-visibility  : Ignore all layer visibility flags in the map file, and render all
                            layers in the output (default is to omit invisible layers)
     --hide-layer         : Specifies a layer to omit from the output image
                            Can be repeated to hide multiple layers

Yes, I call it correctly
It just says “libpng warning: iCCP: known incorrect sRGB profile” and doesn’t output an image file

I don’t want it to render object layers, so that’s good. I’m new to Tiled so I couldn’t have known

Yes I know what the help says, it’s just not completely clear because I haven’t been able to actually use it yet

This should only be a warning printed by an internal library because your images seem to use a incorrec RGB profile. But it should still output a file…

Here I successfully rendered this map (it depends on some tileset within the repository) with this command:
tmxrasterizer sandbox.tmx sandbox.png

Does that map work for you? I have no idea why it does not work on your machine…


It was because of permissions in the folder that wouldn’t let it create new files, I just changed the output folder / added it to Path

Ah, thanks for letting us know! I’ve opened up the following issue about this so that I don’t forget to add some error message for the next release:

Missing error message is now fixed, as well as a crash when trying to rasterize maps referring to external tilesets…

Here’s a batch file to do what I was wanting

@echo off
for /f "tokens=3 delims== "  %%n in ('findstr /c:"layer name" %1.tmx') do (
set layers=!layers! %%~n
set c=1
for %%l in (%layers::= %) do (
    set hide=
    for %%h in (%layers::= %) do (
      if not %%h==%%l (
         set hide= !hide! --hide-layer %%h
    call "C:/program files (x86)/tiled/tmxrasterizer.exe" !hide! %1.tmx %%l_.png
    copy %%l_.png %1_!c!.png
    set /a c+=1

Ouch, that just reminds me how extremely ugly batch scripting is… but, well done!