Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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.

58 changes: 48 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,73 @@
# 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
============
* Vim with *python* support. You can verify if your Vim is compiled with python using:

`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!
12 changes: 6 additions & 6 deletions plugin/image.vim
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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,)
Expand Down