From eb8f2fed496147f4da47cab1dd72b11bb3c918ed Mon Sep 17 00:00:00 2001 From: Daniel Diaz Date: Wed, 9 Dec 2020 17:16:38 -0500 Subject: [PATCH 1/7] Added python3 support --- README.md | 27 ++++++++++++++++++++++++--- plugin/image.vim | 10 +++++----- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index db889ea..0971341 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # image.vim +Forked from: [Image.vim](https://github.com/ashisha/image.vim) + View images in Vim, because Vim is awesome! ![](https://github.com/ashisha/image.vim/blob/master/screenshot/image.vim.jpg) @@ -9,7 +11,7 @@ Features ========= * Let's you open (preview) images in Vim! * It's safe, never modifies the original image (unless you force write) - +* Adapted to work with python3 instead of python2 Requirements ============ @@ -17,8 +19,21 @@ Requirements `vim --version | grep python` - If you see `+python`, your Vim has python support. If not, figure out how to get one. - + If you see `+python`, your Vim has python support. If not, compile or install yourself + a vim with python support. + In arch: + ``` + sudo pacman -S gvim + ``` + In Debian based: + + ``` + sudo apt install vim-gtk + ``` + + It will install gvim which include vim with python support and a GTK application of vim. + You will be asked to remove Vim, but relax, you will keep the option of use vim in terminal. + * Also needs the Python library PIL. You can install PIL using `pip install Pillow` Installation @@ -32,4 +47,10 @@ Installation * Manual * Copy image.vim into your `~/.vim/plugin/` directory +Errors +============ +Not an error but a deficit, it doesn't work well with image that are +full colored like Screenshots, because the plugin uses Ascii characters. + + Thank you! diff --git a/plugin/image.vim b/plugin/image.vim index 16fb80d..185a8c7 100644 --- a/plugin/image.vim +++ b/plugin/image.vim @@ -1,6 +1,6 @@ command! -nargs=0 Image call DisplayImage() -if !has("python") +if !has("python3") echo "image.vim requires python support" finish endif @@ -9,7 +9,7 @@ au BufRead *.png,*.jpg,*.jpeg :call DisplayImage() function! DisplayImage() set nowrap -python << EOF +python3 << EOF from __future__ import division import vim from PIL import Image @@ -40,7 +40,7 @@ def getAsciiImage(imageFile, maxWidth, maxHeight): img = img.resize((scaledWidth, scaledHeight)) pixels = img.load() - colorPalette = "@%#*+=-:. " + colorPalette = '"@%#*+=-:.' lencolor = len(colorPalette) # Delete the current buffer so that we dont overwrite the real image file @@ -53,9 +53,9 @@ def getAsciiImage(imageFile, maxWidth, maxHeight): # clear the buffer vim.current.buffer[:] = None - for y in xrange(scaledHeight): + for y in range(scaledHeight): asciiImage = "" - for x in xrange(scaledWidth): + for x in range(scaledWidth): rgb = pixels[x, y] if not isinstance(rgb, tuple): rgb = (rgb,) From 60c5cb1aa337e5e3fdc9136e706e6fb9b602681b Mon Sep 17 00:00:00 2001 From: Daniel Diaz Date: Wed, 9 Dec 2020 17:17:37 -0500 Subject: [PATCH 2/7] Added python3 support --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0971341..94964a7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# image.vim +# Image.vim Forked from: [Image.vim](https://github.com/ashisha/image.vim) View images in Vim, because Vim is awesome! @@ -21,6 +21,7 @@ Requirements If you see `+python`, your Vim has python support. If not, compile or install yourself a vim with python support. + In arch: ``` sudo pacman -S gvim From 0f4e3193fe8a4c2f403067c054d8acbaba6e5044 Mon Sep 17 00:00:00 2001 From: Daniel Diaz Date: Wed, 9 Dec 2020 17:22:03 -0500 Subject: [PATCH 3/7] Added .webp image support --- plugin/image.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/image.vim b/plugin/image.vim index 185a8c7..a822870 100644 --- a/plugin/image.vim +++ b/plugin/image.vim @@ -5,7 +5,7 @@ if !has("python3") finish endif -au BufRead *.png,*.jpg,*.jpeg :call DisplayImage() +au BufRead *.png,*.jpg,*.jpeg,*.webp :call DisplayImage() function! DisplayImage() set nowrap From e03132be97172fb231ae948e68502a036084177f Mon Sep 17 00:00:00 2001 From: Daniel Diaz Date: Wed, 9 Dec 2020 17:25:07 -0500 Subject: [PATCH 4/7] Added .webp image support --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 94964a7..5d825dc 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,11 @@ View images in Vim, because Vim is awesome! Features ========= -* Let's you open (preview) images in Vim! +* Let's you open (preview) images in Vim!: + Image supported: + * Png + * jpg - jpeg + * webp * It's safe, never modifies the original image (unless you force write) * Adapted to work with python3 instead of python2 From 883fd4d748e4401e21d03d069d1eb845249bd6ce Mon Sep 17 00:00:00 2001 From: Daniel Diaz Date: Wed, 9 Dec 2020 17:37:41 -0500 Subject: [PATCH 5/7] Updated README --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5d825dc..e16501c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Image.vim -Forked from: [Image.vim](https://github.com/ashisha/image.vim) +# Image.viDaniel1404d from: [Image.vim](https://github.com/Daniel1404/image.vim) +Original project is Unmainteined. View images in Vim, because Vim is awesome! -![](https://github.com/ashisha/image.vim/blob/master/screenshot/image.vim.jpg) +![](https://github.com/Daniel1404/image.vim/blob/master/screenshot/image.vim.jpg) @@ -44,11 +44,11 @@ Requirements Installation ============ * [Pathogen](https://github.com/tpope/vim-pathogen) - * `git clone https://github.com/ashisha/image.vim ~/.vim/bundle/image.vim` + * `git clone https://github.com/Daniel1404/image.vim ~/.vim/bundle/image.vim` * [Vundle](https://github.com/gmarik/vundle) - * `Plugin 'ashisha/image.vim'` + * `Plugin 'Daniel1404/image.vim'` * [NeoBundle](https://github.com/Shougo/neobundle.vim) - * `NeoBundle 'ashisha/image.vim'` + * `NeoBundle 'Daniel1404/image.vim'` * Manual * Copy image.vim into your `~/.vim/plugin/` directory From b070fa9facf2c3db49acbc72d25bde16d8296642 Mon Sep 17 00:00:00 2001 From: Daniel Diaz Date: Wed, 9 Dec 2020 18:48:45 -0500 Subject: [PATCH 6/7] Updated README --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e16501c..652116c 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,21 @@ Installation * `git clone https://github.com/Daniel1404/image.vim ~/.vim/bundle/image.vim` * [Vundle](https://github.com/gmarik/vundle) * `Plugin 'Daniel1404/image.vim'` + Then reload your .vimrc file and Install the Plugin. + + ``` + :so ~/.vimrc + :PluginInstall + ``` * [NeoBundle](https://github.com/Shougo/neobundle.vim) * `NeoBundle 'Daniel1404/image.vim'` * Manual - * Copy image.vim into your `~/.vim/plugin/` directory + Copy image.vim into your `~/.vim/plugin/` directory + ``` + git clone https://github.com/Daniel1404/image.vim + cd image.vim + cp image.vim ~/.vim/plugin/ + ``` Errors ============ From 11147277d5f5f8ee5ba2860ebf8e4def16e5e05e Mon Sep 17 00:00:00 2001 From: Daniel Diaz Date: Wed, 9 Dec 2020 21:24:35 -0500 Subject: [PATCH 7/7] Updated README --- LICENSE | 23 ++++++++++++++++++++++- README.md | 11 ++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/LICENSE b/LICENSE index a22a2da..94890d1 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1,22 @@ -MIT +Image.vim forked from https://github.com/ashisha/image.vim + +Copyright © 2020 Daniel Diaz - ashish anand + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/README.md b/README.md index 652116c..d35257c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# Image.viDaniel1404d from: [Image.vim](https://github.com/Daniel1404/image.vim) +# Image.vim +The [Image.vim](https://github.com/Daniel1404/image.vim) Original project is Unmainteined. View images in Vim, because Vim is awesome! @@ -6,14 +7,14 @@ View images in Vim, because Vim is awesome! ![](https://github.com/Daniel1404/image.vim/blob/master/screenshot/image.vim.jpg) - Features ========= * Let's you open (preview) images in Vim!: Image supported: - * Png - * jpg - jpeg - * webp + * .png + * .jpg + * .jpeg + * .webp * It's safe, never modifies the original image (unless you force write) * Adapted to work with python3 instead of python2