vscode-paste-image
vscode-paste-image copied to clipboard
粘贴后的图片 vscode 和 chrome 无法读取
按照说明文档的方式,通过截图工具获得图片后,cml + alt + v 的方式能够在 vscode 里粘贴图片并且在 markdown 中自动填入地址,但是生成的这张图片除了 mac 自带的预览工具等图片工具可以查看外,chrome、vscode 都无法查看,如下图。
mac os 版本:10.14.6 (18G87) vscode 版本: 1.43.0 paste-image 版本:1.0.4
有些截图软件,例如企业微信,粘贴后生成的图片文件实际是 tiff 格式的,不知道什么原因。。
发现一个解决方法,感谢 @xiaoouwang 的 #65
-
brew install pngpaste
-
打开
~/.vscode/extensions/mushan.vscode-paste-image-1.0.4/res
创建mac.sh
,内容如下
#!/bin/sh
if pngpaste $1 > /dev/null 2>&1 ; then
pngpaste $1
echo $1
else
echo "no image"
fi
- 打开
~/.vscode/extensions/mushan.vscode-paste-image-1.0.4/out/src/extension.js
编辑
// Mac
+ var scriptPath = path.join(__dirname, '../../res/mac.sh');
+ var ascript = child_process_1.spawn('sh', [scriptPath, imagePath]);
- var scriptPath = path.join(__dirname, '../../res/mac.applescript');
- var ascript = child_process_1.spawn('osascript', [scriptPath, imagePath]);
- 重启vscode
我也遇到了同样的问题,希望下个版本可以解决
发现一个解决方法,感谢 @xiaoouwang 的 #65
brew install pngpaste
- 打开
~/.vscode/extensions/mushan.vscode-paste-image-1.0.4/res
创建mac.sh
,内容如下#!/bin/sh if pngpaste $1 > /dev/null 2>&1 ; then pngpaste $1 echo $1 else echo "no image" fi
- 打开
~/.vscode/extensions/mushan.vscode-paste-image-1.0.4/out/src/extension.js
编辑// Mac + var scriptPath = path.join(__dirname, '../../res/mac.sh'); + var ascript = child_process_1.spawn('sh', [scriptPath, imagePath]); - var scriptPath = path.join(__dirname, '../../res/mac.applescript'); - var ascript = child_process_1.spawn('osascript', [scriptPath, imagePath]);
- 重启vscode
我修改了之后复制图片文件粘贴的是icon,最后是修改了 pngpaste 文件,https://github.com/sw926/pngpaste,make 后生用新生成的 pngpaste 替换 brew 安装的 pngpaste