Mods / Map exporter (DB to PNG)

Tags: #Utility
Author: SiiMeR
Side: Client
Created: Feb 5th 2024 at 3:34 PM
Last modified: May 20th 2024 at 7:26 PM
Downloads: 1537
Follow Unfollow 52

Latest release:
VintageStoryDBToPNG.zip


Vintage Story Map Exporter

This is a tool to read the color values of your Vintage Story client-side map file from a .db file and export them to a .png file.

How to use

  1. Fill in the values in config.json

    • MapFile - The path to your map .db file (usually found in VintageStoryData/Maps). Warning: Make a backup of your map before using this program.
    • The bounding box of the exported map. Note that these are absolute coordinates (you can find your position ingame by writing .cp aposi to the chat). From there you will have to guesstimate the bounds:
      • MinX - The leftmost coordinate the map will be exported from
      • MaxX - The rightmost coordinate the map will be exported to
      • MinY - The uppermost coordinate the map will be exported from (in VS, the Y coordinates are flipped)
      • MaxY - The lowermost coordinate the map will be export to
  2. Run the provided VintageStoryDBToPNG.exe file

  3. The map will be exported to the same directory

The map colors are from the Medieval Map mod

Version For Game version Downloads Release date Changelog Download 1-click mod install*
v2
1283 May 20th 2024 at 7:26 PM Show VintageStoryDBToPNG.zip
v1
254 Feb 5th 2024 at 3:38 PM Show VintageStoryDBToPNG.zip

29 Comments (oldest first | newest first)

💬 The_Lunarian, 1 day ago

Hey! Just wanted to say thanks to SiiMeR for this great tool. The code really helped me understand how the minimap database is structured. 🙏

Back when I was looking for a way to extract the minimap as an image, I couldn't run this exporter on my MacBook or Steam Deck (Linux), so I ended up writing my own cross-platform version in Python. If anyone’s looking for a CLI-based alternative that works on Linux/macOS/Windows, you can check it out here:

👉 VS Map Renderer

It renders the entire explored map (or a bounding box) to a pixel-perfect PNG and supports large sizes with no hard limits. Still evolving, but fully usable. Feedback welcome!

💬 Taeo, Mar 22nd at 6:22 AM

SiiMeR

The map isn't disabled but the coordinate system is. Good call. I'm the admin so imo the command should work anyway but I wouldn't be surprised if that didn't matter

💬 SiiMeR , Mar 21st at 2:27 PM

Interesting, it has been working for me. Are you sure you are not playing on a map disabled server? Taeo

💬 SiiMeR , Mar 21st at 2:23 PM

The source is linked at the top of this mod, under both Homepage and Source koniu699

💬 koniu699, Mar 21st at 1:41 PM

Fair I failed to use absolute numbers. Works like a charm. Mind sharing code base? I see some improvements I could do.  SiiMeR

💬 Taeo, Mar 21st at 12:23 AM

.cp aposi doesn't seem to work in 1.20.x multiplayer, any other way to get the absolute position if it is not what you see on the map?

💬 SiiMeR , Mar 20th at 5:29 PM

Hi, maybe you are using wrong coordinates. The program is expecting absolute coordinates, not what you see on your HUD. koniu699

💬 koniu699, Mar 20th at 11:12 AM

Hi, when I load a map file I got information that 0 chunks was loaded and then the app exits. Any idea what might be wrong?

 

💬 achenalia, Mar 19th at 7:09 AM

Swend there was a typo that broke the script, the new one is here:

https://gist.github.com/achenalia/d2871cd702137825355b265865a53730

💬 Swend, Feb 11th at 12:20 PM

@petrichor I don't know enough to be sure, but the error comes when it tries to save a file, so there is some chance it has problems with permissions. Try moving the folder or running the exe as administrator?

💬 petrichor, Feb 10th at 10:24 PM

Not sure what I am doing incorrectly:


Reading map DB...
Loaded 29733 chunks from map DB
Creating tile (0, 0) with bounds (0, 0) to (8000, 7744)
Saving tile to map_tile_0_0.png
Unhandled exception. System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.SafeNativeMethods.Gdip.CheckStatus(Int32 status)
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at VintageStoryDBToPNG.Program.CreateAndSaveTiledImages(List`1 mapPieces, Int32 chunkWidth, Int32 chunkHeight, Int32& finalWidth, Int32& finalHeight) in C:\Users\siimr\Desktop\VSMods\vintagestory-map-to-png\Program.cs:line 134
at VintageStoryDBToPNG.Program.CreateMapWithBounds(Int32 minX, Int32 maxX, Int32 minY, Int32 maxY, String mapFileName) in C:\Users\siimr\Desktop\VSMods\vintagestory-map-to-png\Program.cs:line 65
at VintageStoryDBToPNG.Program.Main() in C:\Users\siimr\Desktop\VSMods\vintagestory-map-to-png\Program.cs:line 13

 

💬 Swend, Feb 10th at 2:07 PM

I wrote a script to automate converting from relative to absolute coords. Just drop in the same folder as the config and exe, and edit the file directly with the values.

https://gist.github.com/Swend5/ec5258e4da6eda03eb5dc42d3f2b6b88

SiiMeR you can of course also add it to the mod if you would want to.

💬 SiiMeR , Jan 19th at 2:47 PM

You could try some online bitmap or pixel art upscaler. 

WildEwok

💬 WildEwok, Jan 13th at 6:55 PM

Is there a way to increase the resolution of the output image? Say I only want to export a map that's 500x500 for planning purposes. I'm able to zoom in on the native map in game so that each block is more than 1px, but it doesn't seem to export nicely so I can zoom in to the same resolution when using the tool. Can you help me out with that?

💬 Jarrett, Oct 14th 2024 at 4:30 PM

DanaCraluminum That's good to know. I had a few classes of C++ in college, but that was over 15 years ago. 

💬 DanaCraluminum, Oct 13th 2024 at 9:00 PM

Jarrett The game is not in Java, but in C#

💬 Jarrett, Oct 13th 2024 at 5:54 PM

I am not great with java, but I was able to eventually figure this out. 

 

Here are some more user friendly instructions.

  1. While in-in game, type ".cp aposi" in chat
  2. Open note pad and paste the coordinates. It should look like this "X=512110,Y=115,Z=512030" ... Note that the Z= value is actually the Y value that you will be using below...
  3. Exit out of the game (this may not be necessary, but I think it is a good idea)
  4. Download the zip file
  5. Export it wherever
  6. Open file location in browser window
  7. edit "config.json" using notepad (I use Visual Studio Code, but notepad works)
  8. Open a 2nd browser window and navigate to where your map .db file is located. It should be in C:\Users\<your user name>\AppData\Roaming\VintagestoryData\Maps (replace <your user name> to the appropriate user profile).
  9. Find the most recent map .db file (I looked for the most recently modified one).
  10. Right click, copy and paste it to the same directory (this is making a back up in case the program breaks the original) - Image Link
  11. copy the full file path and file name and replace the section in the mapfile line with it (between the two quotes)
  12. Take the coordinates you got above - Image Link
    1. subtract 5000 to the X value in your coordinates that you copied earlier from the game... that is you MinX value
    2. add 5000 to the X value in your coordinates that you copied earlier from the game... that is you MaxX value
    3. subtract 5000 to the Z value in your coordinates that you copied earlier from the game... that is you MinY value
    4. add 5000 to the Z value in your coordinates that you copied earlier from the game... that is you MaxY value
  13. After you have edited the 5 lines in the config.json file, save it (you don't need to close it... though you should be done with it) - Image Link
  14. Run the VintageStoryDBToPNG application file in the same directory as the config.json file
  15. That should be it... the .png image file should be saved in the same directory as the config.json file and be named something like map_tile_0_0.png - Image Link

 

I hope this helps anyone overcome the hurdles that slowed me down! 

💬 SiiMeR , Aug 29th 2024 at 10:31 AM

@Wahazar

This is expected. The image manipulation methods in .NET don't support images over some size (I think it was 12k by 12k). 

So what I did was generate small chunks and then try to stitch them together. If it works, it works. If it doesn't, you have to stitch them together yourself. 

💬 Wahazar, Aug 25th 2024 at 3:00 PM

Unfortunately program crashed when tried to stich together map tiles (map size was above 40k blocks, I was travelling a lot).

System.ArgumentException: Parameter is not valid. at System.Drawing.SafeNativeMethods.Gdip.CheckStatus(Int32 status)

 

I guess there is issue with too short longint...

💬 Wahazar, Jun 23rd 2024 at 11:45 AM

It took me several attempts, but finally I was able to generate whole map.

Note to users not familiar with json: data path in config needs double slashes \\

💬 SiiMeR , Feb 21st 2024 at 8:53 AM

Hey

If you install the Medieval Map mod, you must re-explore every chunk to make the game repaint the chunks. I think referencing the game config to color the maps during exporting would be great, but I am not sure how easy that is. Maybe I will add it in a future version (kinda busy right now). The same goes for the default coloring of the background.

Thanks for the suggestion though!

💬 LittleJoe, Feb 21st 2024 at 4:42 AM

A suggestion:

It seems that by default, the export contains only chunks that have been explored, but for the purposes of stitching together several images into larger one, or layering images from several players into a larger one, would it be possible to have an option that fills the "empty" space up to the edge of the defined position edges? That way I can predictably export the same area from multiple maps and layer them, or step over another 10k in a given direction and stick that image right by the last one I exported.

anyways, amazing mod though!

💬 LittleJoe, Feb 21st 2024 at 3:49 AM

Heeeey again, so the exporting is working great for me! Awesome work! Only issue is I'm not getting the Medievil Map Mod colors, but instead the regular map colors. Is there a place to double-check the config for it? Does the program reference the game files at all for colors? I'm on 18.xx atm.

💬 LittleJoe, Feb 20th 2024 at 11:34 PM

Ahhhhh, okay, I just didn't use absolute coordinates, thanks 👍 

💬 SiiMeR , Feb 20th 2024 at 3:13 PM

Hey,

 

The error indicates that the coordinates you provided didn't have any map chunks in them.

 

Are the coordinates correct? Keep in mind that they need to be absolute coordinates, not the ones shown in the Map view. You can get the absolute coordinates of your current position by running the .cp aposi command in your chat. From there, you have to play around with the numbers a bit. 

 

Hope this helps!

💬 LittleJoe, Feb 20th 2024 at 12:00 AM

Hey Siimer, love the idea here! I seem to be having trouble running it though. I'm getting this error when running the exe: 

My config looks like:

{
  "MapFile": "C:\\Users\\[username]\\AppData\\Roaming\\VintagestoryData\\Maps\\3942d752-83f8-4729-903a-932f78b0ead8.db",
  "MinX": -6734,
  "MaxX": -7134,
  "MinY": 12087,
  "MaxY": 16087
}

 



💬 W4RD0, Feb 7th 2024 at 12:52 PM

Love seeing my city of Nova Cale in the thumbnail😊! Thank you so much for this SiiMeR! 💕

💬 SiiMeR , Feb 5th 2024 at 4:16 PM

This only works for areas you have already discovered. Basically, anything you see in the in-game map view is exported

💬 RubyGloom, Feb 5th 2024 at 4:10 PM

Does this reveal the map areas under the fog of war or only the areas you've discovered?

 (edit comment delete)