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.stack.imgur.com/2dEty.png"]
Column[{"text", Image[image, Magnification -> 1], "text"}]
The output I get looks like this in the front end:
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:
Table[
Column[{"text",
Pane[Image[image, Magnification -> 1],
ImageDimensions[image] + {0, k}], "text"}],
{k, 0, 5}
]
Grid
here: mathematica.stackexchange.com/a/753/12 $\endgroup$ImagePad
? $\endgroup$Magnification
, the cropping is eliminated if you useImage[image, Magnification -> 1.000001]
or higher magnification. An alternative is adding1
or more to the vertical range in bothPlotRange
andImageSize
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$