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
14 changes: 11 additions & 3 deletions plugin/image.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
command! -nargs=0 Image call DisplayImage()

if !has("python")
if !has("pythonx")
echo "image.vim requires python support"
finish
endif
Expand All @@ -9,11 +9,19 @@ au BufRead *.png,*.jpg,*.jpeg :call DisplayImage()

function! DisplayImage()
set nowrap
python << EOF

pyx << EOF
from __future__ import division
import vim
from PIL import Image

try:
# Python 2
xrange
except NameError:
# Python 3, xrange is now named range
xrange = range

def getAsciiImage(imageFile, maxWidth, maxHeight):
try:
img = Image.open(imageFile)
Expand Down Expand Up @@ -63,7 +71,7 @@ def getAsciiImage(imageFile, maxWidth, maxHeight):
vim.current.buffer.append(asciiImage)

return asciiImage

vim.command("let imagefile = expand('%:p')")
imagefile = vim.eval("imagefile")

Expand Down