% % stack: pw ph sw sh % second 1.0 mul 4 index div second 1.0 mul 4 index div % % stack: pw ph sw sh pw/sw ph/sh % 2 copy gt { % % width ratio greater than height ratio % use height ratio to create size of picturebox % pop2nd } { % % width ratio less than height ratio % use width ratio to create size of picturebox % pop } ifelse dup !ratio % % stack: pw ph sw sh ratio % 5 1 roll pop2 third mul normint tuck mul normint exch % % stack: fitw fith %