error in download png in R

If you are on a Debian distribution of Linux

sudo apt-get install libpng-dev

If you are on macOS and have homebrew installed

brew install libpng

might work.

If you are on Windows, may the heavens protect and preserve you.