GNU bug report logs - #21714
25.0.50; image-metadata using Emacs --with-ns prevents *.gif animation.

Previous Next

Package: emacs;

Reported by: Keith David Bershatsky <esq <at> lawlist.com>

Date: Mon, 19 Oct 2015 16:30:04 UTC

Severity: normal

Tags: patch

Found in version 25.0.50

Done: Alan Third <alan <at> idiocy.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21714 in the body.
You can then email your comments to 21714 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#21714; Package emacs. (Mon, 19 Oct 2015 16:30:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Keith David Bershatsky <esq <at> lawlist.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 19 Oct 2015 16:30:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Keith David Bershatsky <esq <at> lawlist.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50;
 image-metadata using Emacs --with-ns prevents *.gif animation.
Date: Mon, 19 Oct 2015 09:29:17 -0700
When using Emacs built --with-ns on OSX 10.6.8, the function `image-metadata` returns `nil` when trying to animate a *.gif file with the built-in image-mode by pressing the return key.  I suspect it is because `valid_image_p` returns `nil`, but I do not know how to test that internal function.

When opening a *.gif image, Emacs successfully displays the first image in the series of multiple images.  Pressing the return key yields:  "No image animation."

OSX has its own built-in image support when building --with-ns, which is why I am able to see the first of the *.gif images.

(image-type-available-p 'gif) returns t, so I am fairly certain I have image support.

Animation works on Emacs for Windows, but not OSX.

Thanks,

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

In GNU Emacs 25.0.50.1 (x86_64-apple-darwin10.8.0, NS appkit-1038.36 Version 10.6.8 (Build 10K549))
 of 2015-10-13
Repository revision: 6d6bf466477b004035a4314886e35214c6f8603b
Windowing system distributor 'Apple', version 10.3.1038
Configured using:
 'configure --with-ns --without-imagemagick --enable-checking=glyphs'

Configured features:
RSVG DBUS ACL LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS

Important settings:
  locale-coding-system: utf-8-unix

Major mode: C

Minor modes in effect:
  tb-mode: t
  sb-mode: t
  ml-mode: t
  sd-mode: t
  fl-mode: t
  bc-mode: t
  +-mode: t
  buffer-read-only: t
  abbrev-mode: t

Recent messages:
Type C-c C-c to view the image as text.
Wrote /Users/HOME/.0.data/.0.emacs/.lock
Emacs:  image-metadata
*beep*
if: End of buffer

Load-path shadows:
None found.

Features:
(shadow emacsbug sendmail lawlist-ztree lawlist-ys lawlist-ws
lawlist-wl elmo-imap4 elmo-localdir modb-standard modb-legacy
elmo-internal elmo-flag mmelmo-imap mmelmo-buffer elsp-generic mel-u
ps-print ps-def lpr epg-config enriched lawlist-w3m doc-view jka-compr
image-mode ccl lawlist-vl lawlist-view lawlist-undo lawlist-txt
lawlist-tm lawlist-tex compare-w lawlist-tabbar lawlist-speedbar
lawlist-shell info esh-groups ehelp ange-ftp lawlist-sgml lawlist-sb
lawlist-saveplace lawlist-ruler lawlist-replace lawlist-rectangle
lawlist-re-builder lawlist-python skeleton lawlist-profiler
lawlist-print lawlist-php cl-seq cc-langs lawlist-perl lawlist-parens
lawlist-org lawlist-calendar org-agenda org org-macro org-footnote
org-pcomplete org-list org-faces org-entities org-version
ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src
ob-keys ob-comint ob-core ob-eval org-compat org-macs org-loaddefs
find-func holidays hol-loaddefs cal-menu calendar cal-loaddefs
lawlist-neotree lawlist-movement lawlist-mouse lawlist-ml lawlist-misc
lawlist-messages lawlist-mc rect lawlist-markdown noutline outline
lawlist-lorem lawlist-ln lawlist-keymap lawlist-js cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
lawlist-ispell lawlist-isearch lawlist-imenu lawlist-ibuffer
lawlist-hl lawlist-grep lawlist-git ido seq vc-git vc vc-dispatcher
thingatpt time-stamp subr-x server nntp gnus-group gnus-undo
gnus-start gnus-cloud nnimap nnmail mail-source tls utf7 netrc
parse-time gnus-spec gnus-int gnus-range gnus-win nnoo mm-view
mml-smime smime dig mailcap log-edit message mml mml-sec mm-decode
mm-bodies mm-encode gmm-utils mailheader pcvs-util add-log ldap json
find-lisp ediff-merg ediff-wind ediff-diff ediff-mult ediff-help
ediff-init ediff-util ediff diff-mode conf-mode autorevert filenotify
lawlist-framebufs lawlist-frame lawlist-fm lawlist-files zeroconf dbus
xml lawlist-env lawlist-elscreen lawlist-elisp lawlist-dv
lawlist-image lawlist-ds lawlist-dired dired format-spec lawlist-diff
lawlist-desktop frameset lawlist-debug lawlist-window debug
lawlist-css smie lawlist-compile rx lawlist-color lawlist-cm
lawlist-cc lawlist-font-lock cl-macs lawlist-calc lawlist-calc+
lawlist-bk lawlist-bc lawlist-bbdb gnus gnus-ems nnheader mail-utils
wid-edit mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
mail-extr rfc822 timezone lawlist-minibuffer gv lawlist-auth gnus-util
mm-util help-fns mail-prsvr password-cache lawlist-as lawlist-archive
lawlist-+ lawlist-lcl byte-opt bytecomp byte-compile cl-extra cconv
lawlist-help disp-table easy-mmode edmacro kmacro quail help-mode
easymenu cl-loaddefs cl-lib pcase derived advice shell pcomplete
comint ansi-color ring savehist time-date mule-util tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel ns-win
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese
eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook
help simple abbrev minibuffer cl-preloaded nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote dbusbind cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 2395843 198980)
 (symbols 48 89769 0)
 (miscs 40 1373 1067)
 (strings 32 212905 17549)
 (string-bytes 1 7685690)
 (vectors 16 44361)
 (vector-slots 8 1091868 14715)
 (floats 8 4334 755)
 (intervals 56 1101 110)
 (buffers 976 15))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21714; Package emacs. (Mon, 19 Oct 2015 23:42:01 GMT) Full text and rfc822 format available.

Message #8 received at 21714 <at> debbugs.gnu.org (full text, mbox):

From: Xue Fuqiao <xfq.free <at> gmail.com>
To: Keith David Bershatsky <esq <at> lawlist.com>
Cc: 21714 <at> debbugs.gnu.org
Subject: Re: bug#21714: 25.0.50; image-metadata using Emacs --with-ns prevents
 *.gif animation.
Date: Tue, 20 Oct 2015 07:40:58 +0800
On Tue, Oct 20, 2015 at 12:29 AM, Keith David Bershatsky
<esq <at> lawlist.com> wrote:
> When opening a *.gif image, Emacs successfully displays the first image in the series of multiple images.  Pressing the return key yields:  "No image animation."

Yes, I can reproduce this problem on OS X 10.11 with Emacs master.

Configured features:
ACL LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21714; Package emacs. (Sun, 13 Aug 2017 00:59:01 GMT) Full text and rfc822 format available.

Message #11 received at 21714 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: Keith David Bershatsky <esq <at> lawlist.com>
Cc: 21714 <at> debbugs.gnu.org
Subject: [PATCH] Add multiframe image support to NS port (bug#21714)
Date: Sun, 13 Aug 2017 01:58:18 +0100
* src/nsimage.m (image_spec_value): New function.
(ns_load_image): Handle multiple frames.
(EmacsImage::getMetadata, EmacsImage::setFrame): New function.
* src/nsterm.h (EmacsImage::getMetadata, EmacsImage::setFrame): New
function prototypes.
---
 src/nsimage.m | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/nsterm.h  |  2 ++
 2 files changed, 81 insertions(+)

diff --git a/src/nsimage.m b/src/nsimage.m
index fb2322afc3..6717202199 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -70,12 +70,38 @@ Updated by Christian Limpach (chris <at> nice.ch)
   return [EmacsImage allocInitFromFile: file];
 }
 
+static Lisp_Object
+image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found)
+{
+  Lisp_Object tail;
+
+  eassert (valid_image_p (spec));
+
+  for (tail = XCDR (spec);
+       CONSP (tail) && CONSP (XCDR (tail));
+       tail = XCDR (XCDR (tail)))
+    {
+      if (EQ (XCAR (tail), key))
+	{
+	  if (found)
+	    *found = 1;
+	  return XCAR (XCDR (tail));
+	}
+    }
+
+  if (found)
+    *found = 0;
+  return Qnil;
+}
+
 bool
 ns_load_image (struct frame *f, struct image *img,
                Lisp_Object spec_file, Lisp_Object spec_data)
 {
   EmacsImage *eImg = nil;
   NSSize size;
+  Lisp_Object lisp_index = image_spec_value (img->spec, QCindex, NULL);
+  unsigned int index = INTEGERP (lisp_index) ? XFASTINT (lisp_index) : 0;
 
   NSTRACE ("ns_load_image");
 
@@ -99,12 +125,20 @@ Updated by Christian Limpach (chris <at> nice.ch)
       return 0;
     }
 
+  if (index < 0 || ![eImg setFrame: index])
+    {
+      add_to_log ("Unable to set index %d for image %s", index, img->spec);
+      return 0;
+    }
+
   size = [eImg size];
   img->width = size.width;
   img->height = size.height;
 
   /* 4) set img->pixmap = emacsimage */
   img->pixmap = eImg;
+
+  img->lisp_data = [eImg getMetadata];
   return 1;
 }
 
@@ -435,4 +469,49 @@ - (NSColor *)stippleMask
   return stippleMask;
 }
 
+/* If the image has multiple frames, get a count of them and the
+   animation delay, if available. */
+- (Lisp_Object)getMetadata
+{
+  Lisp_Object metadata = Qnil;
+
+  for (NSImageRep * r in [self representations])
+    {
+      if ([r isKindOfClass:[NSBitmapImageRep class]])
+        {
+          NSBitmapImageRep * bm = (NSBitmapImageRep *)r;
+          int frames = [[bm valueForProperty: NSImageFrameCount] intValue];
+          float delay = [[bm valueForProperty: NSImageCurrentFrameDuration]
+                          floatValue];
+
+          if (frames > 1)
+            metadata = Fcons (Qcount, Fcons (make_number (frames), metadata));
+          if (delay > 0)
+            metadata = Fcons (Qdelay, Fcons (make_float (delay), metadata));
+          break;
+        }
+    }
+  return metadata;
+}
+
+/* Attempt to set the animation frame to be displayed. */
+- (BOOL)setFrame: (unsigned int) index
+{
+  for (NSImageRep * r in [self representations])
+    {
+      if ([r isKindOfClass:[NSBitmapImageRep class]])
+        {
+          NSBitmapImageRep * bm = (NSBitmapImageRep *)r;
+          if ([[bm valueForProperty: NSImageFrameCount] intValue] <= index)
+            continue;
+
+          [bm setProperty: NSImageCurrentFrame
+                withValue: [NSNumber numberWithUnsignedInt: index]];
+          return YES;
+        }
+    }
+
+  return NO;
+}
+
 @end
diff --git a/src/nsterm.h b/src/nsterm.h
index 0f1b36db7b..67c0d42ac1 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -668,6 +668,8 @@ typedef id instancetype;
               alpha:(unsigned char)a;
 - (void)setAlphaAtX: (int)x Y: (int)y to: (unsigned char)a;
 - (NSColor *)stippleMask;
+- (Lisp_Object)getMetadata;
+- (BOOL)setFrame: (unsigned int) index;
 @end
 
 
-- 

Animated gif support, and I expect it to handle tiff with multiple
layers, or whatever.

-- 
Alan Third




Added tag(s) patch. Request was from Alan Third <alan <at> idiocy.org> to control <at> debbugs.gnu.org. (Sun, 13 Aug 2017 01:00:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21714; Package emacs. (Sun, 13 Aug 2017 13:21:02 GMT) Full text and rfc822 format available.

Message #16 received at 21714 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Alan Third <alan <at> idiocy.org>
Cc: Keith David Bershatsky <esq <at> lawlist.com>, 21714 <at> debbugs.gnu.org
Subject: Re: bug#21714: [PATCH] Add multiframe image support to NS port
 (bug#21714)
Date: Sun, 13 Aug 2017 09:21:44 -0400
Alan Third <alan <at> idiocy.org> writes:
 
> +static Lisp_Object
> +image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found)
> +{
> +  Lisp_Object tail;
> +
> +  eassert (valid_image_p (spec));
> +
> +  for (tail = XCDR (spec);
> +       CONSP (tail) && CONSP (XCDR (tail));
> +       tail = XCDR (XCDR (tail)))
> +    {
> +      if (EQ (XCAR (tail), key))
> +	{
> +	  if (found)
> +	    *found = 1;
> +	  return XCAR (XCDR (tail));
> +	}
> +    }

Wouldn't it be clearer to call Fplist_get here?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21714; Package emacs. (Sun, 13 Aug 2017 13:38:01 GMT) Full text and rfc822 format available.

Message #19 received at 21714 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: npostavs <at> users.sourceforge.net
Cc: Keith David Bershatsky <esq <at> lawlist.com>, 21714 <at> debbugs.gnu.org
Subject: Re: bug#21714: [PATCH] Add multiframe image support to NS port
 (bug#21714)
Date: Sun, 13 Aug 2017 14:37:45 +0100
On Sun, Aug 13, 2017 at 09:21:44AM -0400, npostavs <at> users.sourceforge.net wrote:
> Alan Third <alan <at> idiocy.org> writes:
>  
> > +static Lisp_Object
> > +image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found)
> > +{
> > +  Lisp_Object tail;
> > +
> > +  eassert (valid_image_p (spec));
> > +
> > +  for (tail = XCDR (spec);
> > +       CONSP (tail) && CONSP (XCDR (tail));
> > +       tail = XCDR (XCDR (tail)))
> > +    {
> > +      if (EQ (XCAR (tail), key))
> > +	{
> > +	  if (found)
> > +	    *found = 1;
> > +	  return XCAR (XCDR (tail));
> > +	}
> > +    }
> 
> Wouldn't it be clearer to call Fplist_get here?

Yes I think it would. I actually just copied the code from image.c, so
would it maybe be worth tidying up that code too?

Thanks!
-- 
Alan Third




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21714; Package emacs. (Sun, 13 Aug 2017 13:54:02 GMT) Full text and rfc822 format available.

Message #22 received at 21714 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Alan Third <alan <at> idiocy.org>
Cc: Keith David Bershatsky <esq <at> lawlist.com>, 21714 <at> debbugs.gnu.org
Subject: Re: bug#21714: [PATCH] Add multiframe image support to NS port
 (bug#21714)
Date: Sun, 13 Aug 2017 09:54:39 -0400
Alan Third <alan <at> idiocy.org> writes:

> On Sun, Aug 13, 2017 at 09:21:44AM -0400, npostavs <at> users.sourceforge.net wrote:
>> Alan Third <alan <at> idiocy.org> writes:
>>  
>> > +static Lisp_Object
>> > +image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found)
>> > +{
>> > +  Lisp_Object tail;
>> > +
>> > +  eassert (valid_image_p (spec));
>> > +
>> > +  for (tail = XCDR (spec);
>> > +       CONSP (tail) && CONSP (XCDR (tail));
>> > +       tail = XCDR (XCDR (tail)))
>> > +    {
>> > +      if (EQ (XCAR (tail), key))
>> > +	{
>> > +	  if (found)
>> > +	    *found = 1;
>> > +	  return XCAR (XCDR (tail));
>> > +	}
>> > +    }
>> 
>> Wouldn't it be clearer to call Fplist_get here?

Actually we would need Fplist_member to set the 'found' parameter
correctly in case the value is Qnil.  Hmm, that one can signal an error,
so potentially it's not the right thing.

> Yes I think it would. I actually just copied the code from image.c, so
> would it maybe be worth tidying up that code too?

Oh, maybe we should make it non-static and call it rather than copying
then?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21714; Package emacs. (Sun, 13 Aug 2017 14:57:02 GMT) Full text and rfc822 format available.

Message #25 received at 21714 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: npostavs <at> users.sourceforge.net
Cc: Keith David Bershatsky <esq <at> lawlist.com>, 21714 <at> debbugs.gnu.org
Subject: Re: bug#21714: [PATCH] Add multiframe image support to NS port
 (bug#21714)
Date: Sun, 13 Aug 2017 15:56:12 +0100
On Sun, Aug 13, 2017 at 09:54:39AM -0400, npostavs <at> users.sourceforge.net wrote:
> Alan Third <alan <at> idiocy.org> writes:
> 
> > On Sun, Aug 13, 2017 at 09:21:44AM -0400, npostavs <at> users.sourceforge.net wrote:
> >> Alan Third <alan <at> idiocy.org> writes:
> >>  
> >> > +static Lisp_Object
> >> > +image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found)
> >> > +{
> >> > +  Lisp_Object tail;
> >> > +
> >> > +  eassert (valid_image_p (spec));
> >> > +
> >> > +  for (tail = XCDR (spec);
> >> > +       CONSP (tail) && CONSP (XCDR (tail));
> >> > +       tail = XCDR (XCDR (tail)))
> >> > +    {
> >> > +      if (EQ (XCAR (tail), key))
> >> > +	{
> >> > +	  if (found)
> >> > +	    *found = 1;
> >> > +	  return XCAR (XCDR (tail));
> >> > +	}
> >> > +    }
> >> 
> >> Wouldn't it be clearer to call Fplist_get here?
> 
> Actually we would need Fplist_member to set the 'found' parameter
> correctly in case the value is Qnil.  Hmm, that one can signal an error,
> so potentially it's not the right thing.

In this particular case I’m not using the found parameter anyway so
Fplist_get will work fine.

-- 
Alan Third




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21714; Package emacs. (Mon, 14 Aug 2017 16:03:02 GMT) Full text and rfc822 format available.

Message #28 received at 21714 <at> debbugs.gnu.org (full text, mbox):

From: charles <at> aurox.ch (Charles A. Roelli)
To: Alan Third <alan <at> idiocy.org>
Cc: esq <at> lawlist.com, 21714 <at> debbugs.gnu.org
Subject: Re: bug#21714: [PATCH] Add multiframe image support to NS port
 (bug#21714)
Date: Mon, 14 Aug 2017 18:02:26 +0200
Thanks for adding this feature.  It's working on my end.




Reply sent to Alan Third <alan <at> idiocy.org>:
You have taken responsibility. (Wed, 16 Aug 2017 20:28:01 GMT) Full text and rfc822 format available.

Notification sent to Keith David Bershatsky <esq <at> lawlist.com>:
bug acknowledged by developer. (Wed, 16 Aug 2017 20:28:01 GMT) Full text and rfc822 format available.

Message #33 received at 21714-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: "Charles A. Roelli" <charles <at> aurox.ch>
Cc: esq <at> lawlist.com, 21714-done <at> debbugs.gnu.org
Subject: Re: bug#21714: [PATCH] Add multiframe image support to NS port
 (bug#21714)
Date: Wed, 16 Aug 2017 21:27:18 +0100
On Mon, Aug 14, 2017 at 06:02:26PM +0200, Charles A. Roelli wrote:
> Thanks for adding this feature.  It's working on my end.

Thanks. It’s pushed to master now.
-- 
Alan Third




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 14 Sep 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 280 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.