Resize image width to match the number of pages