Code covered by the BSD License  

Highlights from
HTML Indexer

image thumbnail

HTML Indexer

by

 

16 Aug 2004 (Updated )

automated multi-language html index, index for print, batch image scaling

prjCheckFile(path, name, Options, Nav);
function FileEntry = prjCheckFile(path, name, Options, Nav);

% FileEntry = prjCheckFile(path, name);
%
% verifica fisieru spec de path/name daca e imagine, 
% si intoarce o intrare (path $empty daca nu)
%
% nou quadra v.0.4, 07.11.2003
% v.0.46a   - 15.04.2004, smartscale added

if nargin < 2 disp('prjCheckFile : no path specified'); end;
if nargin < 3 Options = uConstr('options'); disp('prjCheckFile: using default options'); end;
if nargin < 4 Nav = uConstr('nav'); end;

% sorteaza known types (tif, jpg, gif, etc.)
%   'jpg' or 'jpeg' Joint Photographic Experts Group (JPEG)
%   'tif' or 'tiff' Tagged Image File Format (TIFF)
%   'gif'           Graphics Interchange Format (GIF)
%   'bmp'           Windows Bitmap (BMP)
%   'png'           Portable Network Graphics
%   'hdf'           Hierarchical Data Format (HDF)
%   'pcx'           Windows Paintbrush (PCX)
%   'xwd'           X Window Dump (XWD)
%   'cur'           Windows Cursor resources (CUR)
%   'ico'           Windows Icon resources (ICO)

known_extensions = {'jpg', 'jpeg', 'tif', 'tiff', 'gif', 'bmp', 'png', 'hdf', 'pcx', 'xwd', 'cur', 'ico'}; 
FileEntry = uConstr('fileinfo');

namelength = size(name,2); base = namelength; extension = ''; type = 'unknown';
if (namelength > 4) % - recunoaste extensia & radacina
    p=namelength;
    
    while p>0
        p=p-1;
        if strcmp(name(p),'.')
            base = name(1:p-1);
            extension = name(p+1:namelength);
            switch lower(extension)
                case 'tiff' 
                    type = 'tif';;
                case 'jpeg' 
                    type = 'jpg';
                otherwise
                    type = lower(extension);
            end;
            break;
        end;
    end;
end;

if sum(strcmp(type,known_extensions)) %  fa bucataria cu info
    fprintf(1, '%s', '.')
    FileEntry.path = path;
    FileEntry.name = name;
    FileEntry.base = base;
    FileEntry.extension = extension;
    FileEntry.type = type;
    info = imfinfo(fullfile(path, name)); info = info(1);
    FileEntry.scalefactor_th = max(info.Width,info.Height)/Options.ThSize;     
    FileEntry.scalefactor_gy = max(info.Width,info.Height)/Options.GySize;
    if Options.smartscale % acum doar closest, aci mai tirziu smaller, larger
        FileEntry.scalefactor_th = round(FileEntry.scalefactor_th);
        FileEntry.scalefactor_gy = round(FileEntry.scalefactor_gy);
    end;
    FileEntry.th_height = round(info.Height/FileEntry.scalefactor_th);
    FileEntry.th_width = round(info.Width/FileEntry.scalefactor_th);
    FileEntry.gy_height = round(info.Height/FileEntry.scalefactor_gy);
    FileEntry.gy_width = round(info.Width/FileEntry.scalefactor_gy);
    FileEntry.or_height = info.Height;
    FileEntry.or_width = info.Width;
    
    FileEntry.TextOver = base;
    FileEntry.Legenda = base;
    for i=2:size(Options.languages,1)
        FileEntry.TextOver = strvcat(FileEntry.TextOver, base);
        FileEntry.Legenda = strvcat(FileEntry.Legenda, base);
    end;
else 
    fprintf(1, '%s', '-')
end;

Contact us