Org 中显示 inline 图片时,图片尺寸可以控制吗?

能不能看看 module 文件夹里的内容?我用的 linux 没法帮你看

如果 path 设置正确,在 emacs 里

M-: (image-type-available-p 'imagemagick) RET

应该会在 minibuffer 内显示 t

下面三张截图是modules文件夹里面的内容

另外我在这里找到了一个信息:

John Kitchin回答说,不仅要安装ImageMagick还需要Emacs支持它才行。我怀疑我安装的Emacs不支持ImageMagick,请问你知道如何才能获得支持它的Emacs吗?

如果不能下载的话,用下面的链接,然后点第一个(下载的次数最多的那个):

非常感谢你的帮助,时间不早,我先下载文件,明天再继续研究,你也早点休息吧!

我从你提供的链接下载了emacs-w64-25.1-O2-with-modules.7z,重新安装了ImageMagick-7.0.5-Q16。我注意到在安装ImageMagick的时候有一步会提示把ImageMagick添加到环境变量,我勾选了这个选项。安装完成后,也能看到在环境变量里ImageMagick目录已经自动添加。

做完这些依然不能缩放图片。

M-: (image-type-available-p 'imagemagick) RET

M-:开头的命令我没有执行过,请问该如何执行?

Alt + Shift + ;

后面的 RET 代表回车

执行的结果是nil

你把路径里的这一段用双引号包起来试试,因为你的安装路径里面有空格,注意不要把分号也括进去了。完了以后重启emacs再试验一下

你能不能把 C-h v exec-path

的结果也贴出来

还有你运行 emacs 是用的 runemacs 吗?

是用runemacs来启动的

路径添加了引号,确定。关闭EMACS重新打开,执行

M-: (image-type-available-p 'imagemagick) RET

还是返回nil

你能不能把C-h v exec-path

的结果也贴出来

exec-path is a variable defined in ‘C source code’.
Its value is
("C:/Users/admin/AppData/Roaming/.emacs.d/fcitx-remote" "\"C:/Program Files/ImageMagick-7.0.5-Q16\"" "C:/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler" "C:/Windows/system32" "C:/Windows" "C:/Windows/System32/Wbem" "C:/Windows/System32/WindowsPowerShell/v1.0/" "C:/Program Files (x86)/QuickTime/QTSystem/" "C:/Users/admin/AppData/Local/Pandoc/" "d:/GProgram/emacs_with_modules/libexec/emacs/25.1/x86_64-w64-mingw32")

Original value was 
("c:/Users/admin/AppData/Roaming/.emacs.d/fcitx-remote" "\"C:/Program Files/ImageMagick-7.0.5-Q16\"" "c:/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler" "c:/Windows/system32" "c:/Windows" "c:/Windows/System32/Wbem" "c:/Windows/System32/WindowsPowerShell/v1.0" "c:/Program Files (x86)/QuickTime/QTSystem" "c:/Users/admin/AppData/Local/Pandoc" "d:/GProgram/emacs_with_modules/libexec/emacs/25.1/x86_64-w64-mingw32")


  This variable may be risky if used as a file-local variable.

Documentation:
List of directories to search programs to run in subprocesses.
Each element is a string (directory name) or nil (try default directory).

By default the last element of this list is ‘exec-directory’. The
last element is not always used, for example in shell completion
(‘shell-dynamic-complete-command’).

You can customize this variable.

再试试把 imagemagick 下面的几个子文件夹比如 modules 添加到 path 中

还有就是 M-! (Alt Shift 1) 在 emacs 里执行一下 magick -help

如果以上都不行,装个虚拟机,安装随便哪个 linux,然后体验完整版的 spacemacs :joy:

开个玩笑

你稍等,我装一个 windows 下的 emacs 试试

我把几个有dll文件的字文件夹路径都添加到path里面了,现在环境变量是

c:\Program Files\ImageMagick-7.0.5-Q16\;c:\Program Files\ImageMagick-7.0.5-Q16\modules\;c:\Program Files\ImageMagick-7.0.5-Q16\modules\filters\;c:\Program Files\ImageMagick-7.0.5-Q16\modules\coders\;"C:\Program Files\ImageMagick-7.0.5-Q16";%INTEL_DEV_REDIST%redist\intel64\compiler;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;

执行

M-: (image-type-available-p 'imagemagick) RET

还是得到nil

还有就是 M-! (Alt Shift 1) 在 emacs 里执行一下 magick -help

执行这个之后得到

不要折腾了,目前版本的 emacs-w64 是不支持 imagemagick 的,之前我记得 24.5 的时候好像是支持的。

下面 John Kitchin 给了一种解决方案:

As noted in some comments above, you need to have the mogrify program installed. With the code at that location, images get scaled in org-mode on windows for us.

reddit 上也有相关讨论,这不是只有你一个人遇到的问题。

https://www.reddit.com/r/emacs/comments/4p5o2f/imagemagick_support_on_windows/?st=itovnhtq&sh=654dd723

我看了一下他们的讨论,貌似是因为 imagemagick 升级后有了比较大的改动,导致目前 windows 下的 emacs 版本都不能支持 imagemagick,估计要安装旧版本的 imagemagick + emacs 才行。

也许我的玩笑话也不失为一种解决方案,换了 linux 后你会发现原来各种折腾的问题现在根本都不是事 :joy:

看来没办法了,但还是非常感谢你的帮助! 不知道EMACS有没有改善这个问题的计划

应该会的,但是我们没必要等,对吧。

你可以试试 John Kitchin 的办法,虽然比较 hacky,但他确实在 windows 上面实现了缩放。

你需要: 1.安装 mogrify.exe,原来的 imagemagick 中的 convert.exe 命令已经不存在了(这也是让我比较困惑的地方,变化比较大)

2.用 John Kitchin 的代码: scimax/scimax-org.el at master · jkitchin/scimax · GitHub

或者: 安装 Linux,开始另一端折腾 :joy:

1 个赞

用linux对我来说几乎不可能,还是来挑战一下hack的方法吧!

可惜在第一步就碰到了问题。mogrify.exe貌似是imagemagick里的东西,但是我安装的这个imagemagick又没有,于是google了一下,从这里(http://www.fixfile.info/mogrify.exe/en-download-56048.html)下载了mogrify.exe,可惜直接运行会报错。

于是我又从上面那个连接下载了ImageMagick-6.9.3-7-vc11-x64.zip,但解压出来并没有安装文件,貌似是绿色版。我在解压出来的bin文件夹里发现了mogrify.exe文件,可以运行。但我并没有“安装”它,估计也不能用吧。

第二步,John Kitchin的代码改如何使用?

和我一样都是不折腾会死星人 :joy:,你先拷贝到 elisp buffer 里 eval 一下试试。