emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b525f201ba: Allow specifying the color to use in image-elide


From: Lars Ingebrigtsen
Subject: master b525f201ba: Allow specifying the color to use in image-elide
Date: Wed, 14 Sep 2022 14:22:08 -0400 (EDT)

branch: master
commit b525f201ba9f4f8862059a49947874a2bfa0d2f1
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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 a88b8ed842..64db226d50 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-map>\\[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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]