Newer
Older
labs / tiddlers / system / cheatsheet / $__Cheatsheet_Cheatsheet_Images_Optimising.tid
tags: cheatsheet
title: $:/Cheatsheet/Cheatsheet/Images/Optimising
type: text/vnd.tiddlywiki

Since everything is embedded directly inside the HTML file, you should try to keep any images as small as possible (in terms of file size) to prevent the HTML file from becoming too large.

!! SVG

`svgcleaner` seems to be the best tool for reliably shrinkifying SVG files (does a better job of using groups to apply shared styles than `scour`):

https://github.com/RazrFalcon/svgcleaner

Available in Arch as `community/svgcleaner`.

Run using:

```plaintext
svgcleaner file.svg file_opt.svg
```

If you want the output in a human readable form rather than one massive line:

```plaintext
svgcleaner --indent=1 file.svg file_opt.svg
```

!! PNG

`oxipng` seems to be the best of the commonly available PNG optimisers.  It has support for Zopfli which generally offers better compression than zlib.

https://github.com/shssoichiro/oxipng

Available in Arch as `community/oxipng`.

Run using:

```plaintext
oxipng --strip safe --alpha --zopfli -o max --out file_opt.png file.png
```