Displaying inline images, preserveAspectRatio does not function correctly, and part of the top is almost always cut off
Bug report
- iTerm2 version: 3.4.5
- OS version: 11.2.3
- com.googlecode.iterm2.plist
Detailed steps to reproduce the problem
When displaying this (hastily hand-made) square test image:
This is the result:
The image includes the commands to reproduce each case.
- The image is displayed in its original size. Its top few pixels are cut off. There is a gap beneath the image that appears to be roughly the same height as the cut-off region.
- The image is scaled down to fit 100x100. Many more of the scaled image's top few pixels are cut off, and there is a large gap beneath the image that appears about twice the height of the cut-off region.
- The image is scaled down to fit 200x100. The display area appears to be the correct size, but in addition to the top being cut off, the image is effectively being displayed at an aspect of 4:1 and has had its entire right half cut off. (Strangely, less of the top is cut off than in the 100x100 case.)
- The image is scaled down to fit 100x200. As above, the display area size appears correct, but now a massive chunk of the top has been cut off, and the visible portion of the image is effectively being displayed at an aspect ratio of 1:4.
In all the displayed cases, preserveAspectRatio
is enabled, as per default. Explicitly enabling it leads to the same result. Disabling it makes things get a whole lot weirder; I'm not even sure how to describe the results.
I'm on a Retina display and GPU rendering is not in use. Issue #6030 applies but is a separate issue.
I thought that this was a simple case of getting an aspect ratio calculation backwards somewhere, but I made a (very) quick check of the code and the aspect ratio calculation itself looks right to me. Perhaps the code to scale the image, and the code to center the scaled image, are the source of the issue?