Skip to content
This repository has been archived by the owner on Dec 30, 2023. It is now read-only.

image2ascii for markdown images #43

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Maddin-619
Copy link

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!

@sotte
Copy link
Owner

sotte commented Oct 9, 2021

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.

@normen
Copy link

normen commented Dec 28, 2021

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?

@Maddin-619
Copy link
Author

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?

@normen
Copy link

normen commented Jan 3, 2022

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)

@sotte
Copy link
Owner

sotte commented Jan 3, 2022

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.

@normen
Copy link

normen commented Jan 3, 2022

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.

@sotte
Copy link
Owner

sotte commented May 1, 2022

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

@Maddin-619
Copy link
Author

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.

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

Successfully merging this pull request may close these issues.

3 participants