回答:
そのような機能はパッケージによって提供されます:
サムネイルバッファ内のポイントを使用すると、RET(
image-dired-display-thumbnail-original-image)と入力して、サイズ変更されたバージョンを別のウィンドウに表示できます。これにより、ウィンドウに合わせて画像のサイズが変更されます。
ImageMagickのconvertコマンドを使用します。
また、を使用image-dired-external-viewerして問題を回避し、などの外部画像ビューアで画像を表示することもできますfeh。
(add-hook 'image-mode-hook 'eimp-mode)
mogrifyImageMagick のユーティリティを使用して、実際の変換を行います。
(kbd "+") 'eimp-increase-image-size
(kbd "-") 'eimp-decrease-image-size
(kbd "<") 'eimp-rotate-image-anticlockwise
(kbd ">") 'eimp-rotate-image-clockwise
(kbd "B +") 'eimp-blur-image
(kbd "B -") 'eimp-sharpen-image
(kbd "B E") 'eimp-emboss-image
(kbd "B G") 'eimp-gaussian-blur-image
(kbd "B R") 'eimp-radial-blur-image
(kbd "C B +") 'eimp-increase-image-brightness
(kbd "C B -") 'eimp-decrease-image-brightness
(kbd "C C +") 'eimp-increase-image-contrast
(kbd "C C -") 'eimp-decrease-image-contrast
(kbd "F ^") 'eimp-flip-image
(kbd "F >") 'eimp-flop-image
(kbd "F <") 'eimp-flop-image
(kbd "N") 'eimp-negate-image
; Commands most relevant to you:
(kbd "S f") 'eimp-fit-image-to-window
(kbd "S h") 'eimp-fit-image-height-to-window
(kbd "S w") 'eimp-fit-image-width-to-window
(kbd "<right>") 'eimp-roll-image-right
(kbd "<left>") 'eimp-roll-image-left
(kbd "<up>") 'eimp-roll-image-up
(kbd "<down>") 'eimp-roll-image-down
(kbd "<down-mouse-1>") 'eimp-mouse-resize-image
(kbd "<S-down-mouse-1>") 'eimp-mouse-resize-image-preserve-aspect
(kbd "C-c C-k") 'eimp-stop-all
eiv-また、提供する必要があるImageMagickパッケージも使用しますmogrify。
完全なコマンドリスト:
eiv-fit-image-to-window- 画像のサイズを現在のウィンドウサイズに変更します。eiv-rotate-current-image -現在の画像を90度回転します。 eiv-dec-or-inc-image -イメージのサイズを現在のウィンドウサイズに変更します。 eiv-diaporama -ツリーでディアポラマを開始します。 eiv-viewer- emacs-image-viewer。dirおよびsubdirのツリー内を移動できます。ソースコードを使用lisp/image-mode.elしてこれを記述しました。任意の画像バッファでこの関数を呼び出すと、画像とウィンドウの高さ/幅の比率に応じて、幅または高さに合うようにサイズが変更されます。
この関数が機能するには、次の2つのことが必要です。
libjpegローダーはjpg画像の処理に使用されます。この回答の次の部分に示すハックは、emacsにimagemagickローダーを強制的に使用させるために使用されます。(defun modi / image-transform-fit-to-window()
「画像とウィンドウの比率に基づいて、幅または高さに合わせて画像のサイズを変更します。
この機能を実行するには、Imagemagickが必要です。」
(インタラクティブ)
(let *((img-size(image-display-size(image-get-display-property)t)))
(img-width(car img-size))
(img-height(cdr img-size))
(img-h / w-ratio(/(float img-height)(float img-width)))
(win-width(-(nth 2(window-inside-pixel-edges)))
(nth 0(ウィンドウ内ピクセルエッジ)))))
(win-height(-(nth 3(window-inside-pixel-edges)))
(nth 1(window-inside-pixel-edges)))))
(win-h / w-atio(/(float win-height)(float win-width))))
;; ウィンドウのh / w比が画像のh / w比より大きい場合、幅で画像をフィット
(if(> win-h / w-ratio img-h / w-ratio)
(幅に合わせて画像変換)
;; その他の高さによる適合
(高さに合わせて画像変換))))
imagemagick画像の読み込みにemacsを強制的に使用するハックemacsバグレポート#18797、#10746およびをフォローした後#10112、Imagemagickに画像を強制的にロードさせるために次のソリューションが機能しました。あなたのどこかにそれを置きますinit.el:
私が使用するのemacsを余儀なくされていますimagemagick:私だけになじみの画像ファイルのpng、tiff、jpg/jpegとsvg。残りはデフォルトとして保持されます。私は許可することを選択したgifファイルは、マルチフレーム画像を表示するためのサポートが改善されたemacsの24.4として、デフォルトのローダーでオープンします。正規表現全体はから取得されlisp/image.elます。
(setq image-type-header-regexps
`(
("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm)
("\\`P[1-6]\\\(?:\
\\(?:\\(?:#[^\r\n]*[\r\n]\\)?[[:space:]]\\)+\
\\(?:\\(?:#[^\r\n]*[\r\n]\\)?[0-9]\\)+\
\\)\\{2\\}" . pbm)
("\\`GIF8[79]a" . gif)
;; ("\\`\x89PNG\r\n\x1a\n" . png) ;; Uncomment this (and comment the below line) to enable inline png images in org-mode
("\\`\x89PNG\r\n\x1a\n" . imagemagick) ; png
("\\`[\t\n\r ]*#define \\([a-z0-9_]+\\)_width [0-9]+\n\
#define \\1_height [0-9]+\n\\(\
#define \\1_x_hot [0-9]+\n\
#define \\1_y_hot [0-9]+\n\\)?\
static \\(unsigned \\)?char \\1_bits" . xbm)
;; ("\\`\\(?:MM\0\\*\\|II\\*\0\\)" . tiff)
("\\`\\(?:MM\0\\*\\|II\\*\0\\)" . imagemagick) ; tiff
("\\`[\t\n\r ]*%!PS" . postscript)
;; ("\\`\xff\xd8" . jpeg) ;; Uncomment this (and comment the below line) to enable inline jpg images in org-mode
("\\`\xff\xd8" . imagemagick) ; jpeg
("\\`\377\330" . imagemagick) ; jpeg
(,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
(comment-re (concat "\\(?:!--" incomment-re "*-->[ \t\r\n]*<\\)")))
(concat "\\(?:<\\?xml[ \t\r\n]+[^>]*>\\)?[ \t\r\n]*<"
comment-re "*"
"\\(?:!DOCTYPE[ \t\r\n]+[^>]*>[ \t\r\n]*<[ \t\r\n]*" comment-re "*\\)?"
"[Ss][Vv][Gg]"))
;; . svg) ;; Uncomment this (and comment the below line) to enable inline svg images in org-mode
. imagemagick) ; svg
))
imagemagickように選択された画像タイプは、にインライン画像として表示されませんorg-mode。image-transform-set-scaleあなたが探しているものかもしれません。ただし、EmacsをImagemagickサポート付きでコンパイルする必要があります。
コメントアウトもありimage-transform-modeでimage-mode.el標識「まだ実装されていません。」
Does Emacs use imagemagick? yes実行中に表示されます./configure。そのため、imagemagickでコンパイルしました。静止画の変換は機能しません。(emacs 24.4 x86_64-unknown-linux-gnuで)次のものもありますconfig.log:| #define HAVE_IMAGEMAGICK 1 | #define HAVE_MAGICKEXPORTIMAGEPIXELS 1 | #define HAVE_MAGICKMERGEIMAGELAYERS 1。
テキストのスケーリングに使用されるものと同じキーを使用して、Cx C- =およびCx C--
(defun scale-image ()
"Scale the image by the same factor specified by the text scaling."
(image-transform-set-scale
(expt text-scale-mode-step
text-scale-mode-amount)))
(defun scale-image-register-hook ()
"Register the image scaling hook."
(add-hook 'text-scale-mode-hook 'scale-image))
(add-hook 'image-mode-hook 'scale-image-register-hook)
eimpファイルを変更することに注意してください。読み取り専用画像では機能しません。