write image
calc rect