Skip to content
Open
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
10 changes: 5 additions & 5 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")
echo "image.vim requires python support"
if !has("python3")
echo "image.vim requires python3 support"
finish
endif

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
Expand Down Expand Up @@ -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