Skip to content

Instantly share code, notes, and snippets.

@mariomadproductions
Forked from cmartello/mergentr.py
Last active July 1, 2021 17:17
Show Gist options
  • Save mariomadproductions/e00ed441d723ed720d75e5b3f636a5e1 to your computer and use it in GitHub Desktop.
Save mariomadproductions/e00ed441d723ed720d75e5b3f636a5e1 to your computer and use it in GitHub Desktop.
Takes a directory of screenshots taken by Luma 3DS (v9.0+) and stitches them together.
"""Luma3DS (v9.0+) screenshots are dumped into two seperate files (_top and _bot) and stored
in .bmp format. This script lets you merge those files into one (as a .png) fairly quickly.
A caveat:
- This script is not clever and will not protect you from yourself. It pretty much expects
these files to be exactly 400x240 and 320x240 BMPs in RGB format. Anything else will
probably crash it.
Some good news though, this process takes a little over a minute for 140 odd screenshots, so
you won't be waiting long for your output. Also my one test run took my storage from 70 megs
to a little over 20, so that's a nice benefit.
"""
from PIL import Image
from glob import glob
def merge_files(top, bot):
"""Merges the provided *_top.bmp and *_bot.bmp files created by
NTR's screenshot function into a single .png file. As the top screen
of the 3DS is slightly wider than the bottom, the bottom screen will
be centered and have transparent gutters to the left and right.
top = 400x240
bot = 320x240"""
# create a new output image
output = Image.new(mode='RGBA', size=(400,480), color=(0, 0, 0, 0))
# open the specified image files
t = Image.open(top)
b = Image.open(bot)
# paste the input into the output
output.paste(t, box=(0,0))
output.paste(b, box=(40,240))
# save her to disk
fn = top.replace('_top.bmp','.png')
output.save(fn, 'png')
# close our files
t.close()
b.close()
output.close()
if __name__ == '__main__':
files = glob('*_top.bmp')
for x in files:
y = x.replace('top.bmp', 'bot.bmp')
print('merging %s and %s' % (x, y))
merge_files(x, y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment