thumbnail and move pic from static
@ -0,0 +1,28 @@
|
||||
from glob import glob
|
||||
import os
|
||||
from shutil import copy2
|
||||
import frontmatter
|
||||
from pathlib import Path
|
||||
from PIL import Image
|
||||
|
||||
|
||||
|
||||
# from frontmatter import frontmatter
|
||||
for folder in glob('projects/*'):
|
||||
project = folder.replace('projects/', '')
|
||||
with open(os.path.join(folder,project+'.md'), 'r') as f:
|
||||
meta, content = frontmatter.parse(f.read())
|
||||
if 'cover' in meta:
|
||||
cover = meta.get('cover')
|
||||
file = Path(f'static/img2/{cover}')
|
||||
if file.is_file():
|
||||
try:
|
||||
with Image.open(file) as img:
|
||||
print(f'Ok im copying {cover} to {project}')
|
||||
f, e = os.path.splitext(cover)
|
||||
img.save(os.path.join(folder, f + '.jpg'))
|
||||
img.convert('RGB')
|
||||
img.thumbnail((256,256))
|
||||
img.save(os.path.join(folder, 'thumb_' + cover), 'JPEG')
|
||||
except:
|
||||
print(f"Couldn't convert {cover}")
|
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 119 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 274 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 154 KiB |
After Width: | Height: | Size: 6.5 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 71 KiB |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 291 KiB After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 190 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 248 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 479 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 113 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 181 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 452 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 73 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 357 KiB |
Before Width: | Height: | Size: 451 KiB After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 984 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 174 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 174 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 145 KiB |
After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 227 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 156 KiB |
After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 8.4 KiB |
After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 686 KiB |
After Width: | Height: | Size: 168 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 183 KiB |
Before Width: | Height: | Size: 910 KiB After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 230 KiB After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 83 KiB |