npm-gif icon indicating copy to clipboard operation
npm-gif copied to clipboard

Add Windows Support

Open thiagodp opened this issue 7 years ago • 21 comments

Hi, are you planning to make npm-gif available for other OSes' terminals? Thanks!

thiagodp avatar Oct 24 '17 20:10 thiagodp

Hi @thiagodp! I would love to. However, the limitation is in the terminal itself. The terminal has to support embedding images and as far as I know iTerm2 is the only one that currently does.

kodie avatar Oct 24 '17 21:10 kodie

I see... Since other terminals only support ascii, it would be necessary to do some kind of ascii art or braille animation. So definitively, to simulate this would be a task for a different project (not a gif-based). Thank you, anyway!

thiagodp avatar Oct 25 '17 18:10 thiagodp

BTW, I just found an ascii art -based gif cli.

thiagodp avatar Oct 25 '17 18:10 thiagodp

Definitely lower-res than the real image, but here are some pure-JavaScript options for getting some version of the image in non-iTerm2 terminals:

  • The picture-tube module makes it easy to pipe a PNG write stream (one of the gif-frames output stream options) into the terminal window as ansi terminal characters... however I don't think that really lets you replace a specific region of the terminal window.
  • For finer control you can use picture-tube's dependency, charm, which lets you set a specific terminal character position equal to a color value.
    • For this one you would need access to the decoded data, so you could either re-decode the output frames from gif-frames using get-pixels, or just use get-pixels to decode the GIF in the first place.

More work, but would be cool. 😄

benwiley4000 avatar Dec 06 '17 04:12 benwiley4000

Also looks like image-to-ascii would be perfect for this (much higher res than just color blocks)... if it supported file streams or Buffers!

benwiley4000 avatar Dec 06 '17 05:12 benwiley4000

@benwiley4000 Very interesting! Think I may have to switch progress-img's default fallback to image-to-ascii!

kodie avatar Dec 06 '17 18:12 kodie

@kodie I looked and the underlying image parsing engine (lwipify) actually seems to support Buffer objects so I think you could supply one of those as the source argument to imageToAscii.

benwiley4000 avatar Dec 06 '17 20:12 benwiley4000

@benwiley4000 I've been playing around with image-to-ascii and it does in fact support buffers right out of the box luckily.

kodie avatar Dec 06 '17 21:12 kodie

Good to hear!

benwiley4000 avatar Dec 06 '17 21:12 benwiley4000

Great!

thiagodp avatar Dec 06 '17 22:12 thiagodp

@benwiley4000 @thiagodp The biggest thing stopping me from implementing this is that image-to-ascii relies on image-parser which requires GraphicsMagick to be installed on the user's system.

Which means that if implemented and a user runs npm install npm-gif, the install will fail unless they have GraphicsMagick installed on their system.

kodie avatar Dec 07 '17 20:12 kodie

@kodie this one has no native dependencies. https://github.com/ajay-gandhi/asciify-image

Like the other module, it claims it takes a string path but I think a Buffer will work since it relies on lwip.

benwiley4000 avatar Dec 07 '17 23:12 benwiley4000

@benwiley4000 Unfortunately lwip doesn't support modern node versions quite yet :( https://github.com/EyalAr/lwip/issues/297

kodie avatar Dec 13 '17 16:12 kodie

Aaah. Also I'm realizing the "no native dependencies" is a lie since lwip has some. ETA: The only advantage I guess is that you don't need to count on the user to install anything manually, but it's still prone to issues when you change Node versions, as with all C++ bindings.

benwiley4000 avatar Dec 13 '17 18:12 benwiley4000

@thiagodp @benwiley4000 I have made a pull request for asciify-image that would make it truly dependency-free so if that gets merged we'll be in business!

kodie avatar Jan 05 '18 21:01 kodie

Awesome! Looking forward to what comes next.

benwiley4000 avatar Jan 08 '18 19:01 benwiley4000

@benwiley4000 @thiagodp Please install the new release (v1.0.2) and give it a try!

kodie avatar Jan 11 '18 17:01 kodie

Hi, Not working with mac OS terminal capture d ecran 2018-07-27 a 11 00 48

And the image appears after installing the packages on iTerm2

✗ npm --version
6.1.0

iTerm 3.1.7

Fridus avatar Jul 27 '18 09:07 Fridus

Hi, @kodie , sorry for giving you feedback so late...

Anyway, this was the result on Windows 10:

image

The ascii appeared at once.

thiagodp avatar Jul 27 '18 13:07 thiagodp

@thiagodp No worries, thank you for the feedback. I will look into this.

kodie avatar Aug 10 '18 14:08 kodie

Git bash too :(

blogdopata avatar Sep 23 '18 09:09 blogdopata