Merge pull request #14 from chavinlo/patch-3

moved scripts and added nsfw extractors
This commit is contained in:
harubaru 2022-09-11 22:55:03 -07:00 committed by GitHub
commit f6c06933ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,19 @@
#resizes and adds a black bar to all images in directory original
from PIL import Image, ImageOps
import os
directory = 'original'
for filename in os.listdir(directory):
var1 = directory + '/' + filename
os.mkdir('E:/convert/original/' + filename)
for i in os.listdir(var1):
var4 = var1 + '/'
var2 = var1 + '/' + i
if os.path.isfile(var2):
print(var2)
im = Image.open(var2)
im = ImageOps.pad(im, (512, 512), color='black')
im.save('E:/convert/' + var2)

View File

@ -0,0 +1,48 @@
# with open("nsfw-ids.txt", 'r', encoding="utf8") as nsfwfile:
# nsfw_list = list(nsfwfile)
import tqdm
# ##Read line
# current_saved_file_count = 0
# current_line_count = 0
# for line in nsfw_list:
# print(line)
# last3_line_raw = line[-4:]
# last3_line = last3_line_raw.zfill(4)
# print(last3_line_raw)
# print(last3_line)
def file_len(filename):
with open(filename) as f:
for i, _ in enumerate(f):
pass
return i + 1
def writetofile(input):
f = open("files2download.txt", "a")
f.write(input + "\n")
f.close()
#converts nsfw-ids.txt entries to rsync readable file
with open("nsfw-ids.txt", 'r', encoding="utf8") as nsfwfile:
nsfw_list = list(nsfwfile)
count = 0
linescount = file_len("nsfw-ids.txt")
##Read line
for line in nsfw_list:
line = line.strip()
# print(line)
linefilled1 = line.zfill(4)
linelast3 = linefilled1[-3:]
linedirectory = linelast3.zfill(4)
# print("line: " + ">>"+ line + "<<")
# print("Linefilled1: " + linefilled1)
# print("linelast3: " + linelast3)
# print("linedirectory: " + linedirectory)
directory = "original/" + linedirectory + "/" + line + ".jpg"
# print(directory)
# print(directory2)
writetofile(directory)
count = count + 1
print(str(count) + "/" + str(linescount))