hpjansson / chafa

📺🗿 Terminal graphics for the 21st century.
https://hpjansson.org/chafa/
GNU Lesser General Public License v3.0
2.97k stars 64 forks source link

Incorrect aspect ratio #214

Closed johnd0e closed 2 months ago

johnd0e commented 2 months ago

Chafa version 1.14.2, Windows

chafa -f symbols file.jpg
chafa -f sixels file.jpg

Outputs images that are too narrow. And with sixels image is too small, perhaps that is wrong too.

sample.zip

hpjansson commented 2 months ago

The size issue is probably #211. There's a test binary there too. The aspect issue is #212, I think, but that one needs some work still. Shouldn't be too long.

hpjansson commented 2 months ago

I think this is fixed now. It'll be in the next release. Thanks for reporting it!

johnd0e commented 2 months ago

I think this is fixed now. It'll be in the next release.

Now the image has proper size, but still distorted a bit. Too narrow.

hpjansson commented 2 months ago

Now the image has proper size, but still distorted a bit. Too narrow.

Could you attach the source image, plus a screenshot showing how it's displayed in the terminal and the command line you used? I'll take another look.

johnd0e commented 2 months ago

Source 1024*1024: result

Appearance in terminal (~= 842*1094): Capture

Command: chafa -f sixels picture.jpg

Important! Font: Victor Mono

With other fonts I see other aspect ratios, e.g.:

j4james commented 2 months ago

@johnd0e If you're using Windows Terminal, the behavior you're seeing is by design. It's intended that a given sixel image will occupy the same number of cells, independent of the font or font size that is in use at the time. For example your 1024x1024 image will always occupy a little over 102 columns and 51 rows. If your font has an aspect ratio that is significantly different from 2:1, it's expected that it would appear somewhat distorted.

johnd0e commented 2 months ago

If you're using Windows Terminal, the behavior you're seeing is by design.

Ok, I believe that it is useful for some use cases. But not for others.

Shouldn't then the "correct aspect ratio" be implement as an option? Perhaps CSI 14 t and CSI 18 t can give the proper value?

j4james commented 2 months ago

Shouldn't then the "correct aspect ratio" be implement as an option?

That's not something I'm personally interested in implementing, but you're welcome to request that feature on the WT issue tracker.

Perhaps CSI 14 t and CSI 18 t can give the proper value?

CSI 14 t has to return the emulated pixel size, otherwise software that relies on that to calculate the cell size won't work.

hpjansson commented 2 months ago

Sounds like this is working to its full potential. I'll close the issue, but feel free to keep discussing (although, as James points out, it'd likely be more productive in the WT tracker). Thanks!

johnd0e commented 1 month ago

@hpjansson Is it possible to force specific aspect ration with command line option?

hpjansson commented 1 month ago

@johnd0e You can set the output size with -s and add --stretch to fill the dimensions exactly. In theory, you should also be able to use --font-ratio, but I think I broke it in one of the recent releases.

johnd0e commented 1 month ago

In theory, you should also be able to use --font-ratio, but I think I broke it in one of the recent releases.

That's right, it's broken(