Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On the page the example code has ImageSize -> 1 -> 1. I am unfamiliar with this chaining of rules... What does it mean? Note I know what ImageSize does, it is the TWO arrows that I don't understand.

share|improve this question
syntactically it sets the ImageSize option to the rule "1->1". What that means in terms of Graphics I don't know and It doesnt appear to be documented (It definitely does something , its not an error and its not the same as ImageSize->1 ) – george2079 Mar 11 '14 at 19:02
FYI: This syntax is not recognized in version 7. – Mr.Wizard Mar 12 '14 at 1:06
up vote 14 down vote accepted

Using FullForm, you can see that ImageSize -> 1 -> 1 is the same as ImageSize -> (1 -> 1) i.e., the option value itself is a rule. This appears to be an undocumented shorthand for scaling a graphics to the correct image size or to scale up/down by a factor.

Observe the following, using a modified version of the example:

img = Import@""

scale[a_, b_] := Module[{faces = FindFaces[img]},
    ImageDimensions@Graphics[Disk[Mean[##], First@Differences[##]/2] & /@ faces, 
        PlotRange -> Transpose[{{0, 0}, ImageDimensions[img]}], ImageSize -> a -> b]

scale @@@ Tuples[{1, 2}, 2]
(* {{285, 228}, {570, 456}, {143, 114}, {285, 228}} *)

{285, 228} is the size of img and the rest are scaled up/down. You can interpret the rule as ImageSize -> originalScale -> resizedScale. Leaving out this option is not the same, because then the size of the graphics is {360, 288}.

This is very handy when used with functions like ImageCompose, ImageAdd, ImageMultiply, because you can very easily set the mask to be the same size as the original image or scale the same mask for different sizes of the image without having to calculate or recompute the dimensions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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