From b525f201ba9f4f8862059a49947874a2bfa0d2f1 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 14 Sep 2022 20:21:54 +0200 Subject: [PATCH] Allow specifying the color to use in image-elide * lisp/image/image-crop.el (image-crop-elide-command): Adjust to allow specifying the color. (image-elide): Prompt for a color. (image-crop--crop-image-update): Pass the color along. --- lisp/image/image-crop.el | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lisp/image/image-crop.el b/lisp/image/image-crop.el index a88b8ed842e..64db226d50e 100644 --- a/lisp/image/image-crop.el +++ b/lisp/image/image-crop.el @@ -48,7 +48,8 @@ The following `format-spec' elements are allowed: :version "29.1") (defcustom image-crop-elide-command '("convert" "-draw" "rectangle %l,%t %r,%b" - "-" "%f:-") + "-fill" "%c" + "-" "%f:-") "Command to make a rectangle inside an image. The following `format-spec' elements are allowed: @@ -56,12 +57,13 @@ The following `format-spec' elements are allowed: %t: Top. %r: Right. %b: Bottom. +%c: Color. %f: Result file type." :type '(repeat string) :version "29.1") (defcustom image-crop-crop-command '("convert" "+repage" "-crop" "%wx%h+%l+%t" - "-" "%f:-") + "-" "%f:-") "Command to crop an image. The following `format-spec' elements are allowed: @@ -97,12 +99,17 @@ original buffer text, and the second parameter is the cropped image data.") ;;;###autoload -(defun image-elide (&optional square) +(defun image-elide (color &optional square) "Elide a square from the image under point. If SQUARE (interactively, the prefix), elide a square instead of a -rectangle from the image." - (interactive "P") - (image-crop square t)) +rectangle from the image. + +Interatively, the user will be prompted for the color to use, and +defaults to black." + (interactive (list (read-color "Use color: ") + current-prefix-arg)) + (image-crop square (if (string-empty-p color) + "black" color))) ;;;###autoload (defun image-crop (&optional square elide) @@ -111,7 +118,8 @@ If SQUARE (interactively, the prefix), crop a square instead of a rectangle from the image. If ELIDE, remove a rectangle from the image instead of cropping -the image. +the image. In that case ELIDE, should be the name of a color to +use. After cropping an image, it can be saved by `M-x image-save' or \\\\[image-save] when point is over the image." @@ -217,6 +225,7 @@ After cropping an image, it can be saved by `M-x image-save' or (?t . ,top) (?r . ,(+ left width)) (?b . ,(+ top height)) + (?c . ,elide) (?f . ,(cadr (split-string type "/"))))) (image-crop--process image-crop-crop-command `((?l . ,left) -- 2.39.2