Code covered by the BSD License  

Highlights from
Print ID photo on 4x6 photo paper

image thumbnail
from Print ID photo on 4x6 photo paper by Zhen Qian
Print your passport or visa or other ID photos on a 4x6-inch-sized photo paper

ResizePhoto(i,a)
function i = ResizePhoto(i,a)
% Crop the input photo into specified size

[h,w,z] = size(i);

if h/w>a
    ho = a*w;
    d = ceil((h-ho)/2);
    i = i(d+1:end-d,:,:);
else
    wo = h/a;
    d = ceil((w-wo)/2);
    i = i(:,d+1:end-d,:);
end

Contact us at files@mathworks.com