Be smart about thumbnailing and uploading benches
This commit is contained in:
19
bench.sh
19
bench.sh
@@ -4,14 +4,17 @@ set -e
|
||||
set +x
|
||||
|
||||
for FILE in img/bench/webp-src/*.jpg; do
|
||||
OUT="${FILE%.*}.webp"
|
||||
OUT2X="${FILE%.*}@2x.webp"
|
||||
if [ ! -f ../$OUT ]; then
|
||||
cwebp -mt -resize 160 0 -q 40 $FILE -o $OUT
|
||||
FULLNAME=$(basename -- ${FILE})
|
||||
NAME=${FULLNAME%.*}
|
||||
OUT="img/bench/${NAME}.webp"
|
||||
OUT2X="img/bench/${NAME}@2x.webp"
|
||||
echo "Checking for \"${OUT}\"..."
|
||||
if [ ! -f "${OUT}" ]; then
|
||||
echo "Would thumbnail ${OUT}"
|
||||
cwebp -mt -resize 160 0 -q 40 ${FILE} -o ${OUT}
|
||||
fi
|
||||
if [ ! -f ../$OUT2X ]; then
|
||||
cwebp -mt -q 40 $FILE -o $OUT2X
|
||||
if [ ! -f "${OUT2X}" ]; then
|
||||
echo "Would thumbnail@2x ${OUT2X}"
|
||||
cwebp -mt -q 40 ${FILE} -o ${OUT2X}
|
||||
fi
|
||||
done
|
||||
|
||||
mv img/bench/webp-src/*.webp img/bench/
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<a href="/img/bench/065.jpg"><picture><source type="image/webp" srcset="/img/bench/065.thumb.webp, /img/bench/065.thumb@2x.webp 2x"><img src="/img/bench/065.thumb.jpg"></picture></a>
|
||||
<a href="/img/bench/066.jpg"><picture><source type="image/webp" srcset="/img/bench/066.thumb.webp, /img/bench/066.thumb@2x.webp 2x"><img src="/img/bench/066.thumb.jpg"></picture></a>
|
||||
<a href="/img/bench/067.jpg"><picture><source type="image/webp" srcset="/img/bench/067.thumb.webp, /img/bench/067.thumb@2x.webp 2x"><img src="/img/bench/067.thumb.jpg"></picture></a>
|
||||
<a href="/img/bench/068.jpg"><picture><source type="image/webp" srcset="/img/bench/068.thumb.webp, /img/bench/068.thumb@2x.webp 2x"><img src="/img/bench/068.thumb.jpg"></picture></a>
|
||||
|
||||
</div>
|
||||
<div class="nav">
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<img id="aaron" alt="Aaron" src="img/aaron.jpg"
|
||||
srcset="img/aaron.jpg, img/aaron@2x.jpg 2x,img/aaron@3x.jpg 3x">
|
||||
<p>
|
||||
Integrations Engineer @ <a href="https://asana.com">Asana</a><br>
|
||||
Platform Engineer @ <a href="https://asana.com">Asana</a><br>
|
||||
Carnegie Mellon University, SCS 2017
|
||||
</p>
|
||||
</header>
|
||||
|
||||
12
pub.py
12
pub.py
@@ -26,10 +26,18 @@ TYPE_MAP = {
|
||||
'webp': 'image/webp',
|
||||
}
|
||||
|
||||
def upload_file(filename):
|
||||
def upload_file(filename, overwrite=True):
|
||||
print('Uploading {} to {}/{}'.format(filename, BUCKET, filename))
|
||||
ext = filename.split('.')[-1]
|
||||
|
||||
if not overwrite:
|
||||
try:
|
||||
existing = s3.get_object(Bucket=BUCKET, Key=filename)
|
||||
print('\tSkipping existing key ', filename)
|
||||
return
|
||||
except:
|
||||
pass
|
||||
|
||||
s3.upload_file(filename, BUCKET, filename, ExtraArgs={
|
||||
'ACL': 'public-read',
|
||||
'ContentType': TYPE_MAP[ext]
|
||||
@@ -77,7 +85,7 @@ def upload_bench():
|
||||
upload_file('bench/{}'.format(f))
|
||||
|
||||
for f in img_files:
|
||||
upload_file('img/bench/{}'.format(f))
|
||||
upload_file('img/bench/{}'.format(f), overwrite=False)
|
||||
|
||||
def upload_img():
|
||||
files = filter_filenames(os.listdir('img'), ['jpg', 'webp'])
|
||||
|
||||
Reference in New Issue
Block a user