18

Bug introduced in V9.0 or earlier and persisting through V11.2


pic2 = ImageResize[
  ImageCrop@Rasterize@Graphics@Disk[],
  {Automatic, 40}]

enter image description here

Grid[{{pic2}}]

enter image description here

This is just annoying...

Win 10 V10.3.1

Q: so, is there any quick fix? Have I missed something obvious?

p.s. e.g. Row works well but it is not Grid :-)


A support case with the identification [CASE:3522370] was created:

Thank you for contacting Wolfram Technical Support.

I have filed a report regarding the behavior you describe. The appropriate development team will be able to review the issue and hopefully implement a fix in a future version.

Fortunately this is not an issue with the object itself, but with its visual representation in the Mathematica front end. Although not a practical workaround, if you increase your magnification from 100% to 200%, you will notice the problem no longer persists. Similarly, if I printed the notebook demonstrating the issue I did not experience the clipping.

If you are able to get away without using ImageCrop, the issue does not seem to present itself. Without seeing your actual application it is difficult to provide a solution that will work in any scenario and still maintain the exact results you desire.


Kuba
  • 136,707
  • 13
  • 279
  • 740
  • Grid[{{pic2}}, Frame -> All] clips the left side too. However, this can be repaired with Spacings. Unfortunately, Spacings does not repair the original problem; e.g.,Grid[{{pic2}}, Frame -> All, Spacings -> {1, 1}]` – bbgodfrey Jan 28 '16 at 12:10
  • 1
    @bbgodfrey this is just ridiculous :-/ – Kuba Jan 28 '16 at 12:11
  • This does remove the clips but not sure about the method First@Grid[{{pic2}}] – Hubble07 Jan 28 '16 at 12:11
  • @Hubble07 Yes, but it also removes the Grid. – bbgodfrey Jan 28 '16 at 12:13
  • 1
    @Hubble07 let's go further and turn off the screen :p – Kuba Jan 28 '16 at 12:13
  • 1
    Removing ImageCrop works correctly... Strangely magnifying bigger than 1 also corrects it... – s.s.o Jan 28 '16 at 12:18
  • @s.s.o take pic2 as given, e.g. from web page. And I suppose it doesn't work, just the difference isn't visible due to the white frame. – Kuba Jan 28 '16 at 12:20
  • @s.s.o yep, on different magnification levels it looks beter, not the same though, If you take a closer look, the first row is different. – Kuba Jan 28 '16 at 12:21
  • The image from Grid[{{pic2}}, Frame -> All, Spacings -> {1, 1}, Background -> Blue] shows that the circle is not centered vertically in Grid, and Alignment has no effect. Even stranger, if you execute Grid[{{pic2}}, Frame -> All, Spacings -> {1, 1}, Background -> Blue] again on the next line, the first image changes! – bbgodfrey Jan 28 '16 at 12:28
  • 1
    I'mu using version 10.3.0 Linux, and this does not happen, Grid shows the circle correctly with or without the Frame option – Jason B. Feb 02 '16 at 08:00
  • Let's keep the bug description on a single line so that Pickett's script can extract it. If you want to display a line break, <br> works without needing to put an empty line in the markdown source. – Szabolcs Feb 04 '16 at 13:13
  • @Szabolcs ok! I was not aware of that, what script? p.s. I have to edit couple of topics now :) – Kuba Feb 04 '16 at 13:14
  • @Kuba The one linked here. I think the WRI QA folks found that very useful because it is able to filter out fixed bugs. It extracts the first "paragraph" (i.e. up to the first empty line) of the markdown and looks for the word "fixed" in it, I think (but I didn't look at the source code). It also generates a nice webpage with links to each topic and the "bug line" included in the summary. – Szabolcs Feb 04 '16 at 13:18

1 Answers1

12

With Frame -> All, the automatic Spacings are weird. The automatic BaselinePosition is bad either way.

It seems to be a good idea to include substitutes for as many of those options which are Automatic by default as possible:

pic2 = ImageResize[ImageCrop@Rasterize@Graphics@Disk[], {Automatic, 40}];

Grid[{{pic2}}, Alignment -> {Center, Center}, Spacings -> {0, 0},
               BaselinePosition -> Center, Frame -> All]

enter image description here

Kuba
  • 136,707
  • 13
  • 279
  • 740
Coolwater
  • 20,257
  • 3
  • 35
  • 64
  • When you put another Grid on that, the feature is back. It would be so nice to not have to care where the inner grid ends up. – Kuba Jan 28 '16 at 12:30
  • Grid@List@List@% – Kuba Jan 28 '16 at 12:30
  • 2
    Grid is terrible. I used this solution but then some glitches were introduced in the interior of the image, unfortunately, I can't share that image and I wasn't able to reproduce that problem with Graphics. That's crazy. – Kuba Jan 29 '16 at 09:29
  • 1
  • 1
    Due to all those issues I'm using in my UI ImagePad[pic2, 1, 1] or whichever value that fits the background. If such row is cut it's not a harm. – Kuba Feb 02 '16 at 07:43