From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 4FUICCQiOGDMCAAA0tVLHw (envelope-from ) for ; Thu, 25 Feb 2021 22:18:12 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id uBfmAyQiOGA7GQAAbx9fmQ (envelope-from ) for ; Thu, 25 Feb 2021 22:18:12 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5BC2480D6 for ; Thu, 25 Feb 2021 23:18:11 +0100 (CET) Received: from localhost ([::1]:57004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lFOxV-0008D8-An for larch@yhetil.org; Thu, 25 Feb 2021 17:18:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFOwO-0008Ck-9I for emacs-orgmode@gnu.org; Thu, 25 Feb 2021 17:17:00 -0500 Received: from mout01.posteo.de ([185.67.36.65]:54445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFOwI-0002lU-3s for emacs-orgmode@gnu.org; Thu, 25 Feb 2021 17:17:00 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id BF601160060 for ; Thu, 25 Feb 2021 23:16:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1614291408; bh=gKcWDqgLrievqcce1ngoYJn7YEgd+E88rMs36ft7Ef0=; h=From:To:Subject:Date:From; b=lKUlhBI3XrmDpx+gPsor0nzfZF2oFopyMaVzIrLt+Motip+xAfmFjbT41agxVK3+8 M9n1S4vXqHXvp5zmzzKcffAqArqkT0fnHQ0vqUkwxT6n8XGf/654nSFsdK7CIQEbQU 5vsfFIpurRmywQcU0sflGX1i7NJ6vNHNf0rdT2omCv01lbQSlJmcJkSzcuRru0atq8 giWB1G8fROt3hfG5rZNBnYfeonB3PN7WtU6mGfsrh+MPuJB6MvwPESVMBHxgEI7BJ5 CBwu6pBEcbS21soG7mroIeHzeRgrUnrU9tzxINWNo/3K2HGwdgjgUhZ3xCUZQmp51Q r/nQco9ZMBp1Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DmnFX0dTMz6tmK for ; Thu, 25 Feb 2021 23:16:47 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: Add color space and icc profile information to images Date: Thu, 25 Feb 2021 23:16:47 +0100 Message-ID: <878s7b23ow.fsf@posteo.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.07 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=lKUlhBI3; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 5BC2480D6 X-Spam-Score: -3.07 X-Migadu-Scanner: scn1.migadu.com X-TUID: 9rOzaOCNPihq Hi, When working with images for print, I often need to get quickly the color space and icc profile information of each included image, so I came up with this function (code at the end of this mail) that I share here, in case it is useful to someone. The function inserts the information I need, under each image link in a document. For example: #+begin_src org [[file:~/Im=C3=A1genes/Arte/Lilian_May_Miller_Blue_Hills_and_Crescent_Moo= n.jpg]] # COLOR-INFO: Colorspace: sRGB | icc:description: Adobe RGB (1998) [[file:~/CA/CA10/cubierta.jpg]] # COLOR-INFO: Colorspace: CMYK | icc:description: ISO Coated v2 300% (ECI) [[file:~/Escritorio/crespo.jpg]] # COLOR-INFO: Colorspace: Gray | icc:description: GIMP built-in D65 Grays= cale with sRGB TRC #+end_src The only problem is that the process is somewhat slow, especially when the images are large or there are many images in the document. I think that this is due in part to the imagemagick process itself, and in part to the little elegance of my function ... ;-) Best regards, Juan Manuel=20 #+begin_src emacs-lisp (defun my-org-comment-colorspace () (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward org-bracket-link-regexp nil t) (when (string-match (regexp-opt '(".png" ".jpg")) (match-string 1)) (forward-char -1) (let* ((link (assoc :link (org-context))) (link-str (when link (buffer-substring-no-properties (cadr link) (caddr link))))) (string-match org-bracket-link-regexp link-str) (let* ((identify-result (shell-command-to-string (concat "identify -verbose " "\"" (expand-file-name (format "%s" (replace-regexp-in-string "file:" "" (substring link-str (match-beginning 1) (match-end 1))))) "\""))) (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))))) (forward-line 1) (beginning-of-line) (when (looking-at "\\(# COLOR-INFO:.+\\)") (delete-region (match-beginning 0) (match-end 0))) (insert (format "# COLOR-INFO: %s | %s" colorspace icc)))))))) #+end_src