Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I have a large number of pictures, and I need to place each three of them in a grid with a certain layout. For example, if I have the following pictures:

p1 = 
  Import["http://images4.fanpop.com/image/photos/21900000/Beautiful-\
    Pictures-_-beautiful-pictures-21967793-1024-768.jpg"];
p2 = 
  Import["http://static.ddmcdn.com/gif/ice-ice-babies-pictures-2.jpg"];
p3 = 
  Import["http://latimesphoto.files.wordpress.com/2012/08/la-0824-pin01.jpg"];

The image dimensions of each is as follows:

ImageDimensions[#] & /@ {p1, p2, p3}

(* {{1024, 768}, {622, 468}, {970, 647}}  *)

I have resized the first 2 pictures:

{p11, p22} = ImageResize[#, 300] & /@ {p1, p2};

and now I want to place them together in one picture and then export them. I have tried Grid as follows:

all = Grid[{{p3, Column[{p11, p22}]}}]
Export["all.jpg", all]

The problem is that, Grid does not return the pictures in their correct size. So when I export, the result will be very small as seen in the pictures bellow. How can I get Grid to return the three pictures sized as I want?

enter image description here

share|improve this question

marked as duplicate by Mr.Wizard Jun 6 at 13:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 7 down vote accepted

Original answer

By default FrontEnd resizes graphics down inside list-like constructs. To prevent this inside Grid, set BaseStyle -> ImageSizeMultipliers -> 1 option for Grid:

all = Grid[{{p3, Column[{p11, p22}]}}, BaseStyle -> ImageSizeMultipliers -> 1];

Response to Mr.Wizard's comments

As Mr.Wizard notes in the comments, the ImageSizeMultipliers -> 1 does not fix another feature related to Image itself, citing the Documentation page for Image:

With Magnification->Automatic, smaller images are typically displayed at larger magnifications, and large images are reduced to fit within available notebook or other display areas.

Magnification->Automatic is the default option of Image, so if the whole Grid does not fit the screen area, all the images (sequentially starting from the largest one) are rescaled to fit the screen area. So more general workaround is:

all = Grid[{{p3, Column[{p11, p22}]}}] /. x_Image :> Image[x, Magnification -> 1]

If one wish to have Images always displayed and exported at their true sizes independently of any local or global Notebook's and FrontEnd's settings for the Magnification option, it is possible to achieve this by setting Magnification locally using Style:

Style[
   Grid[{{p3, Column[{p11, p22}]}}] /. x_Image :> Image[x, Magnification -> 1], 
   Magnification -> 1]

Now the magnification will be no longer affected by any local or global settings, for example

Magnify[%, 2]

Will display everything exactly at the original magnification.

share|improve this answer
    
Thanks a lot. this is what I am looking for. –  Algohi Jun 6 at 9:14
    
At least in version 7 this doesn't work (entirely). Rather than rendering large images at full pixel size it results in a scaling where all images fit on one screen width. Useful, but not what was requested. –  Mr.Wizard Jun 6 at 10:12
    
@Mr.Wizard I have added another, more general method. –  Alexey Popkov Jun 6 at 12:36
1  
Indeed, that jogged a memory. Note that to override a Notebook magnification you'll also need a Style[. . ., Magnification -> 1]. –  Mr.Wizard Jun 6 at 13:12
    
Thanks, added to the answer. –  Alexey Popkov Jun 6 at 13:44

In general, you can also use the ImageSize->All option for images to ensure that an image is always displayed full sized, even if it's in a list. So you could write:

all = Grid[{{Image[p3, ImageSize -> All], 
Column[{Image[p11, ImageSize -> All], 
  Image[p22, ImageSize -> All]}]}}]

(but I realize that's more typing in this specific case.)

share|improve this answer
2  
This method works for me. You can simplify its application with this: Grid[{{p3, Column[{p11, p22}]}} /. x_Image :> Image[x, ImageSize -> All]] –  Mr.Wizard Jun 6 at 10:14
    
@Mr.Wizard this method and your simplification are very nice. –  Algohi Jun 6 at 21:28

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