# Inconsistent image sizing with Grid and Row?

Can anyone explain why Row and Grid don't size the image correctly and consistently to 300 as specified in ImageResize?

image = ImageResize[Import["ExampleData/lena.tif"], 300];
image
Row[{image}]
Grid[{{image}}]
Row[{"abcd", image}]
Grid[{{"abcd", image}}]


GraphicsGrid doesn't seem to help either.

Any workarounds to do so?

• because you can paste images and use them as expressions just like anything else. The actual image size information is stored in the option ImageSizeRaw. When you say "GraphicGrid doesn't help either" what exactly do you want as the outcome? – Mike Honeychurch Jan 27 '15 at 4:42
• I've received (as of this comment) 2 useful but different workarounds. Mr.Wizard's the simplest and most direct and Mike's a bit more versatile in that it gives one additional control for sizing. How to chose? – Jagra Jan 27 '15 at 23:30
• @Mr.Wizard restores the actual image size without you have to know that actual size so would be a preferred option if that is all you need to do. – Mike Honeychurch Jan 28 '15 at 0:27
• @MikeHoneychurch - We should have a badge for sportsmanship! Many thanks. – Jagra Jan 28 '15 at 2:25
• just calling it the way i see it – Mike Honeychurch Jan 28 '15 at 2:51

Another approach (from this answer) is to re-set the value of the option ImageSizeMultipliers to {1.,1.} :

image = ImageResize[Import["ExampleData/lena.tif"], 250];
image2 = ImageResize[ExampleData[{"TestImage", "Mandrill"}], 150];


With the default settings

image
image2
Grid[{{"abcd", image, image2}}]


gives

After evaluating

SetOptions[EvaluationNotebook[], ImageSizeMultipliers -> {1., 1.}]


anywhere in the notebook, we get

You can reset the option value to its default using:

SetOptions[EvaluationNotebook[], ImageSizeMultipliers -> {.5, .25}]


An alternative, more cumbersome, approach is to wrap each object with Style[#, ImageSizeMultipliers->{1.,1.}:

dontResizeF = Style[#, ImageSizeMultipliers -> {1., 1.}] &;
image
image2
Grid[{{"abcd", dontResizeF@image, dontResizeF@image2}}]


• Thanks for this. This gives one a much better idea about what Mathematica might actually do under the hood. It does seem odd, that the default values of ImageSizeMultiplier don't equal {1.,1.}. – Jagra Mar 9 '15 at 13:28
• Jagra, my pleasure. The default value makes using images/graphs in Input cells more convenient. I agree with you that, for output cells, default value of 1 would make more sense. – kglr Mar 9 '15 at 13:54
• I've decided to select your answer as the best one (sorry @Mr.Wizard), because while the others provide workarounds, this one actually provides some insight and explanation of why the problem occurs. Thanks again. – Jagra Mar 9 '15 at 22:29
• @Jagra No problem! I encouraged kguler to (re)post this here. I agree it is the best answer. For application to one item at a time I'll still use Pane, but it is a side-effect rather than the specific purpose of that construct, unlike the Option described here. – Mr.Wizard Mar 10 '15 at 2:23
• @Jagra, thank you for the Accept. – kglr Mar 10 '15 at 8:57

My standard(1) work-around for this problem is to add Pane:

Grid[{{Pane@image}}]
Row[{"abcd", Pane@image}]
Grid[{{"abcd", Pane@image}}]


A default characteristic of Pane is that it still allows resizing its contents to fit the window width of the Notebook. I find this a desirable default behavior. However if clipping is preferred you can specify an absolute width for Pane, or use ImageSize as Mike Honeychurch proposed.

Grid@{Table[image, {2}]}
Grid@{Table[Pane@image, {2}]}
Grid@{Table[Pane@image, {3}]}
Grid@{Table[Pane[image, 300], {3}]}


For more control see:

As per my comment you will note that images can be pasted into notebooks and used as expressions. They are not rendered at full size but the size information is stored as an option. If all you want to do is have Row and Grid render something to the same specific size then try Show:

Row[{"abcd", Show[image, ImageSize -> 300]}]
Grid[{{"abcd", Show[image, ImageSize -> 300]}}]