Skip to content

Instantly share code, notes, and snippets.

@nh2
Created May 26, 2020 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nh2/e056642c8bed55b3bbccb612158c2cab to your computer and use it in GitHub Desktop.
Save nh2/e056642c8bed55b3bbccb612158c2cab to your computer and use it in GitHub Desktop.
Compresstion/decompression benchmark between JPEG and WebP with ImageMagick
set -e
set -x
echo "Cat"
wget --no-clobber 'https://homepages.cae.wisc.edu/~ece533/images/cat.png'
identify 'cat.png'
echo "Cat - 100%"
time convert 'cat.png' -quality 100 test.webp
time convert 'cat.png' -quality 100 test.jpeg
du --apparent-size -h test.webp test.jpeg
time convert test.webp test.bmp
time convert test.jpeg test.bmp
echo "Cat - 50%"
time convert 'cat.png' -quality 50 test.webp
time convert 'cat.png' -quality 50 test.jpeg
du --apparent-size -h test.webp test.jpeg
time convert test.webp test.bmp
time convert test.jpeg test.bmp
echo "Grand Canyon"
wget --no-clobber 'https://upload.wikimedia.org/wikipedia/commons/a/af/Grand_Canyon_view_from_Pima_Point_2010.jpg'
identify 'Grand_Canyon_view_from_Pima_Point_2010.jpg'
echo "Grand Canyon - 100%"
time convert 'Grand_Canyon_view_from_Pima_Point_2010.jpg' -quality 100 test.webp
time convert 'Grand_Canyon_view_from_Pima_Point_2010.jpg' -quality 100 test.jpeg
du --apparent-size -h test.webp test.jpeg
time convert test.webp test.bmp
time convert test.jpeg test.bmp
echo "Grand Canyon - 50%"
time convert 'Grand_Canyon_view_from_Pima_Point_2010.jpg' -quality 50 test.webp
time convert 'Grand_Canyon_view_from_Pima_Point_2010.jpg' -quality 50 test.jpeg
du --apparent-size -h test.webp test.jpeg
time convert test.webp test.bmp
time convert test.jpeg test.bmp
[nix-shell:~/Pictures]$ bash bench.sh
+ echo Cat
Cat
+ wget --no-clobber https://homepages.cae.wisc.edu/~ece533/images/cat.png
File ‘cat.png’ already there; not retrieving.
+ identify cat.png
cat.png PNG 490x733 490x733+0+0 8-bit sRGB 663451B 0.000u 0:00.000
+ echo 'Cat - 100%'
Cat - 100%
+ convert cat.png -quality 100 test.webp
real 0m0.626s
user 0m0.605s
sys 0m0.018s
+ convert cat.png -quality 100 test.jpeg
real 0m0.046s
user 0m0.038s
sys 0m0.007s
+ du --apparent-size -h test.webp test.jpeg
454K test.webp
317K test.jpeg
+ convert test.webp test.bmp
real 0m0.032s
user 0m0.023s
sys 0m0.009s
+ convert test.jpeg test.bmp
real 0m0.027s
user 0m0.020s
sys 0m0.006s
+ echo 'Cat - 50%'
Cat - 50%
+ convert cat.png -quality 50 test.webp
real 0m0.077s
user 0m0.066s
sys 0m0.010s
+ convert cat.png -quality 50 test.jpeg
real 0m0.039s
user 0m0.030s
sys 0m0.008s
+ du --apparent-size -h test.webp test.jpeg
40K test.webp
47K test.jpeg
+ convert test.webp test.bmp
real 0m0.027s
user 0m0.018s
sys 0m0.008s
+ convert test.jpeg test.bmp
real 0m0.023s
user 0m0.018s
sys 0m0.005s
+ echo 'Grand Canyon'
Grand Canyon
+ wget --no-clobber https://upload.wikimedia.org/wikipedia/commons/a/af/Grand_Canyon_view_from_Pima_Point_2010.jpg
File ‘Grand_Canyon_view_from_Pima_Point_2010.jpg’ already there; not retrieving.
+ identify Grand_Canyon_view_from_Pima_Point_2010.jpg
Grand_Canyon_view_from_Pima_Point_2010.jpg JPEG 2848x4288 2848x4288+0+0 8-bit sRGB 4.73281MiB 0.000u 0:00.000
+ echo 'Grand Canyon - 100%'
Grand Canyon - 100%
+ convert Grand_Canyon_view_from_Pima_Point_2010.jpg -quality 100 test.webp
real 0m13.373s
user 0m13.206s
sys 0m0.149s
+ convert Grand_Canyon_view_from_Pima_Point_2010.jpg -quality 100 test.jpeg
real 0m0.514s
user 0m0.464s
sys 0m0.045s
+ du --apparent-size -h test.webp test.jpeg
13M test.webp
8.4M test.jpeg
+ convert test.webp test.bmp
real 0m0.442s
user 0m0.340s
sys 0m0.095s
+ convert test.jpeg test.bmp
real 0m0.254s
user 0m0.184s
sys 0m0.068s
+ echo 'Grand Canyon - 50%'
Grand Canyon - 50%
+ convert Grand_Canyon_view_from_Pima_Point_2010.jpg -quality 50 test.webp
real 0m1.363s
user 0m1.297s
sys 0m0.052s
+ convert Grand_Canyon_view_from_Pima_Point_2010.jpg -quality 50 test.jpeg
real 0m0.326s
user 0m0.267s
sys 0m0.059s
+ du --apparent-size -h test.webp test.jpeg
600K test.webp
1.1M test.jpeg
+ convert test.webp test.bmp
real 0m0.233s
user 0m0.160s
sys 0m0.071s
+ convert test.jpeg test.bmp
real 0m0.170s
user 0m0.111s
sys 0m0.057s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment