Fix external image conversion on MS-Windows
* lisp/image/image-converter.el (image-converter--convert-magick) (image-converter--convert): Force encoding/decoding to avoid any text or EOL conversions, since we are reading/writing binary data. (Bug#56317)
This commit is contained in:
parent
6f22631a63
commit
f5421104e9
1 changed files with 22 additions and 18 deletions
|
@ -227,11 +227,13 @@ Only suffixes that map to `image-mode' are returned."
|
||||||
(cadr (split-string (symbol-name image-format) "/"))))
|
(cadr (split-string (symbol-name image-format) "/"))))
|
||||||
|
|
||||||
(defun image-converter--convert-magick (type source image-format)
|
(defun image-converter--convert-magick (type source image-format)
|
||||||
(let ((command (image-converter--value type :command)))
|
(let ((command (image-converter--value type :command))
|
||||||
|
(coding-system-for-read 'no-conversion))
|
||||||
(unless (zerop (if image-format
|
(unless (zerop (if image-format
|
||||||
;; We have the image data in SOURCE.
|
;; We have the image data in SOURCE.
|
||||||
(progn
|
(progn
|
||||||
(insert source)
|
(insert source)
|
||||||
|
(let ((coding-system-for-write 'no-conversion))
|
||||||
(apply #'call-process-region (point-min) (point-max)
|
(apply #'call-process-region (point-min) (point-max)
|
||||||
(car command) t t nil
|
(car command) t t nil
|
||||||
(append
|
(append
|
||||||
|
@ -239,7 +241,7 @@ Only suffixes that map to `image-mode' are returned."
|
||||||
(list (format "%s:-"
|
(list (format "%s:-"
|
||||||
(image-converter--mime-type
|
(image-converter--mime-type
|
||||||
image-format))
|
image-format))
|
||||||
"png:-"))))
|
"png:-")))))
|
||||||
;; SOURCE is a file name.
|
;; SOURCE is a file name.
|
||||||
(apply #'call-process (car command)
|
(apply #'call-process (car command)
|
||||||
nil t nil
|
nil t nil
|
||||||
|
@ -252,10 +254,12 @@ Only suffixes that map to `image-mode' are returned."
|
||||||
(cl-defmethod image-converter--convert ((type (eql 'ffmpeg)) source
|
(cl-defmethod image-converter--convert ((type (eql 'ffmpeg)) source
|
||||||
image-format)
|
image-format)
|
||||||
"Convert using ffmpeg."
|
"Convert using ffmpeg."
|
||||||
(let ((command (image-converter--value type :command)))
|
(let ((command (image-converter--value type :command))
|
||||||
|
(coding-system-for-read 'no-conversion))
|
||||||
(unless (zerop (if image-format
|
(unless (zerop (if image-format
|
||||||
(progn
|
(progn
|
||||||
(insert source)
|
(insert source)
|
||||||
|
(let ((coding-system-for-write 'no-conversion))
|
||||||
(apply #'call-process-region
|
(apply #'call-process-region
|
||||||
(point-min) (point-max) (car command)
|
(point-min) (point-max) (car command)
|
||||||
t '(t nil) nil
|
t '(t nil) nil
|
||||||
|
@ -263,7 +267,7 @@ Only suffixes that map to `image-mode' are returned."
|
||||||
(cdr command)
|
(cdr command)
|
||||||
(list "-i" "-"
|
(list "-i" "-"
|
||||||
"-c:v" "png"
|
"-c:v" "png"
|
||||||
"-f" "image2pipe" "-"))))
|
"-f" "image2pipe" "-")))))
|
||||||
(apply #'call-process
|
(apply #'call-process
|
||||||
(car command)
|
(car command)
|
||||||
nil '(t nil) nil
|
nil '(t nil) nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue