new image layout algorithm