Code covered by the BSD License  

Highlights from
Generate HTML Table with thumbnails from jpg images

image thumbnail
from Generate HTML Table with thumbnails from jpg images by Theodoros Giannakopoulos
Creates an html table that contains the thumbnails (and links) of the jpg images of a whole director

createThumbnailTable(Dir,HtmlName, TSize, imagesPerRow)
function createThumbnailTable(Dir,HtmlName, TSize, imagesPerRow)

%
% function createThumbnailTable(Dir,HtmlName, TSize, imagesPerRow)
% 
% This function generates an html file that contains a table with
% thumbnails (and respective links) of the images stored in a provided
% directory.
%
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%
% ARGUMENTS:
%  - Dir: the directory name in which the images are stored
%  - HtmlName: the name of the html file to be generated
%  - TSize: The size (in pixels) of the thumbnails images to be generated (the largest
%           of the two dimensions (width or height), depending on the image
%           orientation
%  - imagesPerRow: The number of thumbnails per row in the html page.
%
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%
%
% % % % % % % % % % % % % % % % % % % % % % % %
% Theodoros Giannakopoulos
% Dep. of Informatics and Telecommunications
% University of Athens
% http://www.di.uoa.gr/~tyiannak
% % % % % % % % % % % % % % % % % % % % % % % %
%

% generate thumbnails:
Dir2 = 'Thumbnails';
mkdir(Dir,Dir2);
resizeImageDir(Dir,Dir2,'ThumbNail_',TSize);

D = dir([Dir '/*.jpg']);
numOfCells = 0;

% Start writing the html file:
fp = fopen(HtmlName,'wt');
fprintf(fp,'<html>\n');
fprintf(fp,'<body bgcolor="aaccdd">\n');

fprintf(fp,'<p align = ''center''><font size = "4" color = "003388">Thumbnails for the images in the folder <b>''%s''</b></font>\n',Dir);

fprintf(fp,'<table width="100%%" border="1" cellpadding="0">\n');
for (i=3:length(D))            
    curFileName = D(i).name;
    curThumbName = ['ThumbNail_' D(i).name];
    if (mod(numOfCells, imagesPerRow)==0)
        if (numOfCells>0)
            fprintf(fp, '</tr>\n');
        end
        fprintf(fp, '<tr>\n');
    end
    fprintf(fp, '  <td align = ''center''>\n  <a href = "./%s/%s" target = "new"> <img src="./%s/%s/%s"> </a> </td>\n',...
        Dir, curFileName, Dir, Dir2, curThumbName);
    numOfCells = numOfCells + 1;
end
if (numOfCells>0)
    fprintf(fp, '</tr>\n');
end
fprintf(fp,'</table>\n');

fprintf(fp,'</body>\n');
fprintf(fp,'</html>\n');
fclose(fp);

open(HtmlName);

Contact us at files@mathworks.com