imgcat
imgcat copied to clipboard
Make the library imgcat useful for people who want to embed images
I think we should split this project up into a library (root folder of the repo) and the imgcat
command itself (probably in /cmd/imgcat
).
I'd love to use this in glow
/ glamour
to optionally display images :heart:
That would be cool!
What kind of function signature would be best for glow?
something like:
func ImageToString(img image.Image) []string
or would you like a higher level one?
func ImageToString(imgPath string, width, height uint) ([]string, error)
Great minds think alike I guess. I did pretty much this in #12, mostly following the same pattern that https://github.com/charmbracelet/bubbles seemed to follow for the components. As in just directly exposing the Model structure.
if we are going to make a model/component. I wonder if the most usable form is just { width, height, url/filepath }, then you can embed any number of images anywhere without the assumption of a full screen q to quit setup.
For now I just used the model as is. Meaning all properties are private. Making width, height and urls public is probably a good idea. I would like to add that an offline toggle (so not accepting http urls) is probably a good idea for providing this as a library, but I'd say that would deserve it's own issue/pull request later on.
Having ImageToString
is convenient and nice, but I think I'd prefer passing either an image.Image
or an io.Reader
to it. That makes it a lot more flexible in regards to where the image is stored.
I was actually already planning on following up with another pull request later on adding support for image.Image
and/or io.Reader
later down the line. I suppose I will look into implementing this later today.
Awesome, can't wait for that @schoentoon!
This will be our tracking ticket for how we want the library to look when we finish shaking out the assumptions of the original impl. So not closing even though we did a first pass.
I will most likely add a few methods like AddImage(image image.Image)
and AddImageFromReader(reader io.Reader)
to the Model structure we have now. Along with changing NewModel()
to something like NewModel(image image.Image)
and NewModelFromReader(reader io.Reader)
. Getting rid of the current urls part completely, leaving the opening of files or images over http on the caller. Although we could decide to add helpers for file and http alongside it.
Any news on this? I was interested in trying out Bubbletea, but it seems your program is the closest thing you can get for displaying images, so having it as a bubble component would be great.