Closed joshtriplett closed 8 years ago
Aspect ratio is (not) preserved by image
, so I have little control over that, but the idea seems nice
You can read out the size, and calculate the new size yourself, rather than using the aspect-ratio-preserving resize.
Terminal characters have a rectangular shape, with more height than width; when not using Unicode, you'd want to take that into account, and resize the image to have twice as much width as height compared to its natural aspect ratio. For instance, you could take a 1600x1200 image and resize it to 80x30 rather than 80x60, which would make the image printed in the terminal look closer to correct.
However, when using a unicode half-block character, you'd want to resize the image preserving aspect ratio (1600x1200 -> 80x60) and then use two pixel rows per text row.
Yeah, you're right.
Terminal characters have a rectangular shape
Which is inconsistent across any and all implementations :P
@nabijaczleweli True, but it'll generally be closer to 2:1 than 1:1; terminal fonts are almost never square. So, 2:1 should generally produce better results.
I'm bad at numbers, misclosed :v
@joshtriplett Can you verify with -a truecolor
?
Yeah, that works, and produces a much better aspect ratio as well.
The unicode block thing came readily to mind because I'd done a similar experiment as a test of the ansi_term
module after adding truecolor support to it. My quick-and-dirty version didn't have any of the error handling or command-line handling that yours does, though.
Screenshots of the truecolor Unicode-block version:
Also, I'd suggest subtracting one from the target height, so that the subsequent prompt doesn't scroll the top of the image off the screen.
That's unavoidable on Windooze, but I might be able to do something about it on Linux, open a separate issue, please?
@joshtriplett Can you please make an SS of this image: ? That way we'd have a consistent comparison base for multiple platforms
You can double the vertical resolution by printing a Unicode "upper block" character, using the foreground for the upper pixel and the background for the lower pixel. (This also requires an adjustment to the aspect ratio calculation.)