To expand on this; they both use GD by default, as it's the most widely-installed library with PHP extensions available out of the box.
But both have plugins/modules that you can use to switch the library to ImageMagick very easily, and some plugins/modules would require ImageMagick for specific functionality.