-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on testing Wand / ImageMagick features
Related to issue #4; still a WIP
- Loading branch information
1 parent
b5752a1
commit ad00720
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
creds.py | ||
__pycache__/ | ||
.*.swp | ||
extra/generating_images_demo/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
if [[ ! -z $(find generating_images_demo/ -name "row*") ]]; then | ||
echo "found row* images to delete in generating_images_demo" | ||
rm generating_images_demo/row* | ||
fi | ||
|
||
for i in {0..20}; do | ||
montage generating_images_demo/modulate_${i}_0.jpg generating_images_demo/modulate_${i}_1.jpg -tile 2x1 -geometry +0+0 generating_images_demo/row_${i}.jpg | ||
for j in {2..20}; do | ||
montage generating_images_demo/row_${i}.jpg generating_images_demo/modulate_${i}_${j}.jpg -tile 2x1 -geometry +0+0 generating_images_demo/row_${i}.jpg | ||
done | ||
# montage generating_images_demo/modulate_${i}_[0-20].jpg -tile 21x1 -geometry +0+0 generating_images_demo/row_${i}.jpg | ||
echo "finished generating row file for row $i" | ||
# convert append generating_images_demo/modulate_${i}_*.jpg generating_images_demo/row_${i}.jpg | ||
done | ||
|
||
montage generating_images_demo/row_0.jpg generating_images_demo/row_1.jpg -tile 1x2 -geometry +0+0 generating_images_demo/result.jpg | ||
while [[ ! -e generating_images_demo/result.jpg ]]; do | ||
echo "waiting for result.jpg to be generated" | ||
sleep 1 | ||
done | ||
|
||
for i in {2..20}; do | ||
mv generating_images_demo/result.jpg generating_images_demo/tmp.jpg | ||
while [[ ! -e generating_images_demo/tmp.jpg || -e generating_images_demo/result.jpg ]]; do | ||
echo "waiting for result.jpg to be moved to tmp.jpg" | ||
sleep 1 | ||
done | ||
sleep 10 | ||
montage generating_images_demo/tmp.jpg generating_images_demo/row_${i}.jpg -tile 1x2 -geometry +0+0 generating_images_demo/result.jpg | ||
sleep 10 | ||
while [[ ! -e generating_images_demo/result.jpg ]]; do | ||
echo "waiting for result.jpg to be regenerated" | ||
sleep 1 | ||
done | ||
rm generating_images_demo/tmp.jpg | ||
done | ||
|
||
mv generating_images_demo/result.jpg generating_images_demo/big_result.jpg | ||
rm generating_images_demo/row*.* |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
from wand.image import Image | ||
from shutil import copyfile | ||
import glob | ||
|
||
if not os.path.isdir('generating_images_demo'): | ||
os.mkdir('generating_images_demo') | ||
else: | ||
for filename in glob.glob('generating_images_demo/*.jpg'): | ||
os.remove(filename) | ||
|
||
def test_modulate(sample): | ||
outfile = 'generating_images_demo/modulate.jpg' | ||
if os.path.isfile(outfile): | ||
os.remove(outfile) | ||
iWidth = None | ||
iHeight = None | ||
with Image(filename=sample) as get_size: | ||
iWidth = get_size.width | ||
iHeight = get_size.height | ||
for y in range(-1000, 1001, 100): | ||
for x in range(-1000, 1001, 100): | ||
copy = 'generating_images_demo/src_copy.jpg' | ||
copyfile(sample, copy) | ||
xval = str(int((x+1000)/100)) | ||
# if len(xval) == 1: | ||
# xval = '0' + xval | ||
yval = str(int((y+1000)/100)) | ||
# if len(yval) == 1: | ||
# yval = '0' + yval | ||
with Image(filename=copy) as modify: | ||
modify.modulate(x, y) | ||
modify.save(filename='generating_images_demo/modulate_%s_%s.jpg' % (xval, yval)) | ||
os.remove(copy) | ||
|
||
files = sorted(glob.glob('generating_images_demo/*.jpg')) | ||
|
||
with Image(width=iWidth * 21, height=iHeight * 21) as final: | ||
for idx in range(len(files)): | ||
with Image(filename=files[idx]) as next_img: | ||
|
||
final.composite(image=next_img, top=(idx // 21), left=(idx % 21)) | ||
final.save(filename=outfile) | ||
return 0 | ||
|
||
def main(): | ||
test_modulate('stock_images/bce223b38aeed99d.jpeg') | ||
|
||
main() |