Last active
January 5, 2024 00:57
-
-
Save iTrooz/fddfcce03c1c44b04231be73d6e7982a to your computer and use it in GitHub Desktop.
reMarkable 2 splash.dat converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
This script aims at converting an image to the custom format used by Remarkable 2 | |
After running this script, move the output "splash.dat" file to /var/lib/uboot in the rM2 device | |
I tried this with PNG images but I guess other formats should work too since I use PIL | |
Syntax: ./main.py <file> [-x xOffset] [-y yOffset] | |
(-x and -y are the offsets of the image on the screen. If not set, the image will be centered on the screen) | |
Input images may need to be rotated 90 degrees before converting them | |
Licence: MPL 2.0 | |
""" | |
import sys | |
from PIL import Image, ImageOps | |
import argparse | |
TABLET_HEIGHT = 1872 | |
TABLET_WIDTH = 1404 | |
parser = argparse.ArgumentParser() | |
parser.add_argument("file", help="image to convert", type=str) | |
parser.add_argument("-x", help="X offset for image", type=int) | |
parser.add_argument("-y", help="Y offset for image", type=int) | |
args = parser.parse_args() | |
if len(sys.argv)==1: | |
print("Syntax : "+sys.args[0]+" <image file>") | |
exit() | |
img = Image.open(sys.argv[1], "r") | |
img = ImageOps.grayscale(img) | |
d = map(lambda i:round(i/16), img.getdata()) | |
if img.width > TABLET_HEIGHT or img.height > TABLET_WIDTH: | |
print("Error: input image dimensions are larger than the tablet dimensions.") | |
print(" Hint: you should rotate the image 90 degrees before converting it") | |
exit(1) | |
# If offsets are not set, default to centering the image | |
if args.x == None: | |
args.x = int(TABLET_HEIGHT/2-img.width/2) | |
if args.y == None: | |
args.y = int(TABLET_WIDTH/2-img.height/2) | |
outf = open("splash.dat", "wb") | |
def w_header(num): | |
outf.write(num.to_bytes(4, "little")) | |
w_header(args.x) | |
w_header(args.y) | |
w_header(img.width) | |
w_header(img.height) | |
outf.write(bytearray(d)) | |
outf.close() | |
print("Convertion finished ! Output file: splash.dat") |
Hey, let's say MPL 2.0: https://www.mozilla.org/en-US/MPL/2.0/
what are the offset values meant to be, coverting with an offfset of 0 or the width and height of the image result in a blank startup screen
what are the offset values meant to be, coverting with an offfset of 0 or the width and height of the image result in a blank startup screen
Nevermind, had to rotate the image 90 degrees
From what I remember:
- Yes, you have to rotate the image 90 degrees
- the x and y offsets indicate where to start drawing the image on the screen, if the image is smaller than it. Their default value will automatically center the image (https://gist.github.com/iTrooz/fddfcce03c1c44b04231be73d6e7982a#file-main-py-L34-L37)
- I assume you had a blank screen before because since you didn't rotate the image, it had dimensions larger than the tablet screen, and it didn't like that
I updated the script to indicate that, feel free to try it and give me feedback
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What license is this under?