Created
March 23, 2025 02:20
-
-
Save motebaya/606c05746e19db3f0b605bf3d0ae2253 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/python | |
# 2/24/2025 - @github.com/motebaya | |
from PIL import Image | |
from io import StringIO | |
import pilgram | |
import os | |
ext_list = list(Image.registered_extensions().keys()) | |
list_filters = [ | |
"_1977", | |
"aden", | |
"brannan", | |
"brooklyn", | |
"clarendon", | |
"earlybird", | |
"gingham", | |
"hudson", | |
"inkwell", | |
"kelvin", | |
"lark", | |
"lofi", | |
"maven", | |
"mayfair", | |
"moon", | |
"nashville", | |
"perpetua", | |
"reyes", | |
"rise", | |
"slumber", | |
"stinson", | |
"toaster", | |
"valencia", | |
"walden", | |
"willow", | |
"xpro2", | |
] | |
css_list = [ | |
"contrast", | |
"grayscale", | |
"hue_rotate", | |
"saturate", | |
"sepia", | |
] | |
def _test( | |
mode: str = 'filters', | |
sample: str = 'pilgram-effects/mayfair-sample.png' | |
): | |
if not os.path.exists('pilgram-effects'): | |
os.mkdir('pilgram-effects') | |
if mode == 'filters': | |
for fil in list_filters: | |
im = Image.open(sample) | |
getattr(pilgram, fil)(im).save(f'pilgram-effects/{fil}-sample.png') | |
print(fil) | |
if mode == 'css': | |
for css in css_list: | |
im = Image.open(sample) | |
if css == 'saturate': | |
iem = getattr(pilgram.css, css)(im, 1.5) | |
else: | |
iem = getattr(pilgram.css, css)(im) | |
iem.save(f'pilgram-effects/css-{css}-sample.png') | |
print(css) | |
_test() | |
_test('css') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment