unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: joakim@verona.se
To: Juri Linkov <juri@jurta.org>
Cc: Stefan Monnier <monnier@IRO.UMontreal.CA>,
	Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: Image metadata
Date: Fri, 02 Apr 2010 23:51:59 +0200	[thread overview]
Message-ID: <m38w95wmio.fsf@verona.se> (raw)
In-Reply-To: <87tyrx77v3.fsf@mail.jurta.org> (Juri Linkov's message of "Wed, 31 Mar 2010 01:38:36 +0300")

Juri Linkov <juri@jurta.org> writes:

>>> The problem is that one part of the current `image-extension-data'
>>> is metadata, and another part is extension data.  For instance, in
>>
>>>   (count 44
>>>    255 "NETSCAPE2.0"
>>>      0 "^A^@^@"
>>>    249 "^D^M^@\377"
>>>   )
>>
>>> `count 44' is metadata, and the rest (with non-descriptive numeric keys)
>>> is extension data.
>>
>> Not knowing what is "extension data", I don't know if I agree.
>
>>From the API's point of view, "extension data" is just raw data fetched
> from the `ExtensionBlocks' slot of the GIF metadata.  So really it's not
> important what it is as long as slot names basically coincide in the GIF
> structure and in its Lisp image metadata.
>
> I believe this patch cleans up the naming mess:

This does indeed seem clearer. Will this be commited?

If so I would try to use this api in the imagemagick patch.
For instance, it seems I can use MagickGetNumberImages() to 
get the 'count property for multifile image archives.
>
> === modified file 'lisp/image.el'
> --- lisp/image.el	2010-03-11 20:01:33 +0000
> +++ lisp/image.el	2010-03-30 22:28:18 +0000
> @@ -681,8 +681,9 @@ (defun image-animated-p (image)
>  shall be displayed."
>    (cond
>     ((eq (plist-get (cdr image) :type) 'gif)
> -    (let* ((extdata (image-extension-data image))
> -	   (images (plist-get extdata 'count))
> +    (let* ((metadata (image-metadata image))
> +	   (images (plist-get metadata 'count))
> +	   (extdata (plist-get metadata 'extension-data))
>  	   (anim (plist-get extdata #xF9)))
>        (and (integerp images) (> images 1)
>  	   (stringp anim) (>= (length anim) 4)
>
> === modified file 'src/image.c'
> --- src/image.c	2010-01-24 23:03:13 +0000
> +++ src/image.c	2010-03-30 22:31:57 +0000
> @@ -604,7 +604,7 @@ (at your option) any later version.
>  extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile;
>  extern Lisp_Object QCdata, QCtype;
>  extern Lisp_Object Qcenter;
> -Lisp_Object QCascent, QCmargin, QCrelief, Qcount;
> +Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data;
>  Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask;
>  Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask;
>  
> @@ -1011,8 +1011,8 @@ (at your option) any later version.
>    return mask;
>  }
>  
> -DEFUN ("image-extension-data", Fimage_extension_data, Simage_extension_data, 1, 2, 0,
> -       doc: /* Return extension data for image SPEC.
> +DEFUN ("image-metadata", Fimage_metadata, Simage_metadata, 1, 2, 0,
> +       doc: /* Return metadata for image SPEC.
>  FRAME is the frame on which the image will be displayed.  FRAME nil
>  or omitted means use the selected frame.  */)
>       (spec, frame)
> @@ -7169,7 +7169,7 @@ (at your option) any later version.
>       struct frame *f;
>       struct image *img;
>  {
> -  /* IMG->data.ptr_val may contain extension data.  */
> +  /* IMG->data.ptr_val may contain metadata with extension data.  */
>    img->data.lisp_val = Qnil;
>    x_clear_image (f, img);
>  }
> @@ -7488,8 +7488,8 @@ (at your option) any later version.
>  	  }
>      }
>  
> -  /* Save GIF image extension data for `image-extension-data'.
> -     Format is (count IMAGES FUNCTION "BYTES" ...).  */
> +  /* Save GIF image extension data for `image-metadata'.
> +     Format is (count IMAGES extension-data (FUNCTION "BYTES" ...)).  */
>    img->data.lisp_val = Qnil;
>    if (gif->SavedImages[ino].ExtensionBlockCount > 0)
>      {
> @@ -7499,7 +7499,9 @@ (at your option) any later version.
>  	img->data.lisp_val = Fcons (make_unibyte_string (ext->Bytes, ext->ByteCount),
>  				    Fcons (make_number (ext->Function),
>  					   img->data.lisp_val));
> -      img->data.lisp_val = Fnreverse (img->data.lisp_val);
> +      img->data.lisp_val = Fcons (Qextension_data,
> +				  Fcons (Fnreverse (img->data.lisp_val),
> +					 Qnil));
>      }
>    if (gif->ImageCount > 1)
>      img->data.lisp_val = Fcons (Qcount,
> @@ -8403,6 +8405,8 @@ (at your option) any later version.
>  
>    Qcount = intern_c_string ("count");
>    staticpro (&Qcount);
> +  Qextension_data = intern_c_string ("extension-data");
> +  staticpro (&Qextension_data);
>  
>    QCascent = intern_c_string (":ascent");
>    staticpro (&QCascent);
> @@ -8498,7 +8502,7 @@ (at your option) any later version.
>    defsubr (&Simage_refresh);
>    defsubr (&Simage_size);
>    defsubr (&Simage_mask_p);
> -  defsubr (&Simage_extension_data);
> +  defsubr (&Simage_metadata);
>  
>  #if GLYPH_DEBUG
>    defsubr (&Simagep);
-- 
Joakim Verona




  parent reply	other threads:[~2010-04-02 21:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-03  7:39 imagemmagick patch 5 joakim
2010-03-03 19:34 ` Juri Linkov
2010-03-03 20:03   ` joakim
2010-03-06 17:59     ` Juri Linkov
2010-03-06 20:16       ` Stefan Monnier
2010-03-06 21:05         ` Juri Linkov
2010-03-07 14:37           ` Stefan Monnier
2010-03-07 19:08             ` Juri Linkov
2010-03-07 21:23               ` Stefan Monnier
2010-03-13 17:44                 ` Kim F. Storm
2010-03-30 16:12                 ` Image metadata (was: imagemmagick patch 5) Juri Linkov
2010-03-30 20:36                   ` Image metadata Stefan Monnier
2010-03-30 22:38                     ` Juri Linkov
2010-03-31  1:22                       ` Stefan Monnier
2010-04-02 21:51                       ` joakim [this message]
2010-04-02 22:38                         ` Juri Linkov
2010-03-04  2:41 ` imagemmagick patch 5 Stefan Monnier
2010-03-05 22:06   ` joakim
2010-03-05 22:30     ` Stefan Monnier
2010-03-05 23:56       ` Jan Djärv
2010-03-06  6:02       ` Stephen J. Turnbull
2010-04-15  9:34     ` joakim
2010-04-15 10:55       ` joakim
2010-04-16 20:45         ` Juri Linkov
2010-04-17  6:09           ` joakim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m38w95wmio.fsf@verona.se \
    --to=joakim@verona.se \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.org \
    --cc=monnier@IRO.UMontreal.CA \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).