Handle cases where loadImage failed to load the image.
Added option to set imagick resource limits.

Destroy old image objects in gd_set_image_object method.