2 Commits a97f1dc330 ... d9162bd0d2

Author SHA1 Message Date
  Andrew Whatson d9162bd0d2 Default to a fully-transparent edit mask 1 year ago
  Andrew Whatson a97f1dc330 Default to a fully-transparent edit mask 1 year ago
2 changed files with 13 additions and 7 deletions
  1. 3 1
      openai/image.scm
  2. 10 6
      openai/utils/magick.scm

+ 3 - 1
openai/image.scm

@@ -69,7 +69,9 @@
     (let ((png-rgba (magick-create-image #:width width
                                          #:height height
                                          #:format "PNG"
-                                         #:alpha-channel 'Activate)))
+                                         #:alpha-channel 'Activate
+                                         #:background-color "white"
+                                         #:background-alpha 0.0)))
       (call-with-port (mkstemp "/tmp/guile-openai-XXXXXX")
         (lambda (port)
           (put-bytevector port png-rgba)

+ 10 - 6
openai/utils/magick.scm

@@ -213,7 +213,9 @@
 (define (magick-alpha-channel-options)
   (alpha-channel-list))
 
-(define* (magick-convert-image image-bytes #:key format alpha-channel)
+(define* (magick-convert-image image-bytes #:key
+                               format
+                               alpha-channel)
   (call-with-magick-wand
    (lambda (wand)
      (MagickReadImageBlob* wand image-bytes)
@@ -224,16 +226,18 @@
      (MagickGetImageBlob* wand))))
 
 (define* (magick-create-image #:key width height
-                              (format "PNG")
-                              (background-color "white")
-                              (background-alpha 0.0)
+                              format
+                              background-color
+                              background-alpha
                               alpha-channel)
   (call-with-magick-wand
    (lambda (wand)
      (call-with-pixel-wand
       (lambda (background)
-        (PixelSetColor background background-color)
-        (PixelSetAlpha background background-alpha)
+        (when background-color
+          (PixelSetColor background background-color))
+        (when background-alpha
+          (PixelSetAlpha background background-alpha))
         (MagickNewImage wand width height background)))
      (when format
        (MagickSetImageFormat wand format))