From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#51381: HEIF image format support Date: Fri, 26 Nov 2021 13:02:28 +0000 Message-ID: References: <87fsspw2mr.fsf@gnus.org> <875ytkhjbu.fsf@gnus.org> <87a6iubos9.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="xEcjXI8ovOJdwUJI" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33398"; mail-complaints-to="usenet@ciao.gmane.io" To: Lars Ingebrigtsen , Glenn Morris , Stefan Kangas , 51381@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 26 14:03:20 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mqaso-0008L0-En for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Nov 2021 14:03:18 +0100 Original-Received: from localhost ([::1]:42874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mqasn-0003Sm-98 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Nov 2021 08:03:17 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqasd-0003S8-M4 for bug-gnu-emacs@gnu.org; Fri, 26 Nov 2021 08:03:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mqasY-0003Hf-Fu for bug-gnu-emacs@gnu.org; Fri, 26 Nov 2021 08:03:07 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mqasY-0002wb-D0 for bug-gnu-emacs@gnu.org; Fri, 26 Nov 2021 08:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Nov 2021 13:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51381 X-GNU-PR-Package: emacs Original-Received: via spool by 51381-submit@debbugs.gnu.org id=B51381.163793176311208 (code B ref 51381); Fri, 26 Nov 2021 13:03:02 +0000 Original-Received: (at 51381) by debbugs.gnu.org; 26 Nov 2021 13:02:43 +0000 Original-Received: from localhost ([127.0.0.1]:58948 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mqasF-0002ui-1x for submit@debbugs.gnu.org; Fri, 26 Nov 2021 08:02:43 -0500 Original-Received: from outbound.soverin.net ([116.202.126.228]:60085) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mqasD-0002u1-AL for 51381@debbugs.gnu.org; Fri, 26 Nov 2021 08:02:42 -0500 Original-Received: from smtp.soverin.net (unknown [10.10.3.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id B72442A0; Fri, 26 Nov 2021 13:02:33 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.138]) by soverin.net DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1637931752; bh=/0uhek7+Z8meQ7sQlTJel1DXGkDidpuaCX/2d0kvFic=; h=Date:From:To:Subject:References:In-Reply-To:From; b=l/aoA4ToSV4pgl41jmipqOjr8/zgqzUHHMotwBofoF/KiN21XtnM+prIyZflnrwxy Q8pHwymcJNC0K2MnxCCeCEaAQAuDXbHF/PhupeTiAIVCamFY+ab8Pf1gYE9qyWpdAA 5NbUOcibU0iTbO18T7mijsJpo7Yv3rk4TSH/3G58s6tHM16/Hpw2ICDbDyf1TluJqO sbi2zgDd0nQc/xikfQhr1JwlVYKUWeLEGATMPRIC5ghpyuRs5oRQMpDlggExhgZBK/ TFlqcQVN2sRkGAWIVnkaB0nSrVYZtgO3TLzqa/RqHyaox+g7OpowySC+RNfs5dNtKy J1sgB+NAWyJNw== Original-Received: by breton.holly.idiocy.org (Postfix, from userid 501) id 07300202DB9D87; Fri, 26 Nov 2021 13:02:28 +0000 (GMT) Mail-Followup-To: Alan Third , Lars Ingebrigtsen , Glenn Morris , Stefan Kangas , 51381@debbugs.gnu.org Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:220870 Archived-At: --xEcjXI8ovOJdwUJI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Oct 27, 2021 at 05:13:17PM +0100, Alan Third wrote: > > FWIW NSImage (on macOS) is already capable of loading an heic file, if > we just point it to it. I thought all we needed to do is add heic to > ns_can_use_native_image_api in nsimage.m and then load an image with > the type of "heic" or whatever, but it doesn't work and I'm not sure > what else I need to do. Probably define heic as a type elsewhere. Patch attached. I'm not entirely sure this won't break anything, so testing on a platform that already supports heif files would probably be a good idea. It doesn't support any of the interesting features of heif, for example it doesn't allow you to view multiple images (like an animated gif), but I have a suspicion the IM/GM code won't support that anyway, so no great loss. -- Alan Third --xEcjXI8ovOJdwUJI Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Add-native-HEIC-support-on-macOS-bug-51381.patch" >From b12846cadfa052e222a7b026868e66a5a897a65a Mon Sep 17 00:00:00 2001 From: Alan Third Date: Fri, 26 Nov 2021 12:54:07 +0000 Subject: [PATCH] Add native HEIC support on macOS (bug#51381) * lisp/image.el (image-type-header-regexps): (image-type-file-name-regexps): (image-type-auto-detectable): Add auto-detect code for heic. * src/image.c (syms_of_image): Add heic as an image type under NS. * src/nsimage.m (ns_can_use_native_image_api): Add heic to list of possible image types in the native image support lookup. --- lisp/image.el | 7 ++++--- src/image.c | 5 +++++ src/nsimage.m | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lisp/image.el b/lisp/image.el index edbf6c54df..1321560575 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -56,7 +56,7 @@ image-type-header-regexps "\\(?:!DOCTYPE[ \t\r\n]+[^>]*>[ \t\r\n]*<[ \t\r\n]*" comment-re "*\\)?" "[Ss][Vv][Gg]")) . svg) - ) + ("\\`....ftyp\\(heic\\|heix\\|hevc\\|heim\\|heis\\|hevm\\|hevs\\|mif1\\|msf1\\)" . heic)) "Alist of (REGEXP . IMAGE-TYPE) pairs used to auto-detect image types. When the first bytes of an image file match REGEXP, it is assumed to be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol. If not a symbol, @@ -76,7 +76,7 @@ image-type-file-name-regexps ("\\.ps\\'" . postscript) ("\\.tiff?\\'" . tiff) ("\\.svgz?\\'" . svg) - ) + ("\\.hei[cf]s?\\'" . heic)) "Alist of (REGEXP . IMAGE-TYPE) pairs used to identify image files. When the name of an image file match REGEXP, it is assumed to be of image type IMAGE-TYPE.") @@ -95,7 +95,8 @@ image-type-auto-detectable (tiff . maybe) (svg . maybe) (webp . maybe) - (postscript . nil)) + (postscript . nil) + (heic . maybe)) "Alist of (IMAGE-TYPE . AUTODETECT) pairs used to auto-detect image files. \(See `image-type-auto-detected-p'). diff --git a/src/image.c b/src/image.c index f2597f529d..e94a22caf7 100644 --- a/src/image.c +++ b/src/image.c @@ -11320,6 +11320,11 @@ syms_of_image (void) #endif /* HAVE_NTGUI */ #endif /* HAVE_RSVG */ +#ifdef HAVE_NS + DEFSYM (Qheic, "heic"); + add_image_type (Qheic); +#endif + #if HAVE_NATIVE_IMAGE_API DEFSYM (Qnative_image, "native-image"); # ifdef HAVE_NTGUI diff --git a/src/nsimage.m b/src/nsimage.m index dd2bb3b0d7..98efc9c6c0 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -76,6 +76,8 @@ Updated by Christian Limpach (chris@nice.ch) imageType = @"public.tiff"; else if (EQ (type, Qsvg)) imageType = @"public.svg-image"; + else if (EQ (type, Qheic)) + imageType = @"public.heic"; /* NSImage also supports a host of other types such as PDF and BMP, but we don't yet support these in image.c. */ -- 2.32.0 --xEcjXI8ovOJdwUJI--