PHP was not working for me as I was encountering this libpng issue, so I reinstalled a new version with Homebrew.
However, I\'m getting a similar error with
In some cases, especially in Catalina, the Homebrew cask for the package may exist but not be properly linked. In that case try:
brew link libjpeg brew reinstall php --build-from-source