Skip to main content

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}}]

enter image description here


GraphicsGrid doesn't seem to help either.


Any workarounds to do so?



Answer



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



enter image description here




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

With the default settings


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

gives


enter image description here



After evaluating


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

anywhere in the notebook, we get


enter image description here


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}}]

enter image description here


Comments