IMWRITESIZE Write image file with specified width and resolution

Write a TIFF or PNG image file with specified width (inches) and resolution (dpi).

You are now following this Submission

imwritesize(A, FILENAME, WIDTH) writes the image A to the specified FILENAME in either TIFF or PNG format. Resolution information is written into the file so that many document and graphics printing applications (e.g., Microsoft Word, Adobe Photoshop and Illustrator, PDFLaTeX) will treat the image as having the specified WIDTH in inches. The input image A can be either grayscale or RGB; indexed images are not supported.

If the specified FILENAME ends in .tif, .tiff, or .png, the appropriate file format will be used. Otherwise, the image will be written as a TIFF file using the specified FILENAME with no additional extension.

imwritesize(A, FILENAME, WIDTH, RESOLUTION) resizes the image A if necessary so that it can be written to the file with both the specified WIDTH in inches as well as the specified RESOLUTION in pixels per inch. (This syntax requires the Image Processing Toolbox.)
EXAMPLES

% Write out an image as a PNG file so that document and
% graphics applications will treat it as being 2 inches wide.
A = imread('rice.png');
imwritesize(A, 'rice_2in.png', 2);

% Write out an image as a TIFF file so that document
% and graphics applications will treat it as being
% 3.5 inches wide with a resolution of 300 dpi.
A = imread('rice.png');
imwritesize(A, 'rice_3.5in_300dpi.tif', 3.5, 300);

Cite As

Steve Eddins (2026). IMWRITESIZE Write image file with specified width and resolution (https://in.mathworks.com/matlabcentral/fileexchange/25595-imwritesize-write-image-file-with-specified-width-and-resolution), MATLAB Central File Exchange. Retrieved .

Categories

Find more on Images in Help Center and MATLAB Answers

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.1

Updated license

1.0.0.0