# Help! My publisher wants a 300 dpi TIFF35

Posted by Steve Eddins,

MATLAB user Paul contacted me recently to ask how to convert 150dpi JPEGs to 300dpi TIFFs. After I asked for more information, he explained that he was working with a publisher who expected all electronically submitted images to be 4 inches by 6 inches at 300dpi.

There is often a conceptual disconnect between engineers and scientists doing image processing and printers or publishers. Publishers often seem to think that every image must have a physical size measured in inches, whereas MATLAB users may be working with data whose physical size may be more appropriately measured in kilometers or nanometers. Or the unit may not even be length. Or there may not be a meaningful physical unit at all. Some users don't know what the publisher is even talking about when they say "your image isn't 300dpi."

TIFF files have "resolution" tags in them. These tags specify the number of pixels per unit in the horizontal and vertical directions. The default unit is inches. By default, the MATLAB function imwrite sets these values to 72 pixels per inch, but imwrite has a syntax to specify a different value.

If your publisher specifies image requirements in inches and dpi, first convert that to the number of rows and columns in the image. 4 inches by 6 inches at 300dpi corresponds to 1200 pixels by 1800 pixels. (Caution: terminology confusion between "pixels" and "dots" is rampant and unavoidable. You'll have to rely on the context to figure out which term is meant.) Modify your image to be 1200 by 1800. (Resize it, crop it, compute it differently, etc.) Then save your 1200 by 1800 image to a TIFF file, specifying 300 as the resolution:

 imwrite(my_image, 'figure_10_a.tif', 'Resolution', 300); 

### Note

aslak grinsted replied on : 1 of 35

Many publishers also have restrictions on line-widths and font-sizes. I have written a piece of code that automatically can manipulate lines and fonts saving a figure in a varity of formats (eps,png,tif,…) at a specified DPI. Check savefigure in the fileexchange. Me and my mates use it all the time. It can also convert to black and white on the go.

It even attempts to move all axes within a figure to avoid figure boundaries clipping axes labels. This, however, does not work perfectly but can be manually adjusted using margins.

Steve replied on : 2 of 35

Aslak – thanks for the tip. It’s great that you put your savefigure utility on the File Exchange.

Mihail replied on : 3 of 35

What if my my_image is a figure?

THanks, Mihai.

Steve replied on : 4 of 35

Mihail – You could grab a screenshot of the figure using getframe, and then write out the captured image using imwrite.

Mihail replied on : 5 of 35

Thanks, it works. To kick it up a notch I summarized your knowledge in a function:
function writeFig300dpi(figNo, fileName)
%make the backgroung white
set(figNo,’color’,’w’);
f=getframe(figNo);
colormap(f.colormap);
imwrite(f.cdata, fileName, ‘Resolution’, 300);

Stephan replied on : 6 of 35

Is there any way in MatLab to change also the ‘Resolutionunit’, e.g. from inch to µm?

Steve replied on : 7 of 35

Stephan—The TIFF spec only has three options for resolution unit: inches, centimeters, or none. imwrite does not currently offer a way to change this setting.

Matt replied on : 8 of 35

So, there is no way to change the ppi and save it as a bmp, right?

Steve replied on : 9 of 35

Matt—nope.

Wissam replied on : 10 of 35

if i have an image named 2.jpg of the following parameters : 400*521 at 200 dpi bitdepth 24 into 316*634 at 96 dpi and 24 bitdepth

Wissam replied on : 11 of 35

what is the exact syntax i need to convert it ?

Damodar replied on : 12 of 35

hi steve
is there any way to write a binary image in arbitrary format(e.g,.ArbitraryHeader, .ArbitraryImage) not in matlab suported format?
sincerely,
Damodar

Steve replied on : 13 of 35

Wissam—You may find imresize to helpful. We don’t have a way to set the stored DPI value in a JPEG file, just TIFF.

Steve replied on : 14 of 35

Damodar—If you have a good description of the file format you are interested in, then you can use fopen and fwrite to write out image data in that format.

Gabriel replied on : 15 of 35

How can I draw a graph in Matlab with resolution of 1200 dpi and in grayscale ?
I know how to do a graph with 300 dpi and in RGB (which I believe are the default options) but I need a resolution of 1200 dpi and grayscale (and .tiff or .eps format) following the publisher requirements of a scientific journal.

Does anyone can help me please ??

Steve replied on : 16 of 35

Gabriel—Use print with the -d and -r options. The resulting file will be in RGB format, so you’ll need to read the file back in, convert it to gray scale using rgb2gray, and write it back out using imwrite and the 'Resolution' option.

Michael Yong replied on : 17 of 35

Hi, I have some scanned images if Tiff format. Is there a way for me to find out what resolution the image was scanned at>
Many thanks,
Michael Yong
35316614433

Steve replied on : 18 of 35

Michael—Look at the XResolution and YResolution fields in the output of imfinfo. If your scanner stored the information in the TIFF file, it should be in those fields.

Nawal replied on : 19 of 35

Thanks Steve..

Can you help me to determine dot per inch of image I use:
Rec=imfinfo(‘steve.bmp’)
HorzResolution=Rec.HorzResolution;

but it return 7874 insade of 199 that I see in file properity.

thanks

Steve replied on : 20 of 35

Nawal—I’d appreciate it if you would contact technical support (www.mathworks.com/support) and provide them with a sample file for us to examine.

Jon Hauris replied on : 21 of 35

Steve, I have been trying to order your book “DIP With Matlab” for a few months. Amazon is unable to get it. Are you coming out with a new edition or do you know why I can’t order it? Thanks, Jon

Steve replied on : 22 of 35

Jon—A transition from one publisher to another has left the book temporarily out of print. I’m very sorry about that! The good news is that the 2nd edition is almost ready.

May replied on : 23 of 35

So, resolution of an image means “dpi” and size of image is the number of pixels say 1200 x 1800. Am I right in this understanding?

Thanks.

May replied on : 24 of 35

I am always confused between the actual size of image (which we get in matlab “size(im)” and resolution) and now I have to measure in “mm” a segmented tube which is in number of pixels from the image…
Thanks.

Steve replied on : 25 of 35

May—I think there are actually three different notions of “size” floating around in your comments #23 and #24. First, there is the number of rows and columns in the image matrix (1200-by-1800 in your example). Second, there is the size of the image in inches or cm when printed. This is derived from the number of rows and columns and the Resolution and ResolutionUnit tags in the TIFF file. Finally, there is the physical size of the objects in the image. The units could be anything from nm to meters to light years.

Which of these things is called the “actual size” depends on who you ask and what kind of work they do.

May replied on : 26 of 35

Thanks Steve. My understanding got better! :)

Jan replied on : 27 of 35

I have a .tiff file that is 200 dpi and the publisher needs it to be 300 dpi. It is 1700 x 2200 pixels and I believe 8.5 x 11 inches, but I’m not sure. It won’t let me change the pixels. How do I change it or what software can I use so that it will work for me?

Steve replied on : 28 of 35

Jan—When you say “It won’t let me change the pixels,” what does “It” refer to?

This blog is about image processing and MATLAB, and the post you commented on talks about how to do the task using MATLAB.

If you don’t have MATLAB and want to use something else, then you should look for an image editing package. There are many such packages, some free and some commercial.

Sonja replied on : 29 of 35

My publisher is wanting images for a new book to be 300 dpi. Only 5 of the 19 images are 300, the rest are either 96 or 150. HOW DO I ENLARGE THE DPI?

Steve replied on : 30 of 35

Sonja—My imwritesize submission on the MATLAB Central File Exchange might be helpful. It was posted there earlier today.

Kumaran replied on : 31 of 35

Hi, I am importing a geotiff image using imread. I have the .tfw file which gives me the reference info.
I then perform some processing on the image and then which to wish to export the image as a geotiff.
The problem I am facing is that I am not sure what to put into the resolution parameters.
The reference data is the same, so I can reuse the tfw file and rename it accordingly.
What do I do with the the XResolution and YResolution parameters. I thought they should be the pixels per degree, but I cannot change the ResolutionUnit.

Can you provide any help on how to create a geotiff image with the proper referencing and resolution?

Steve replied on : 32 of 35

Kumaran—GeoTIFF referencing information is stored in a TIFF image using private tags, not using the XResolution and YResolution tags. I don’t know exactly how to do what you are asking. However, since you say the referencing info doesn’t change, you might be able to use the Tiff class (a R2009b) feature to copy the GeoTIFF tag info into your output TIFF file.

Peter replied on : 33 of 35

This code works for me. Get export_fig from:
http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig

figure('InvertHardcopy','off','Color',[1 1 1]); % Force the background to be white
plot(x, y);
export_fig([filepath filename 'full'], '-tif', '-cmyk', '-r300'); % For CMYK 300 DPI tiff images

Steve replied on : 34 of 35

Peter—Thanks!

AC replied on : 35 of 35

Hi all,
I have been struggling myself with this problem. Thanks for all the tips!
I just wanted to add: if you prefer to do it manually (as opposed to command line), once you plot a figure in MATLAB, you may simply click ‘File>Export Setup’. Then you can choose the Resolution and the size at the same time.
I thought this was convenient and simple enough to be mentioned here.

Wow, submission just became less time-consuming :)