Skip to content

Instantly share code, notes, and snippets.

@RonenNess
Last active March 10, 2023 16:59
Show Gist options
  • Save RonenNess/d17b4a17e4fa68a5a182b833456afb1b to your computer and use it in GitHub Desktop.
Save RonenNess/d17b4a17e4fa68a5a182b833456afb1b to your computer and use it in GitHub Desktop.
A utility script to batch-process files recursively using Pixelator (http://pixelatorapp.com/)
"""
INSTRUCTIONS:
Replace command = '''...''' with the desired pixelator command you want to run recursively.
To get the command you want, you can click on View --> Shell Command from Pixelator GUI.
WARNING:
This will replace the original files! If you want to create a copy, change the following line:
full_command = command.replace('__in_file__', fullpath).replace('__out_file__', fullpath)
To something like:
full_command = command.replace('__in_file__', fullpath).replace('__out_file__', "some-output-file-name")
"""
import os
# command to run
command = '''C:\\pixelator-win32-x86\\_pixelator_cmd.exe "__in_file__" "__out_file__" --pixelate 1 --colors 32 --palette_mode file --enhance 1 --smooth 0 --smooth_iterations 0 --refine_edges 10 --stroke none --stroke_opacity 1 --stroke_on_colors_diff 0 --background "#00000000" --stroke_color "#00000000" --resize --palette_file "palette.png" --override'''
# iterate content files
for root, subdirs, files in os.walk('.'):
for file in files:
# get full file path
fullpath = os.path.join(root, file)
# make sure its an image file
if fullpath.lower().split('.')[-1] in ['png', 'jpg', 'jpeg', 'gif', 'bmp']:
# remove the starting ./
fullpath = fullpath[2:]
print (fullpath)
# run command
full_command = command.replace('__in_file__', fullpath).replace('__out_file__', fullpath)
os.system(full_command)
print (full_command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment