Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

icat: rotate, mirror, alpha #4513

dagbdagb opened this issue Jan 14, 2022 · 5 comments

icat: rotate, mirror, alpha #4513

dagbdagb opened this issue Jan 14, 2022 · 5 comments


Copy link

dagbdagb commented Jan 14, 2022

Is your feature request related to a problem? Please describe.
I have discovered the icat kitty. I love it. I have found some minor usability issues with it:

  • occasionally an image is rotated the wrong way. The ability to fix that with an option to icat removes the need to modify the image.
  • mirroring is just a logical extension of the above item
  • I have found that various PDF readers handle PDFs with transparent backgrounds differently. icat honors the transparency. So if a PDF with black text on a transparent background is icat'ed in a terminal with a black background, there is no visible text. Looks perfectly fine in some PDF readers, so the issue may very well not be obvious to users. Apart from image not showing up in the terminal.

Describe the solution you'd like
Options '--mirror <hor|vert>' and '--rotate [NN]' (NN=degrees, range -360 - 360, 'cw'/'ccw' as aliases for 90/270) sounds like natural choices for the first two options. That said, I do notice there is some kind of automagic going on for rotation, depending on terminal width/height.

Regarding alpha, I am not sure if this applies to PDFs only? '--alpha 'somesolidcolor' might be a sufficient user interface for handling this? Only assuming IM can be called with the right options to fix this. Also, maybe a (default?) warning if someone icats an image with alpha to a terminal with black background? Not sure if additional heuristics for a warning is hard to implement.

Describe alternatives you've considered
The alternative implies using a utiltiy to modify the sources prior to icat'ing them. And that kind of defeats the purpose of icat, I think.

Additional context
Linux, Wayland, wayfire, kitty 0.23.1.

Thank you for kitty!

Copy link

allemangD commented Jan 14, 2022

You can already pipe output from ImageMagick to icat to do what you describe.

convert photo.png -rotate 90 - | kitty +kitten icat

The options you've listed are:

  • -flip vertical mirror.
  • -flop horizontal mirror.
  • -rotate <deg> rotation. positive values rotate clockwise.
  • -background white -alpha remove replace transparency with a color.

Since icat already uses ImageMagick to load images, I imagine it would be fairly straightforward to add such functionality, however since the piping method already gives you access to all of ImageMagick's features it seems superior to me.

How are you using icat to view pdfs?

Copy link

@allemangD thank you for the piping example. I'll make a note of it, but l'll eave the FR open.

IM handles PDFs "natively", but ghostscript had a security bug which made distributions disable PDFhandling in IM for a while. You may have to edit your policy.xml. See for example.

Copy link

There is one advantage to integrating these with icat (besides ease of
use), namely performance. It avoid processing the image data twice. I
have implemented transparency removal and mirroring as they were
trivial. Rotating changes the dimensions of the image and therefore
needs careful consideration for how it interacts with the scaling,
placement, etc options. Not worth the effort tome, patches welcome.

Copy link

Thank you,

Rotation would be easier to implement if clamped to 90 degrees CW or CCW only, right? Just need to transpose width/height and otherwise go with the regular code. This would also cover 99.9% of all use-cases. 😬

Copy link

I was talking about transposition only. For non-square images that still
changes image dimensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants