presenting.vim icon indicating copy to clipboard operation
presenting.vim copied to clipboard

image2ascii for markdown images

Open Maddin-619 opened this issue 3 years ago • 8 comments

I recently used this plugin for a presentation in my company and it was so cool. I thought it was nice using some images too, so I made a little patch: If the markdown file includes an image link, the image gets converted with the command line tool image2ascii and centered in the presentation buffer. If the url dosn't exist the alt text gets printed.

In the terminal image2ascii can get the image width and height, but from vim script that didn't worked. So it is necessary to pass the width and height manually. I found a markdown extension where the image size could be passed after the url with an = sign prefix, so I used these format:

![alt text](./images/1200px-Vimlogo.svg.png =55x35)

Here is an example. The cover page of my presentation :) image

P.S. Since it is October can u please lable this PR that it gets accepted: https://hacktoberfest.digitalocean.com/resources/participation Thank you!

Maddin-619 avatar Oct 06 '21 19:10 Maddin-619

Hey @Maddin-619, thanks for the PR! This looks like a nice feature and I'm happy to merge it.

Please add documentation for this feature in the README, the vim docs, and also add a md example.

sotte avatar Oct 09 '21 15:10 sotte

After finding the right image2ascii (theres also a python command with the same name but different parameters) I found that the width/height issue can also be solved by using the -r parameter - seems easier as it keeps the aspect ratio?

normen avatar Dec 28 '21 14:12 normen

You are right. This is much more comfortable. Should we drop the with and height in favor of the ratio or should we accept both?

Maddin-619 avatar Dec 29 '21 22:12 Maddin-619

I guess having both would be nice but it would also mean more parsing - no idea whats the best way here, maybe in the form of actual URL GET parameters? Like folder/myimage.jpg?r=9&w=10&h=10? (ofc all together don't make sense)

normen avatar Jan 03 '22 11:01 normen

I actually had the same issue when I was testing the MR, but I forgot to post it here.

We should also mention what the "right image2ascii version" is and how to install it.

sotte avatar Jan 03 '22 13:01 sotte

We should also mention what the "right image2ascii version" is and how to install it.

Its actually in the PR notes and the vim manual of this PR, I just didn't rtfm 😅 I knew of "the other" image2ascii and so just assumed thats the one.. Maybe in a second step the command and parameters could even be made variables so one can use the ascii-fier of choice.

normen avatar Jan 03 '22 13:01 normen

@Maddin-619 thanks for the additions. Do you think this is ready to be merged?

sotte avatar May 01 '22 15:05 sotte

I did not implement an exchangable image2ascii program as suggested. Stick with the golang tool for now and this works just fine with optional ratio or with and height params in http query style. So in my opinion this could be merged now, doing the exchangable thing maybe in abother PR.

Maddin-619 avatar May 02 '22 19:05 Maddin-619