mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-06 18:54:27 +08:00
Use command 'identify' to retrieve the size of a local image
* Command 'identify' is provived by ImageMagick
This commit is contained in:
@@ -191,6 +191,11 @@ endfunction
|
|||||||
|
|
||||||
function! zencoding#util#getImageSize(fn)
|
function! zencoding#util#getImageSize(fn)
|
||||||
let fn = a:fn
|
let fn = a:fn
|
||||||
|
|
||||||
|
if filereadable(fn) && zencoding#util#isImageMagickInstalled()
|
||||||
|
return zencoding#util#imageSizeWithImageMagick(fn)
|
||||||
|
endif
|
||||||
|
|
||||||
if filereadable(fn)
|
if filereadable(fn)
|
||||||
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
|
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
|
||||||
else
|
else
|
||||||
@@ -228,3 +233,14 @@ function! zencoding#util#getImageSize(fn)
|
|||||||
return [width, height]
|
return [width, height]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! zencoding#util#imageSizeWithImageMagick(fn)
|
||||||
|
let img_info = system('identify -format "%wx%h" "'.a:fn.'"')
|
||||||
|
let img_size = split(img_info, 'x')
|
||||||
|
let width = img_size[0]
|
||||||
|
let height = substitute(img_size[1], '\n', '', '')
|
||||||
|
return [width, height]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! zencoding#util#isImageMagickInstalled()
|
||||||
|
return !(empty(system('command identify')))
|
||||||
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user