avoid allocating images larger than 4096*4096
check image_ptr prior deref