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 db889ea..d35257c 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,22 @@ -# image.vim -View images in Vim, because Vim is awesome! +# Image.vim +The [Image.vim](https://github.com/Daniel1404/image.vim) +Original project is Unmainteined. -![](https://github.com/ashisha/image.vim/blob/master/screenshot/image.vim.jpg) +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! +* 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 Requirements ============ @@ -17,19 +24,50 @@ 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 ============ * [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'` + Then reload your .vimrc file and Install the Plugin. + + ``` + :so ~/.vimrc + :PluginInstall + ``` * [NeoBundle](https://github.com/Shougo/neobundle.vim) - * `NeoBundle 'ashisha/image.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 +============ +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..a822870 100644 --- a/plugin/image.vim +++ b/plugin/image.vim @@ -1,15 +1,15 @@ command! -nargs=0 Image call DisplayImage() -if !has("python") +if !has("python3") echo "image.vim requires python support" finish endif -au BufRead *.png,*.jpg,*.jpeg :call DisplayImage() +au BufRead *.png,*.jpg,*.jpeg,*.webp :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,)