I have a problem where Column will occasionally cut off a single pixel from the top of images.

To reproduce the problem, evaluate this:

image = Import["https://i.sstatic.net/2dEty.png"]
Column[{"text", Image[image, Magnification -> 1], "text"}]

The output I get looks like this in the front end:

Mathematica graphics

Note that in Out[2] a single pixel wide row is cut off from the top of the image. It does not occur with all images, but it does with this particular one.

How can I work around this problem? This is on Win7. Can you reproduce on other platforms?

I need this for the image uploader palette (SOUploader`uploadWithPreview[] function to be specific).

It is interesting to note that if I wrap the image in a Pane, and set a pane-size explicitly (as in the original code of the palette), whether the row is cut off depends on whether the size is even or odd (I suspect a rounding issue):

Try this and notice that the cropping happens for even k only:

   Pane[Image[image, Magnification -> 1], 
    ImageDimensions[image] + {0, k}], "text"}],
 {k, 0, 5}
  • $\begingroup$ Possibly related: The gaps in the Grid here: mathematica.stackexchange.com/a/753/12 $\endgroup$
    – Szabolcs
    Jan 26, 2012 at 17:46
  • $\begingroup$ Everything's fine in my frontend, stupidname.org/files/temp/temp_2012_01/… $\endgroup$
    – David
    Jan 26, 2012 at 18:00
  • $\begingroup$ @David Probably Windows-only. $\endgroup$
    – Szabolcs
    Jan 26, 2012 at 18:12
  • $\begingroup$ seems to work fine on os x as well. If it's just for uploading, can't you pad the image with one pixel using ImagePad? $\endgroup$
    – Heike
    Jan 26, 2012 at 22:47
  • $\begingroup$ Playing with Magnification, the cropping is eliminated if you use Image[image, Magnification -> 1.000001] or higher magnification. An alternative is adding 1 or more to the vertical range in both PlotRange and ImageSize in the rasterized image like so: Graphics[Raster@Reverse@ImageData[image], PlotRange -> {{0, ImageDimensions[image][[1]]}, {0, 1 + ImageDimensions[image][[2]]}}, ImageSize -> {{0, ImageDimensions[image][[1]]}, {0, 1 + ImageDimensions[image][[2]]}}]. All this on Windows Vista. $\endgroup$
    – kglr
    Jan 27, 2012 at 0:00

2 Answers 2


This seems to be due to a small rounding issue on Windows.

Here is a test Manipulate:

 matrix = ArrayFlatten[Table[DiamondMatrix[size], {x}, {y}]];
 image = Image[matrix /. {0 -> {0, 0, 0}, 1 -> {255, 255, 255}},
  "Byte", ColorSpace -> "RGB", Interleaving -> True];
 Column[{"test", Image[image, Magnification -> 1], "test"}],
 {size, 1, 20, 1},
 {x, 1, 20, 1},
 {y, 1, 20, 1}

Under certain settings the top row of pixels in the image is cut off:

Mathematica graphics


Since I cannot reproduce the error I can only guess. Maybe setting the Spacings option for Column helps? This is what Spacing -> 0 looks like:

enter image description here

You can see the gray dividers above the image appearing and then not making it to the middle because of the overlap. Increasing spacing solves this problem, here's Spacing -> 1:

enter image description here

The lines are now visible, and nothing is clipped.

  • $\begingroup$ Thanks for the suggestion. Unfortunately Spacings doesn't change the incorrect rounding behaviour (and the cropping). $\endgroup$
    – Szabolcs
    Jan 27, 2012 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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