‘:mask MASK’
If MASK is ‘heuristic’ or ‘(heuristic BG)’, build a clipping mask
for the image, so that the background of a frame is visible behind
the image. If BG is not specified, or if BG is ‘t’, determine the
background color of the image by looking at the four corners of the
image, assuming the most frequently occurring color from the
corners is the background color of the image. Otherwise, BG must
be a list ‘(RED GREEN BLUE)’ specifying the color to assume for the
background of the image.
If MASK is ‘nil’, remove a mask from the image, if it has one.
Images in some formats include a mask which can be removed by
specifying ‘:mask nil’.
(defun my:org--make-preview-overlay (beg end image &optional imagetype)
"Build an overlay between BEG and END using IMAGE file.
Argument IMAGETYPE is the extension of the displayed image,
as a string. It defaults to \"png\"."
(let ((ov (make-overlay beg end))
(imagetype (or (intern imagetype) 'png)))
(overlay-put ov 'org-overlay-type 'org-latex-overlay)
(overlay-put ov 'evaporate t)
(overlay-put ov
'modification-hooks
(list (lambda (o _flag _beg _end &optional _l)
(delete-overlay o))))
(overlay-put ov
'display
(list 'image :type imagetype :file image :ascent 'center :mask 'heuristic))))
(advice-add 'org--make-preview-overlay :override #'my:org--make-preview-overlay)