Skip to content

Commit 54fcec2

Browse files
authored
Merge pull request #203 from takluyver/squash-images-pngcrush
Resize and squash images
2 parents 97e13ef + 5964168 commit 54fcec2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+42
-7063
lines changed

_sections/30-projects.md

Lines changed: 2 additions & 2 deletions

assets/adb_enhanced.png

-17.1 KB

assets/angr.png

-56 KB

assets/astropy.png

-3.32 KB

assets/axelrod.png

-6.65 KB

assets/biobuilds.png

-13 KB

assets/biopython.png

-14.2 KB

assets/bokeh.png

-32.8 KB

assets/ccxt.png

-440 Bytes

assets/chaquopy.png

-29.2 KB

assets/cmd2.png

-6.67 KB

assets/dateutil.png

-4.16 KB

assets/fecon235.png

-144 KB

assets/fenics.png

-31.1 KB

assets/fonttools.png

-56.7 KB

assets/freud.png

-32.3 KB

assets/geopy.png

-3.68 KB

assets/hypothesis.png

14.2 KB

assets/hypothesis.svg

Lines changed: 0 additions & 94 deletions
This file was deleted.

assets/ipython.png

-29.9 KB

assets/jupyter.png

-15.1 KB

assets/kivy.png

-481 Bytes

assets/matplotlib.png

-37.5 KB

assets/metpy.png

-5.9 KB

assets/mitmproxy.png

-24.8 KB

assets/mne.png

-10.2 KB

assets/nengo.png

-26.5 KB

assets/nikola.png

-12 Bytes

assets/numpylogoicon.png

22 KB

assets/numpylogoicon.svg

Lines changed: 0 additions & 6967 deletions
This file was deleted.

assets/openquake.png

-1.72 KB

assets/osbrain.png

-3.45 KB

assets/pandas.png

-1.77 KB

assets/pillow.png

-2.65 KB

assets/psi4square.png

-233 KB

assets/pylast.png

-642 Bytes

assets/pymc3.png

-43.4 KB

assets/pymeasure.png

-3.49 KB

assets/pyscipopt.png

-866 Bytes

assets/pystan.png

-12.1 KB

assets/pytest1.png

-1.56 KB

assets/pythran.png

-220 Bytes

assets/rdkit.png

-2.65 KB

assets/requests.png

-2.12 KB

assets/rpy2_logo_64x64.png

-851 Bytes

assets/saltstack.png

-11.9 KB

assets/scikit-image.png

-26 KB

assets/scikit-learn.png

-1.06 KB

assets/scipyshiny_small.png

-1.32 KB

assets/signac.png

-1.47 KB

assets/skbio.png

-2.88 KB

assets/spyder.png

11 Bytes

assets/sunpy.png

-1.55 KB

assets/swcarpentry.png

-11.1 KB

assets/sympy.png

-14.5 KB

assets/tensorflow.png

6 Bytes

assets/tensorpack.png

-69.2 KB

assets/tornado.png

-1.09 KB

assets/toyplot-256x256.png

-24.6 KB

assets/tryton.png

-3.32 KB

assets/xarray.png

-86.4 KB

assets/xonsh.png

-30.3 KB

assets/yt.png

-574 KB

assets/zulip.png

-767 Bytes

img/bgnoise.png

-16.5 KB

scripts/squash-images.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# pip install pillow
5+
python3 scripts/thumbnail-images.py
6+
7+
# https://pmt.sourceforge.io/pngcrush/
8+
# On Mac: brew install pngcrush
9+
10+
# Options:
11+
# -ow Overwrite
12+
# -brute Use brute-force: try 176 different methods
13+
14+
find . -iname '*.png' -exec pngcrush -ow -brute {} \;

scripts/thumbnail-images.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python3
2+
# encoding: utf-8
3+
"""
4+
Thumbnail images to a maximum of 320px wide and 160px high
5+
"""
6+
import glob
7+
8+
from PIL import Image # pip install pillow
9+
10+
max_size = 320, 160
11+
12+
# Exclude these images from thumbnailing
13+
excludes = ["assets/signac.png"]
14+
15+
for infile in glob.glob("assets/*.png"):
16+
if infile in excludes:
17+
continue
18+
im = Image.open(infile)
19+
if im.width <= max_size[0] and im.height <= max_size[1]:
20+
continue
21+
22+
size_before = im.size
23+
im.thumbnail(max_size)
24+
im.save(infile)
25+
26+
print(f"Resized {infile} from {size_before} to {im.size}")

0 commit comments

Comments
 (0)