Anyone else use TinyPNG?

I just setup a script so I run tinypng in a folder full of images and it compresses them using the tinypng.com service.

55 jpg/png images compressed from 2.9mb down to 1.4mb, quite happy:

dtbaker@laptop: [images]$  ls -l |wc -l
55
dtbaker@laptop: [images]$  du -sh .
2.9M	.
dtbaker@laptop: [images]$  tinypng
 ( waits 5 minutes )
dtbaker@laptop: [images]$  du -sh .
1.4M	.

score!

Great for rolling up a smaller theme zip file for buyers.

Bash script:

#!/bin/bash
echo "Converting JPG and PNG files using TinyPNG";
for i in *.{jpg,png}
do
        JSON=`curl --user api:PUT-YOUR-API-KEY-HERE --data-binary @$i -i https://api.tinify.com/shrink 2>/dev/null  `;
        URL=${JSON/*url\":\"/};
        URL=${URL/\"*/};
        curl $URL>${i} 2>/dev/null
        echo "${i} updated.";
done
1 Like