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

More image options? #103

Open
lfb0801 opened this issue May 5, 2021 · 7 comments
Open

More image options? #103

lfb0801 opened this issue May 5, 2021 · 7 comments

Comments

@lfb0801
Copy link

lfb0801 commented May 5, 2021

First of all, I really like the project. I used to use mdp, but really needed images for my slides.

Is there a way to display images within a slide instead of in full screen?
Would it then be possible to add multiple images to a slide?

@Tenchi2xh
Copy link
Contributor

First of all, I really like the project. I used to use mdp, but really needed images for my slides.

Is there a way to display images within a slide instead of in full screen?
Would it then be possible to add multiple images to a slide?

If you are on a Mac, and use iTerm, you can use imgcat to generate an ANSI escape sequence containing the image that the terminal will interpret and display, which you can paste verbatim in your slides.

I have been doing that for my slides, and if you refer to the doc there are two numbers you can edit in the generated code to adjust the width and height so it fits in the presentation

@cskksdfklpz
Copy link

May I ask how should we generate the ANSI Escape sequence and which part shall we paste to the slides?

@Tenchi2xh
Copy link
Contributor

imgcat name_of_image.png | pbcopy

Will render the image as an escape sequence and put it in your clipboard. You can then paste it in your slide:

�]1337;File=name=ZmF2aWNvbi5wbmc=;size=1335;inline=1:iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AIEDhkEucE1HgAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAEm0lEQVRYw9WXy29UVRzHP+ecO3fuTGdaOrTQIoUBgQoCgkUNGAkGoxhDdKGuWJgY/Avc6NKFG7e4c2viEh/RxOBrIQ1BCCD4ojz64Flm2mk7r/s4x8XtzHQ6M9BBCPEkd3Fzz+N7fr/v7/f9XvH2kZzhEQ7JIx6PHIC18GXXOounBix6kgInIh7oQSXPMJU3nJ/wGR7xMYsB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t1IKVXYLnN0bwA8N4pokYnbzi8dKTEQb7LT48GOfsmI+va1KaiAqe2xBOPz1a72wBfvzD450XFG8MRVnVLckVTHWtkvBEv6InKRnPBAyP1MRILPw3HEhJXn86yu4NFpZqDOVMUfPTnx5fnXaZK5tFrgde3mpzYJtN37Lm3D552ePL0y4XbwXNAVREqSsmSTqChCMQQGAMs0XDbMkwXTAtHa4QkOoIHXJXXGDJkLAF1zBTNMwUdVWUWtryogtFV3Mz137zMSaU9cycgcz/5Of0X3X54LhrEFQDAAAAAElFTkSuQmCC�

Don't convert a big image and resize them down first because all of those bytes as text will make your text file hard to edit (and quite big).

(instead of | pbcopy you can also > some_file and open that file and copy and paste from there)

Once you have the escape squence for your image you can edit some flags to make it fit your slide. You can add more flags before the : where the image data starts:

�]1337;File=name=ZmF2aWNvbi5wbmc=;size=1335;inline=1;width=10:...

Here I added width=10 to make it exactly 10 characters wide (aspect ratio is preserved) but play around until your slide looks good. You can also add some non breaking spaces to the left to try and center the image.

The full docs are here: https://iterm2.com/documentation-images.html

Here's a full example:

---
title: An image has appeared
author: Tenchi
patat:
    wrap: true
    margins:
        left: 30
        right: 30
...

# An image has appeared

## The image

Here's an image:

    �]1337;File=name=ZmF2aWNvbi5wbmc=;size=1335;inline=1;width=10:iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AIEDhkEucE1HgAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAEm0lEQVRYw9WXy29UVRzHP+ecO3fuTGdaOrTQIoUBgQoCgkUNGAkGoxhDdKGuWJgY/Avc6NKFG7e4c2viEh/RxOBrIQ1BCCD4ojz64Flm2mk7r/s4x8XtzHQ6M9BBCPEkd3Fzz+N7fr/v7/f9XvH2kZzhEQ7JIx6PHIC18GXXOounBix6kgInIh7oQSXPMJU3nJ/wGR7xMY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u35t1IKVXYLnN0bwA8N4pokYnbzi8dKTEQb7LT48GOfsmI+va1KaiAqe2xBOPz1a72wBfvzD450XFG8MRVnVLckVTHWtkvBEv6InKRnPBAyP1MRILPw3HEhJXn86yu4NFpZqDOVMUfPTnx5fnXaZK5tFrgde3mpzYJtN37Lm3D552ePL0y4XbwXNAVREqSsmSTqChCMQQGAMs0XDbMkwXTAtHa4QkOoIHXJXXGDJkLAF1zBTNMwUdVWUWtryogtFV3Mz137zMSaU9cycgcz/5Of0X3X54LhrEFQDAAAAAElFTkSuQmCC�

    1234567890

10 characters wide

Hope you like it!

Which looks like this:

image

Have fun

@jaspervdj
Copy link
Owner

Apart from the workaround @Tenchi2xh posted, I am not sure if we want to support this.

There are a few different, non-compatible ways to display images in terminals, so I prefer to go with the "lowest common denominator" for now; and displaying a single image as large as possible seems to be a good compromise.

That being said, I'm open to proposals, and if there's a compelling use case, the first thing to do would be to figure out a good syntax to describe the width/height that patat can parse and translate to the different backends.

@gpanders
Copy link

gpanders commented Nov 20, 2023

Pasting raw escape sequences works for the Kitty graphics protocol as well. Copy the output of kitty +kitten icat $FILENAME directly into the Markdown document, and the image will display inline.

The escape sequence should look something like this:

\x1b_Ga=T,f=100,t=f;<base64 encoded string>\x1b\

@jaspervdj
Copy link
Owner

Rather than copying the output of kitty +kitten icat into the presentation, you can use eval to do this for you. This uses the new rawInline option added in #158 which I just released in v0.10.2.0.

---
patat:
  eval:
    kitten:
      command: sed 's/^/kitten /' | bash
      replace: true
      fragment: false
      wrap: rawInline
...

See, for example:

```kitten
icat --align left dank-meme.jpg
```

@gpanders
Copy link

Rather than copying the output of kitty +kitten icat into the presentation, you can use eval to do this for you. This uses the new rawInline option added in #158 which I just released in v0.10.2.0.

---
patat:
  eval:
    kitten:
      command: sed 's/^/kitten /' | bash
      replace: true
      fragment: false
      wrap: rawInline
...

See, for example:

```kitten
icat --align left dank-meme.jpg

Nice! I was experimenting with my own script that did something similar. Thanks for adding this.

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

No branches or pull requests

5 participants