26 lines
623 B
Python
26 lines
623 B
Python
from PIL import Image
|
|
import os
|
|
import sys
|
|
|
|
|
|
def resize_png(input_path, output_path, size=(30, 30)):
|
|
img = Image.open(input_path)
|
|
img = img.resize(size, Image.Resampling.LANCZOS)
|
|
img.save(output_path, "PNG")
|
|
print(f"Resized {input_path} to {output_path}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python resize_png.py <input.png> [output.png]")
|
|
sys.exit(1)
|
|
|
|
input_file = sys.argv[1]
|
|
output_file = (
|
|
sys.argv[2]
|
|
if len(sys.argv) > 2
|
|
else f"{os.path.splitext(input_file)[0]}_30x30.png"
|
|
)
|
|
|
|
resize_png(input_file, output_file)
|