-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootanim_trim.py
More file actions
56 lines (43 loc) · 1.39 KB
/
Copy pathbootanim_trim.py
File metadata and controls
56 lines (43 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
# get the android bootanimation trim.txt value
# output will like WxH+X+Y
#
# https://android.googlesource.com/platform/frameworks/base/+/master/cmds/bootanimation/FORMAT.md#trim_txt
import time
import sys
def resomid(reso):
try:
a, b = reso.split("x", 1)
print(f"\nWidth={a} , Height={b}\n")
w = int(a) / 2
h = int(b) / 2
return w, h
except ValueError as e:
print(f"\nuhmmm... we got an error {e}")
sys.exit()
def pictmid(width, height):
midx = width / 2
midy = height / 2
return midx, midy
def compile(w, h, midx, midy):
x = w - midx
y = h - midy
output = (f"{rwidth}x{rheight}+{int(x)}+{int(y)}")
return output
# Resolution of the bootanimation WidthxHeight
reso = input("Enter the bootanimation resolution(eg: 1080x2280 ): ")
while "x" not in reso:
print("\nmake sure you input the resolution corectly (don't forget the \"x\")")
reso = input("Enter here: ")
get_mid1, get_mid2 = resomid(reso)
time.sleep(0.5)
# input the Croped picture WidthxHeight
rwidth = int(input("Enter the picture width(pixel): "))
time.sleep(0.5)
rheight = int(input("Enter the picture height(pixel): "))
time.sleep(1)
# start operation
getpic_mid1, getpic_mid2 = pictmid(rwidth, rheight)
final = compile(get_mid1, get_mid2, getpic_mid1, getpic_mid2)
print("\nhere your trim.txt vaule")
print(f"-> {final}")