Export As Image crops large tiles
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 12.9k
- Forks
- 2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 8
Description
When exporting a map as image, it looks like the image bounds are calculated based on the sum of all the layers' cell bounds, and disregard the additional space required for tiles that stick out of their cells. In some cases, it's desirable to include tiles, Objects, etc that stick out of the map bounds.
Originally reported on the forum: https://discourse.mapeditor.org/t/exported-image-is-cropped/5792
For example, this simple 4x4 ortho map with no layer offsets has a large tree tile in the last column, which I would expect to be visible in its entirety in the export:

However, when actually exported, only the part of the tree that overlaps the cells' bounding box is included:

Here's a less contrived scenario from the user who initially reported this. They have isometric tiles that stick up from their cells, in addition to being offset to produce elevation:

They want these tiles fully included in the export image, but they are cropped right where the map cells end:

A workaround is to add some empty cells at the edges of the map to fit this extra data within the map bounds, but users shouldn't have to do this, and it's likely to add more space than they need. Another solution is to offset an empty layer to add the necessary space to the map bounds, but this is even hackier.
There are scenarios where the current behaviour is desirable, so it is not a bug. The Export As Image dialog should offer the option "Crop to Map Bounds" (current behaviour) as a checkbox, enabled by default. When disabled, it would produce the results desired in above, expanding the canvas to fit overflowing content.
A related issue reported by someone else on Discord recently is that offset layers expand the map bounds even when they're mostly empty. Perhaps an independent trim option would help with that - this would remove empty* pixels around the edges of the image.
* "Empty" does not necessarily mean transparent - the map may have a background colour set and the user will want that trimmed, but probably won't want to crop those parts of tiles/Objects that happen to match the background colour.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Export As Image dialog and the map image bounds calculation. Add the requested “Crop to Map Bounds” option, preserving current cropping when enabled and including overflowing tiles and objects when disabled; verify it with maps containing large or offset tiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100