-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished all the TODOs, now remains debugging
- Loading branch information
1 parent
5a047f0
commit 1219207
Showing
4 changed files
with
42 additions
and
45 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
// Libraries used: PIL (Image, ), os, pathlib, tkinter | ||
|
||
0. Pick folder where to apply app | ||
1. Convert image into hex | ||
- | ||
- | ||
2. Find hex which overlaps with menubar image | ||
- | ||
3. recognize where year&date is | ||
4. extract date&year to file & store it in file | ||
5. cut out the menubar and possibly the nationinfobar from image | ||
6. rename file into what 4 concluded | ||
7. convert into .jpg | ||
// 4. extract date&year to file & store it in file | ||
// 5. cut out the menubar and possibly the nationinfobar from image | ||
//6. rename file into what 4 concluded | ||
//7. convert into .jpg |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,55 @@ | ||
from PIL import Image | ||
import os, sys | ||
import os | ||
#from os import listdir, path | ||
|
||
def cut_image(): | ||
pass | ||
|
||
def sort_date(d:list)->str: | ||
pass | ||
|
||
def get_date(file:str)->list: | ||
cur_img = Image.open(file).tobytes() | ||
temp_img = cur_img # holds image value but gets minimized | ||
|
||
def cut_img (img:Image)->Image: | ||
width, height = img.size | ||
return img.crop((259, 76, width, height)) # cuts out everything except map | ||
|
||
def get_date(cur_img:Image)->list: | ||
color = cur_img.convert("RGB").getpixel((0, 48)) # color of first pixel under the upper black seperator line above the bar | ||
if color == (96, 96, 88): | ||
cur_img_bytes = cur_img.tobytes() | ||
return iterate_chars("dhfull_chars") | ||
elif color == (184, 180, 152): | ||
cur_img_bytes = cur_img.tobytes() | ||
return iterate_chars("dhlite_chars") | ||
else: return None | ||
|
||
def iterate_chars(char_folder:str)->list: | ||
nonlocal cur_img_bytes | ||
nonlocal cur_img | ||
date = [] # HH MM Month Day:int Year, max: 2, 2, 1, 2, 4 | ||
|
||
temp_img = cur_img_bytes # holds image value which gets minimized | ||
date = [] | ||
cur_char_folder = r"darkesthouraarimagefixer\%s" % char_folder | ||
|
||
for charname in os.listdir(cur_char_folder): # maybe make months into own folder so it goes faster | ||
for charname in os.listdir(cur_char_folder): # maybe make months into own folder so it goes faster; actually just save the HEX values | ||
cur_char = Image.open(cur_char_folder + charname).tobytes() | ||
index_img = cur_img.index(cur_char) | ||
try: | ||
date.append((charname.split(".")[0], index_img)) | ||
index_img = cur_img_bytes.index(cur_char) | ||
while cur_char in temp_img: | ||
date.append((charname.split(".")[0], index_img)) | ||
temp_img[index_img:] | ||
continue | ||
except ValueError: # if no index is found | ||
temp_img = cur_img | ||
temp_img = cur_img_bytes | ||
|
||
if len(date) == 11: break # early break out if maxed out stats | ||
if len(date) == 11: break # early break out if maxed out on data | ||
cur_img = cut_img(cur_img) | ||
return date | ||
|
||
try: | ||
return (iterate_chars("dhlite_chars") if cur_img.convert("RGB").getpixel((826,55)) != (126, 126, 126) # Checks if the bar's color of upper dot of comma is grey, as in DH Full | ||
else iterate_chars("dhfull_chars")) | ||
except ValueError: # whenever file lacks both dhfull and dhlite characthers, return nothing | ||
return | ||
|
||
# check color over menubar around date pause | ||
|
||
def walk_folder(folder): | ||
for filename in os.listdir(folder): | ||
|
||
sort_date(get_date(filename)) | ||
cur_img = Image.open(folder+filename) | ||
new_filename = "".join([x[0] for x in sorted((get_date(cur_img)), key=lambda d: d[1])]) # sorts date as: HH MM Month Day Year; currently just mashes sorted list | ||
infilename = os.path.join(folder,filename) | ||
if not os.path.isfile(infilename): continue | ||
oldbase = os.path.splitext(filename) | ||
newname = infilename.replace('.bmp', '.jpg') | ||
output = os.rename(infilename, newname) | ||
|
||
|
||
newname = new_filename + ".jpg" | ||
os.rename(infilename, newname) | ||
|
||
""" StackOverFlow answer | ||
infilename = os.path.join(folder,filename) | ||
if not os.path.isfile(infilename): continue | ||
oldbase = os.path.splitext(filename) | ||
newname = infilename.replace('.grf', '.las') | ||
output = os.rename(infilename, newname) | ||
""" |