GNU bug report logs - #73177
29.4; Unable to retrieve Exif data from some JPEG files

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: AKIYAMA Kouhei <misohena@HIDDEN>; dated Wed, 11 Sep 2024 12:33:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 11 Sep 2024 12:32:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 11 08:32:37 2024
Received: from localhost ([127.0.0.1]:37922 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1soMWS-0007h0-BR
	for submit <at> debbugs.gnu.org; Wed, 11 Sep 2024 08:32:37 -0400
Received: from lists.gnu.org ([209.51.188.17]:48768)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <misohena@HIDDEN>) id 1soLEd-0003RM-8J
 for submit <at> debbugs.gnu.org; Wed, 11 Sep 2024 07:10:08 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <misohena@HIDDEN>)
 id 1soLEW-0004c6-ML
 for bug-gnu-emacs@HIDDEN; Wed, 11 Sep 2024 07:10:00 -0400
Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <misohena@HIDDEN>)
 id 1soLEU-0007GA-Bu
 for bug-gnu-emacs@HIDDEN; Wed, 11 Sep 2024 07:10:00 -0400
Received: by mail-pl1-x62d.google.com with SMTP id
 d9443c01a7336-2059112f0a7so60725625ad.3
 for <bug-gnu-emacs@HIDDEN>; Wed, 11 Sep 2024 04:09:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1726052996; x=1726657796; darn=gnu.org;
 h=mime-version:message-id:date:subject:to:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=Q1xLvc5VZpj+Nvl0tGAMlDrtbT8cMHQsxaHxRf/3tSQ=;
 b=njATeO2lDkgvsVYXgEtPMkcovfPX812o1x2UfVpSx0MqOeMDdpO5mRt0gUzoD+q/7J
 83KyQwr6cAwXisg101jC9gy7l3XSIuogJSSciW4Bm/qYX777Gn2issQlPvnP+Tt5pHYK
 vu3HGiJ2chFAxuSAdoKHkLgo21hhriLeT27QxHXL8HMsNVbB9ozq7XRBx0NyvrB1RizJ
 7BTn8vF+da+xmtfyLnBjtM04IOmsukzWS+Pi+UlGh5FTX+4pA5dFqUCWiYmU93sLH1wF
 40ZriMcoBeJdDjqe1I2j11l3kYhJtRm3Z/FhSTKYETdTr776maE7OHqb0bZFRIZk7wtf
 5giw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1726052996; x=1726657796;
 h=mime-version:message-id:date:subject:to:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=Q1xLvc5VZpj+Nvl0tGAMlDrtbT8cMHQsxaHxRf/3tSQ=;
 b=amIV2sn3HCr0fLmRY3e7QPZlXH/ui7tVkuUMm/biEjhge2aHImLTroVESiaMzU/66e
 b5X1YSxMyyj1V69cpFd9fL9lEBumOeBa8rE5dfgt7AuhPjZ+OJbib8VnPPG734/Y2xrH
 uduUe/u5ZAOizLEBn8JBjQUqLzSKKAWuS2k1dPVvQr4TI8Q7IY+mG6kriyMp2+0FlQRT
 PwBL+CUtVJYAtkLBAifQpljifSJpaCDIrshLsRjD6ZlSQGuWK/i/nhBmc08rfHMRI9AR
 yFSQzLxmuEgwjk0gAtlib5N0ArBchUZLzE+3t2r5leSwGJK51DRPIu/48yrddsnq/mIY
 w/nQ==
X-Gm-Message-State: AOJu0Yx6KuOq6Lp4XMfhzDLu1zKxQJQqJ+aNp5PDDwh2tcDU+MZkI4rw
 jUAG98os2/JTdKl5lY86jLCMXzDpcdS/Nj6/+cFViczZfLe3KzFRqwjiEg==
X-Google-Smtp-Source: AGHT+IGc/MfiSQfVrlo/mIKe/6zMCxy/e80SCqbeWB0ZmLbKYo7hsKGfWplR5GKvFCO5Ke3bOLTuFg==
X-Received: by 2002:a17:902:f681:b0:206:a935:2f8 with SMTP id
 d9443c01a7336-2074c4afdfemr54290225ad.2.1726052995441; 
 Wed, 11 Sep 2024 04:09:55 -0700 (PDT)
Received: from YAMABUKI (pl934.ag1212.nttpc.ne.jp. [61.197.25.166])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-20710eeab5bsm61360925ad.180.2024.09.11.04.09.54
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 11 Sep 2024 04:09:54 -0700 (PDT)
From: AKIYAMA Kouhei <misohena@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.4; Unable to retrieve Exif data from some JPEG files
Date: Wed, 11 Sep 2024 20:09:40 +0900
Message-ID: <86plpaphu3.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2607:f8b0:4864:20::62d;
 envelope-from=misohena@HIDDEN; helo=mail-pl1-x62d.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 11 Sep 2024 08:32:35 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

exif.el does not correctly read the Exif data from some JPEG files,
which means that for example image rotation does not work properly in
image-mode.

* Issue 1: Unable to retrieve values such as orientation from Exif data
           written in Big-endian format.

Reproduction steps 1:
(The following command line creates test images using exiftool)

wget https://www.gnu.org/graphics/gnu-head.jpg
exiftool -Orientation#=6 -ExifByteOrder=Little-endian gnu-head.jpg -o gnu-head-le.jpg
exiftool -Orientation#=6 -ExifByteOrder=Big-endian gnu-head.jpg -o gnu-head-be.jpg
emacs --batch --eval "(progn (require 'exif) (princ (exif-orientation (exif-parse-file \"gnu-head-le.jpg\"))))" # => 90
emacs --batch --eval "(progn (require 'exif) (princ (exif-orientation (exif-parse-file \"gnu-head-be.jpg\"))))" # => nil (expected: 90)

Alternatively, the following expressions can be evaluated within Emacs:

  (exif-orientation (exif-parse-file "gnu-head-le.jpg")) ;; => 90
  (exif-orientation (exif-parse-file "gnu-head-be.jpg")) ;; => nil (expected: 90)

If you view gnu-head-be.jpg in image-mode, the image will not be
rotated. If you view it in an image viewer app or web browser,
it will be rotated correctly.

Related source code location 1: (In exif.el)

  (defun exif--parse-directory (le)
  ...
    for value = (exif--read-number 4 le)

For small field types, 4 bytes is too large.

(This is unrelated to the current issue, but if this part could read
triplet rational numbers such as latitude and longitude information,
the range of applications would be expanded. Currently, it can read
rational numbers, but it cannot read multiple values.)


* Issue 2: An error may occur depending on the order when non-Exif APP1
           segments exist in the file.
Reproduction steps 2-1: (When there is no Exif data and only XMP is embedded)

exiftool -xmp:creator="Etienne Suvasa" gnu-head.jpg -o gnu-head-xmp.jpg
emacs --batch --eval "(progn (require 'exif) (princ (exif-orientation (exif-parse-file \"gnu-head-xmp.jpg\"))))" # => Invalid Exif data (expected: 0)

Reproduction steps 2-2: (When XMP appears before Exif)

wget https://misohena.jp/work/emacs-exif-test/20220629_072635771_cw.jpg
emacs --batch --eval "(progn (require 'exif) (princ (exif-orientation (exif-parse-file \"20220629_072635771_cw.jpg\"))))" # => Invalid Exif data (expected: 90)

I'm not sure if JPEG files with XMP preceding Exif data conform to the
standard, but such files do exist in practice.

Currently, I have not found a way to generate such a JPEG file in my
environment. It may be a problem with the image conversion software I
used in the past.

Related source code location 2: (In exif.el)

  (defun exif-parse-buffer (&optional buffer)
  ...
    (when-let ((app1 (cdr (assq #xffe1 (exif--parse-jpeg)))))
      (exif--parse-exif-chunk app1))

Only the first APP1 segment found will be used, any subsequent APP1
segments (including Exif) will be ignored.


------
In GNU Emacs 29.4 (build 2, x86_64-w64-mingw32) of 2024-07-05 built on
 AVALON
Windowing system distributor 'Microsoft Corp.', version 10.0.19045
System Description: Microsoft Windows 10 Enterprise (v10.0.2009.19045.4780)

Configured using:
 'configure --with-modules --without-dbus --with-native-compilation=aot
 --without-compress-install --with-sqlite3 --with-tree-sitter
 CFLAGS=-O2'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB

Important settings:
  value of $LANG: ja_JP.CP932
  locale-coding-system: cp932

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
comp comp-cstr warnings icons subr-x rx cl-seq cl-macs gv cl-extra
help-mode cl-loaddefs cl-lib bytecomp byte-compile rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils japan-util rmc iso-transl
tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel dos-w32 ls-lisp disp-table
term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine 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
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 85672 6348)
 (symbols 48 8061 0)
 (strings 32 22174 4610)
 (string-bytes 1 623953)
 (vectors 16 17387)
 (vector-slots 8 439453 10338)
 (floats 8 29 33)
 (intervals 56 1089 769)
 (buffers 984 12))

--
# This report was created using machine translation.
AKIYAMA Kouhei
misohena@HIDDEN




Acknowledgement sent to AKIYAMA Kouhei <misohena@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#73177; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 12 Jan 2025 05:45:02 UTC

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