# Displaying map with pytmx (Properly automatically flipping )

**URL:** <https://discourse.mapeditor.org/t/displaying-map-with-pytmx-properly-automatically-flipping/6320>\
**Category:** Questions\
**Created:** [September 5, 2023, 2:26pm UTC](https://discourse.mapeditor.org/t/displaying-map-with-pytmx-properly-automatically-flipping/6320 "2023-09-05T14:26:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shiny\_bieber](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/shiny_bieber/32/4254_2.png) [@Shiny\_bieber](https://discourse.mapeditor.org/u/Shiny_bieber)\
**Post date:** [September 5, 2023, 2:26pm UTC](https://discourse.mapeditor.org/t/displaying-map-with-pytmx-properly-automatically-flipping/6320/1 "2023-09-05T14:26:52Z")

</div>

#remark  
I already check that question, I’m asking about a bit another

> [@Need help understanding exported flipped tiles](https://discourse.mapeditor.org/t/need-help-understanding-exported-flipped-tiles/5383):
>
> Hey, I need some help. I’m completely new to Tiled, but it makes my workflow so much more efficient. I’m using my imported tile map to create my level, but the problem I’m coming into involves exporting flipped tiles. Since I discovered Tiled so late into the development of my game, I’m finding it hard to implement some of the data. It follows this psuedocode: Import ‘terrain.csv’ as file for each item in file //need help here var id = item create tile and apply image This works for all n…

I’m trying to load my map from Tiled editor for a couple of days and still cant understand how blit it properly ?  
I’m also trying to use pytmx library  
I created my map from collection of images , NOT like sprite sheet collection , and now when I’m loading my terrain layer some images dosen’t flipped automatically , but they were flipped in Tiled editor previously …  
Can someone recommend me any ideas how realize it PROPERLY with pytmx library ?  
I know that info about fliping located in gid (In first three bits of bitwize representation of that number)  
but also how ge normal Id from gid ?  
Anyway how read throw pytmx data if image need flip or not ?

```auto
def map_setup():
    global image

    # Getting / Importing the map
    tmxdata = load_pygame("Tile_files\\mymap2.tmx")
    width = tmxdata.width * tmxdata.tilewidth
    height = tmxdata.height * tmxdata.tileheight

    ti = tmxdata.get_tile_image_by_gid
    for layer in tmxdata.visible_layers:
        if isinstance(layer, TiledTileLayer):
            for x, y, gid, in layer:
                tile = ti(gid)
                if tile:
                    image = tmxdata.get_tile_image(x, y, layer)

```

That is exacted code from stackoverflow , but it dosen’t flip tiles which in layers container …

Will be grateful any recommendation ))
