Subject: | |
Emisor: | |
Reply To: | |
Fecha: | Thu, 14 Oct 2021 14:19:29 +0000 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Hola a todos:
Por si le resulta útil a alguien, escribí en este puente pasado esta
función que muestra en una ventana contigua de Emacs la información de
espacio de color y perfiles icc (si los tiene) de todas las imágenes de
un documento LaTeX. Junto a cada imagen se añade un enlace para poder
abrirla y editarla en nuestro editor preferido (por defecto es gimp,
aunque yo suelo usar más krita porque trabaja con cmyk). Esta función me
resulta útil en los documentos con muchas imágenes, para tenerlas todas
auditadas y bajo control.
O sea, que si en nuestro documento tenemos estas dos imágenes:
\includegraphics{imagen1.jpg}
\includegraphics{imagen2.jpg}
Con llamar a la función, en la ventana contigua se nos muestra esto:
imagen1.jpg >> abrir imagen
COLOR-INFO: Colorspace: sRGB | icc:description: sRGB IEC61966-2-1 black scaled
imagen2.jpg >> abrir imagen
COLOR-INFO: Colorspace: sRGB | icc:description: GIMP built-in sRGB
Es necesario tener instalado imagemagick. Dejo aquí el código, con un
saludo (por supuesto, cualquier sugerencia sobre el código siempre es
bienvenida :-)):
(defvar imagenes-doc nil)
;; con esta variable indicamos nuestro editor preferido
;; por defecto es Gimp
(setq muestra-info-color-imagen-editor-pref "gimp")
(defun muestra-info-color-imagen ()
(interactive)
(setq imagenes-doc nil)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\\\\includegraphics\\(\\[.+\\]\\)*{" nil t)
(let* ((ruta-img (buffer-substring-no-properties (point)
(save-excursion
(re-search-forward "}" nil t)
(1- (point)))))
(identify-result (shell-command-to-string
(concat "identify -verbose "
"\""
(expand-file-name
ruta-img
"\""))))
(colorspace (progn
(string-match "\\(Colorspace:.+\\)" identify-result)
(substring identify-result
(match-beginning 1)
(match-end 1))))
(icc (progn
(string-match "\\(icc:description:.+\\)" identify-result)
(substring identify-result
(match-beginning 1)
(match-end 1)))))
(add-to-list 'imagenes-doc (format "%s\nCOLOR-INFO: %s | %s" ruta-img colorspace icc)))))
(let ((img-lista (mapconcat 'identity imagenes-doc "\n\n"))
(buf (buffer-file-name (current-buffer))))
(when (get-buffer "*info-img*")
(kill-buffer "*info-img*"))
(get-buffer-create "*info-img*")
(set-buffer "*info-img*")
(insert (concat buf "\n\n" img-lista))
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\\(.+\\)\\(jpg\\|png\\|tif\\)" nil t)
(insert-button (format " >> abrir imagen" )
'action (lambda (x)
(let*
((ruta (save-excursion
(beginning-of-line)
(re-search-forward "\\(.+\\)\\(jpg\\|png\\|tif\\)" nil t)
(match-string 0)))
(comando (format "%s %s"
muestra-info-color-imagen-editor-pref
(expand-file-name ruta))))
(start-process-shell-command comando nil comando))))))
(switch-to-buffer-other-window "*info-img*")))
----------------------------------------------------
Archivos de ES-TEX: http://listserv.rediris.es/archives/es-tex.html
------------------------------------------------------
|
|
|