According to the Hostgator forums ImageMagick should be installed on your server. I would recommend using a binary for something such as image resizing because of sheer efficiency. To do what you are looking to do, a command such as this will suffice (assuming you want the 2 MB you asked for):
$SCALED_VALUE = (2097152/filesize($OLD_IMAGE))*100; #< Get the percentage of scaling that is required to go to 2MB
shell_exec('convert '. $OLD_IMAGE . '-resize ' . $SCALED_VALUE . '% new_image.jpg'); #< Perform scaling
To answer the question regarding php_memory_limit in the comments; this limit is within PHP and will not affect ImageMagick (or any other application other than PHP).