File Exchange

image thumbnail

makethumbdir

version 1.0.0.0 (2.78 KB) by Brett Shoelson
Create thumbnails for all MATLAB-writeable image types of a given extension in a selected directory.

2 Downloads

Updated 03 Feb 2003

View License

Editor's Note: This file was a File Exchange Pick of the Week

Syntax: MAKETHUMBDIR(MAXSIZE, KEEPFRAC)

The user is prompted to select any image in the folder to be "thumbnailed." The mfile will then create thumbnails for all MATLAB-writeable image types having the same extension as the selected image and residing in the selected directory, and store them in a thumbnail folder within that directory. Thumbnails will have the same name as their parent images, although their paths will necessarily be different.

ARGUMENTS:

Two OPTIONAL ARGUMENTS, as follows:

MAXSIZE is the maximum size of the thumbnail, in kB. The default value of MAXSIZE is 32 (kB).Note that some image writing algorithms produce images that are further compressed; maxsize is a target for the number of bytes in an uncompressed version of the thumbnail image; thumbnails will not be larger than maxsize, but they may be considerably smaller.

KEEPFRAC (which, if it is provided, must be a positive integer greater than 1) determines the number of rows and columns maintained from the original image. A thumbnail for a "2-dimensional" (eg., indexed or grayscale) image should approach 1/keepfrac^2 times the size of its parent image, or 3/keepfrac^2 for "3-dimensional" (eg., truecolor or RGB) images. For example, if the value is set to 8, a thumbnail for a grayscale image will approach 1/64th the size of the parent image.

BY DEFAULT, the value is set dynamically for each parent image to target a thumbnail that is no larger than MAXSIZE kB. However, if KEEPFRAC is provided, MAXSIZE is ignored. The program supports all image file types writeable by MATLAB:

JPEG, TIFF, BMP, PNG, HDF, PCX, or XWD.

The user will be presented with a uigetfile dialog box in which to select a single image to thumbnail. All images of the same extension/type in the same folder will be similarly thumbnailed.

EXAMPLE: makethumbdir %Creates a default series of thumbnails of maximum 32 kB.

makethumbdir(64) %May be of higher resolution, with images possibly ranging up to 64 kB.
makethumbdir([],4) %Writes thumbnails comprising every 4th row and column
makethumbdir(64,4) %Writes thumbnails comprising every 4th row and column

(first argument is ignored)

Written by Brett Shoelson (shoelson@helix.nih.gov; shoelson@hotmail.com).
Last update 1/31/03.
Tested under R12.1 and R13

Cite As

Brett Shoelson (2021). makethumbdir (https://www.mathworks.com/matlabcentral/fileexchange/2983-makethumbdir), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Anoop Sadani

fantastic!! I tried it and it worked the way I wanted it to!! Great utility for Website having many pictures - Can be used for making thumbnails of the Photograph which can then be hyper-linked to full size photographs.

Fahad Al Mahmood

Great function indeed! I just hope that one day it would be updated to accommodate keeping the transparency of the images when thumbnails are created :)

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!