I know that this is an extremely basic question, but I am having a lot of trouble finding the answer in the documentation.

When I import an image (for example, Import[test.png]), Mathematica often displays it smaller than the actual size of the image. How do I force Mathematica to display the imported image at actual size?

I may want to display such images using Grid. For example, suppose that fname is a list of *.png file names. Then I may want to import and display all of those images using a command like:

fname = FileNames["*.png"];
table = Transpose[{fname, Table[Import[fname[[i]]], {i, 1, Length[fname]}]}];

and I'd like the images displayed at actual size.

I know that this is a very basic question, but I really appreciate your time.


Programmatically I would use:

img = ExampleData[{"TestImage", "Lena"}];

Image[img, Magnification -> 1]

Manually you can right-click on the image and select Actual Size.

Edit: Although not as robust as what follows a simple solution to the resizing that takes place in Row, Grid, etc. is to wrap the Image or Graphics in Pane.

Within an Image there is raster data of a particular dimension:

Dimensions @ ImageData @ img

{512, 512, 3}

This is a 512 x 512 pixel image with three channels. Additionally the Image has options:


{ColorSpace -> "RGB", ImageSize -> Automatic, Interleaving -> True, Magnification -> Automatic}

The two options that control the displayed image size are ImageSize and Magnification.

When you use the the context menu to set Actual Size you remove (reset) the Magnification option and set ImageSize -> All. If you select a Magnification level you set ImageSize -> All and a Magnification value.

When you change the size of an image interactively by dragging the corners of the bounding box you remove (reset) the Magnification option an set a specific ImageSize value, e.g. ImageSize -> {171., Automatic}.

When you select Automatic Size you remove (reset) both options.

If numeric values for both options are given within Image the magnification is ignored:

Image[img, Magnification -> 40, ImageSize -> 200]

The Magnification option can also be used outside of Image, and it does not work the same as when it is set inside Image.

When used inside it prevents automatic scaling of the image, and it combines with Notebook magnification meaning that using Image[img, Magnification -> 2] inside a Notebook with magnification 50% produces a 1:1 image.

When used in Style as in Style[img, Magnification -> 2] it does not prevent automatic scaling of the image to fit the window if the two options within Image are either Automatic or not present. Further, this magnification level overrides the Notebook magnification rather than combining with it, but combines with the Image setting.

One may display the image raster 1:1 regardless of Notebook zoom for an arbitrary image using:

Style[Image[img, ImageSize -> All, Magnification -> 1], Magnification -> 1]
  • 2
    $\begingroup$ Note that this works as it should only IF Notebook's Magnification is set to 100% AND global Magnification in the $FrontEnd options is also set to 100%. I don't know if there a way to display an image in its actual size independently of these options. $\endgroup$ – Alexey Popkov Jul 22 '12 at 6:43
  • 1
    $\begingroup$ @Alexey you could always use: CellPrint[ExpressionCell[Image[img, Magnification -> 1], Magnification -> 1]] $\endgroup$ – Mr.Wizard Jul 22 '12 at 7:13
  • 1
    $\begingroup$ ... or just ExpressionCell[Image[img, Magnification -> 1], Magnification -> 1] if we wish just to show it in the standard "Output" cell. Brilliant! $\endgroup$ – Alexey Popkov Jul 22 '12 at 22:26
  • $\begingroup$ @Alexey I forgot about Style -- see my updated answer. $\endgroup$ – Mr.Wizard Jul 24 '12 at 9:41
  • $\begingroup$ Thanks for detailed analysis. Does Style have any advantages as compared to ExpressionCell? $\endgroup$ – Alexey Popkov Jul 24 '12 at 15:03

I guess:

i = ExampleData[{"TestImage", "Lena"}]; 
Image[#, ImageSize -> ImageDimensions[#]] &@i

will do.

  • 5
    $\begingroup$ Or, even simpler: Image[i,ImageSize -> All] $\endgroup$ – Niki Estner Jul 23 '12 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.