Hi,
Thank you for sharing this solution with the community. But we would also like to reiterate that this is a WP-level issue. The HivePress extension only calls the media_handle_upload function. With HivePress, we cannot decide which PHP library is used to load and process images at the WP level. This would be a violation.
Also, we recommend adding snippets through a child theme or the Code Snippet plugin because all the data will be restored after the update on our part if you change the direction or add this snippet in the theme files.