-
Notifications
You must be signed in to change notification settings - Fork 0
/
resize-images
executable file
·31 lines (22 loc) · 1.31 KB
/
resize-images
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
#!/usr/bin/env python3
import os
import subprocess
import argparse
parser = argparse.ArgumentParser(description="Resize theme images located in the \"public/app/themes/originals\" folder.")
parser.add_argument("--group", help="Resize only a group of images and skip the rest.")
args = parser.parse_args()
input_folder = './public/app/themes/originals'
output_folder = './public/app/themes'
files = [file for file in os.listdir(input_folder) if args.group == None or file.startswith(args.group)]
for entry in files:
filename, fileext = os.path.splitext(entry)
input_filepath = os.path.join(input_folder, entry)
thumbnail_output_filepath = os.path.join(output_folder, filename + '_thumb.jpg')
fullsize_output_filepath = os.path.join(output_folder, filename + '.jpg')
print('process ' + input_filepath)
useHighQuality = filename.startswith('ray') or filename.startswith('shine') or filename.startswith('aqua')
quality = '85' if useHighQuality else '40'
thumbnails_magick_command = ['magick', 'convert', input_filepath, '-resize', '200', '-quality', quality, thumbnail_output_filepath]
subprocess.run(thumbnails_magick_command)
fullsize_magick_command = ['magick', 'convert', input_filepath, '-resize', '2000', '-quality', quality, fullsize_output_filepath]
subprocess.run(fullsize_magick_command)