I had this same issue on NextcloudPi on the Odroid-HC2 with Nextcloud Version 21.
I first did this (installs for php 7.3):
sudo apt install php-imagick
sudo phpenmod imagick
sudo reboot (this took care of the error)
However, then I got an error complaining about lack of SVG support in imagick.
To fix this error, I used this thread: How to enable SVG for php-imagick and did the following:
sudo apt install libmagickcore-6.q16-6-extra
This solved the SVG issue.