mapeditor / mapeditor/tiled

tmxrasterizer: option to keep color type and/or palette of PNGs

Open
#4,007 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
12.9k
Forks
2k
Avg merge
4h 27m
Merged PRs (30d)
8

Description

**Is your feature request related to a problem? Please describe.**
I use indexed PNGs (color type 3), which is handy for pixel art. Tiled always converts them to true color PNG, which is bigger. Tiled uses RGBA, which is 32bit per pixel, whereas 256 color indexed PNG only has 8bit per pixel. (bpp prior to compression)

There are indeed some difficulties. The tilesets could have different palettes, though it’s straight forward if all tilesets use the same palette. If they are different they could be merged or conversion be refused. Merging would lead to lower file sizes, but it would have no benefit for the following use cases.

I have multiple palettes, which I use with my tilesets. If tiled kept the color type and palette intact, I could open the exported map and switch palettes. Gimp, Grafx2 and mtPaint allow to load different palettes. This again allows to test a map with multiple palettes quickly instead of loading palette, saving the image, switching to tiled, loading the next palette etc.

Furthermore these exports would become usable on retro gaming platforms that use indexed images. (ZX Spectrum, NES, Game Boy etc.) For these platforms it’s important that the indexes are correct since image and palette get loaded separately. Furthermore there are tools who can create tile maps from a tileset PNG and tile map PNG. The twist with this is that they can optimize for hardware capabilities like Y-flip, X-flip etc, which might not be reflected in the tiled map if the map is for multiple platforms.

Another use case is to possibly create an animated GIF where frames share a palette instead of using per frame palettes. APNG always shares the palette between all frames if it’s indexed.

**Describe the solution you'd like**
Flags like `--nc` and `--np` to not meddle with **c**olor type and/or **p**alette when exporting to PNG. Could be different flags, that’s just how it’s named in oxipng and optipng.

**Describe alternatives you've considered**
Writing my own tmx parser/exporter.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the tmxrasterizer PNG-export entry point and trace how color type and palettes are currently selected. Clarify behavior for matching and differing tileset palettes, then establish the requested options so supported exports preserve indexed color metadata without changing unrelated PNG output.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.