I am curious why we use 512 * 1024 here, shouldn't we use MAX_IMAGE_SIZE instead?