No BSD License  

Highlights from
Resize images and make HTML slideshow

from Resize images and make HTML slideshow by Adam O'Neill
Resize your digital camera photos then make a HTML slideshow to go on the web

resizepics(varargin);
function varargout = resizepics(varargin);

% Resize pictures
% Syntax: varargout = resizepics(varargin);
% Import: varargin = F, P
%            F = cell array of filenames
%            P = path to files
% Export: varargout = exitmsg
%            exitmsg = 'Done!' if OK, empty if not
% Notes:  ONLY REDUCES SIZES! (Why would you want to make photos for the web bigger?)

F = ''; P = 0; exitmsg = ''; scale = 0; string = '';
if nargin>=1; F = varargin{1}; P = strcat(cd,'\'); end
if nargin>=2; P = varargin{2}; end
if nargin>=3; scale = varargin{3}; end

if isempty(F) % Add more image filetypes as needed !  Actually - won't do GIF!
   [F,P] = uigetfiles('*.bmp;*.gif;*.jpg;*.jpeg;*.tif','Select image files...'); 
end

if P==0
   exitmsg = 'No image files !';
   return
end
F = sort(F);

if ~strcmp(P(length(P)),'\')
   P = strcat(P,'\');
end

Scales = {'10','20','25','33','40','50','66','75','80','90'};  % Add more if needed...
if scale==0
   %scale = input('Enter scale (%) =>'); % ...or just input by hand
   choice = menu('Reduction (in %)',Scales);
   scale = str2num(Scales{choice});
end
if scale==0 | isempty(scale); scale=100; end
scale = round(100/scale);

if isempty(string)
   string = input('Enter output file prefix =>','s');
end
if isempty(string); string = 'z'; end

h = waitbar(0,'Please wait...');

for k = 1:length(F)
   
   clear A X
   
   fileextn = F{k};
   [junk,file,extn] = fileparts(fileextn);
   filename = strcat(P,fileextn);
   fmt = extn(2:length(extn));
   
   A = imread(filename,fmt);
   
   [ny,nx,nz] = size(A);
   
   keepy = [1:scale:ny];
   keepx = [1:scale:nx];
   
   X = A(keepy,keepx,:);
   
   filename = strcat(P,string,file,extn);
   
   imwrite(X,filename,fmt);
   
   waitbar(k/length(F))
   fprintf('%3.0f %s %3.0f %s \n',k,'of',length(F),fileextn);
      
end

close(h);

fprintf('%s\n','Done !  Now use makeslideshow to make a HTML viewer');
exitmsg = 'Done!';

if nargout>=1; varargout{1} = exitmsg; end

Contact us at files@mathworks.com