GNU bug report logs - #59242
29.0.50; Poor quality for WebP images

Previous Next

Package: emacs;

Reported by: Evgeny Zajcev <lg.zevlg <at> gmail.com>

Date: Sun, 13 Nov 2022 08:49:01 UTC

Severity: normal

Tags: patch

Found in version 29.0.50

Fixed in version 30.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

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 59242 in the body.
You can then email your comments to 59242 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#59242; Package emacs. (Sun, 13 Nov 2022 08:49:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Evgeny Zajcev <lg.zevlg <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 13 Nov 2022 08:49:02 GMT) Full text and rfc822 format available.

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

From: Evgeny Zajcev <lg.zevlg <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; Poor quality for WebP images
Date: Sun, 13 Nov 2022 11:48:01 +0300
[Message part 1 (text/plain, inline)]
WebP images with alpha channel renders in poor quality in the Emacs.
See http://lgarc.narod.ru/pics/emacs-webp-poor-quality.png

If I convert webp image to png, quality is ok in resulting image.  Also, if
I add webp as native image under MacOS (requires Emacs patch) then quality
is also ok.

Looks like partial transparency is incorrectly applied for webp images.

Thanks

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.20, cairo version 1.16.0) of 2022-10-25 built on x1
Repository revision: 9bfe00dda6b59d9b93eb7a825f6e0868afa1cca3
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12009000
System Description: Ubuntu 20.04.1 LTS

Configured using:
 'configure --with-modules'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND
SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM
GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: ru_RU.UTF-8
  value of $LC_NUMERIC: ru_RU.UTF-8
  value of $LC_TIME: ru_RU.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: ◁Chat

Minor modes in effect:
  tracking-mode: t
  telega-adblock-mode: t
  global-telega-mnz-mode: t
  telega-mnz-mode: t
  global-telega-url-shorten-mode: t
  telega-url-shorten-mode: t
  telega-stories-mode: t
  telega-root-auto-fill-mode: t
  telega-recognize-voice-message-mode: t
  telega-active-locations-mode: t
  telega-my-location-mode: t
  telega-patrons-mode: t
  global-telega-squash-message-mode: t
  telega-autoplay-mode: t
  telega-appindicator-mode: t
  telega-mode-line-mode: t
  telega-notifications-mode: t
  cursor-sensor-mode: t
  cursor-intangible-mode: t
  reverse-im-mode: t
  mlscroll-mode: t
  desktop-save-mode: t
  company-mode: t
  pyvenv-mode: t
  which-function-mode: t
  shell-dirtrack-mode: t
  global-paren-face-mode: t
  save-place-mode: t
  display-time-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  icomplete-mode: t
  disable-mouse-global-mode: t
  override-global-mode: t
  global-eldoc-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/lg/.emacs.d/elpa/magit-20210327.1617/magit-section hides
/home/lg/.emacs.d/elpa/magit-section-20210702.822/magit-section
~/dev/emacs-libvterm/vterm hides
/home/lg/.emacs.d/elpa/vterm-20210326.1458/vterm
/home/lg/.emacs.d/elpa/transient-20210315.1902/transient hides
/usr/local/share/emacs/29.0.50/lisp/transient

Features:
(shadow sort mail-extr shortdoc goto-last-change octave cc-awk lua-mode
slime arc-mode archive-mode hyperspec language-detection macrostep-c
cmacexp macrostep cc-mode cc-fonts cc-guess cc-menus cc-styles cc-align
kinsoku image-converter cl-print mule-util hl-line tracking shorten
vterm bookmark face-remap term disp-table ehelp vterm-module term/xterm
xterm telega-obsolete telega-adblock telega-mnz ol-telega
telega-url-shorten telega-stories telega-dashboard telega-live-location
geo-simulate geo telega telega-tdlib-events telega-webpage
visual-fill-column telega-match telega-root telega-info telega-chat
telega-modes image-mode exif telega-company telega-emoji telega-user
telega-notifications notifications telega-voip telega-msg telega-tme
telega-sticker telega-i18n telega-vvnote bindat telega-ffplay
telega-sort telega-filter telega-ins telega-folders telega-inline
telega-util telega-media telega-tdlib rainbow-identifiers org-element
avl-tree dired-aux telega-server telega-core cursor-sensor
telega-customize svg dom emacsbug skeleton dabbrev misearch
multi-isearch add-log vc-git company-keywords company-dabbrev-code
company-dabbrev company-files company-clang company-template
company-cmake reverse-im avy quail mlscroll dockerfile-mode sh-script
smie executable dashboard dashboard-widgets all-the-icons
all-the-icons-faces data-material data-weathericons data-octicons
data-fileicons data-faicons data-alltheicons recentf tree-widget home
lichess lichess-runtime lichess-api lichess-util sound-wav deferred
request autorevert filenotify cider cider-debug cider-browse-ns
cider-mode cider-inspector cider-completion cider-profile cider-eval
cider-repl-history pulse cider-repl cider-resolve cider-test
cider-overlays cider-stacktrace cider-doc cider-browse-spec
cider-clojuredocs cider-eldoc cider-client cider-common cider-connection
cider-util cider-popup sesman-browser nrepl-client queue nrepl-dict
cider-compat spinner sesman vc vc-dispatcher clojure-mode lisp-mnt align
parseedn parseclj-parser parseclj-lex a desktop frameset gnus-demon nntp
gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap
nnmail mail-source utf7 gnus-spec gnus-win nnoo gnus-int gnus-range
message sendmail yank-media rfc822 mml mml-sec epa derived epg rfc6068
epg-config mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader
gnus nnheader gnus-util mail-utils range autoinsert cython-mode
company-capf company-posframe posframe company pcase help-fns radix-tree
elpy elpy-rpc pyvenv eshell esh-cmd esh-ext esh-opt esh-proc esh-io
esh-arg esh-module esh-groups esh-util elpy-shell elpy-profile
elpy-django s elpy-refactor diff-mode python grep etags fileloop
generator xref python-mode info-look tramp-sh tramp tramp-loaddefs
trampver tramp-integration cus-edit cus-load wid-edit files-x
tramp-compat parse-time ls-lisp which-func imenu edebug shell hideshow
hippie-exp flymake-proc flymake project warnings thingatpt ert pp ewoc
debug backtrace compile text-property-search cc-cmds cc-engine cc-vars
cc-defs paren-face dot-mode gist-org saveplace gist dired dired-loaddefs
gh-gist gh-oauth gh-api logito gh-cache pcache gh-auth gh-common marshal
gh-url url-http url-auth mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr url-gw nsm puny gh-profile timezone eieio-base
server time google-translate google-translate-default-ui
google-translate-core-ui color popup google-translate-core
google-translate-tk google-translate-backend whitespace undo-tree diff
ido icomplete avoid disable-mouse page-break-lines ibuffer-vc ibuf-ext
ibuffer ibuffer-loaddefs org-bullets org ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete
pcomplete comint ansi-osc ansi-color ring org-list org-faces
org-entities noutline outline icons org-version ob-emacs-lisp ob-core
ob-eval org-table oc-basic bibtex iso8601 time-date ol org-keys oc
org-compat org-macs org-loaddefs format-spec find-func cal-menu calendar
cal-loaddefs edmacro kmacro advice browse-kill-ring delsel cl-extra
help-mode use-package use-package-ensure use-package-delight
use-package-diminish use-package-bind-key bind-key use-package-core
finder-inf all-the-icons-autoloads tex-site gist-autoloads gh-autoloads
rx poly-org-autoloads polymode-autoloads pyvenv-auto-autoloads
easy-mmode slime-autoloads w3m-load info package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x
map byte-opt gv bytecomp byte-compile cconv url-vars cl-loaddefs cl-lib
rmc iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
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 dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process
emacs)

Memory information:
((conses 16 6192449 1055030)
 (symbols 48 58618 3)
 (strings 32 883577 49058)
 (string-bytes 1 23200329)
 (vectors 16 308140)
 (vector-slots 8 3071505 351145)
 (floats 8 562338 2818)
 (intervals 56 305793 15205)
 (buffers 1000 131))

-- 
lg
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59242; Package emacs. (Sun, 13 Nov 2022 09:45:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Evgeny Zajcev <lg.zevlg <at> gmail.com>
Cc: 59242 <at> debbugs.gnu.org, Stefan Kangas <stefankangas <at> gmail.com>
Subject: Re: bug#59242: 29.0.50; Poor quality for WebP images
Date: Sun, 13 Nov 2022 17:44:22 +0800
Evgeny Zajcev <lg.zevlg <at> gmail.com> writes:

> WebP images with alpha channel renders in poor quality in the Emacs.
> See http://lgarc.narod.ru/pics/emacs-webp-poor-quality.png
>
> If I convert webp image to png, quality is ok in resulting image.
> Also, if I add webp as native image under MacOS (requires Emacs patch)
> then quality is also ok.
>
> Looks like partial transparency is incorrectly applied for webp images.

Stefan, I see the following code in image.c:

	  /* An alpha channel associates variable transparency with an
	     image.  WebP allows up to 256 levels of partial transparency.
	     We handle this like with PNG (which see), using the frame's
	     background color to combine the image with.  */
	  if (features.has_alpha || anim)
	    {
	      if (mask_img)
		PUT_PIXEL (mask_img, x, y, *p > 0 ? PIX_MASK_DRAW : PIX_MASK_RETAIN);

however, you seem to have misunderstood the meaning of the PNG code: PNG
images can either have a real alpha channel (where the PNG library does
the blending AFAIK) or a simple on-off transparency switch, which is the
only case where this kind of masking is appropriate.

As a questionable optimization, Emacs also uses masking when only alpha
channels of 0 or 255 are present in a PNG image that has a real alpha
channel.

So if the webp library does not blend itself, I think we will have to do
that for it.  Am I missing anything here?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59242; Package emacs. (Mon, 14 Aug 2023 00:13:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 59242 <at> debbugs.gnu.org, Evgeny Zajcev <lg.zevlg <at> gmail.com>
Subject: Re: bug#59242: 29.0.50; Poor quality for WebP images
Date: Mon, 14 Aug 2023 02:11:56 +0200
[Message part 1 (text/plain, inline)]
tags 59242 + patch
thanks

Po Lu <luangruo <at> yahoo.com> writes:

> > Evgeny Zajcev <lg.zevlg <at> gmail.com> writes:
>
> > Looks like partial transparency is incorrectly applied for webp images.

Thanks for the bug report.

> Stefan, I see the following code in image.c:
[...]
> So if the webp library does not blend itself, I think we will have to do
> that for it.  Am I missing anything here?

Yes, the old code was not right.  The attached patch should add proper
alpha blending for webp images.  I have tested it with the example
images here: https://developers.google.com/speed/webp/gallery2

Evgeny, could you please test this patch and report back?  It should
apply cleanly both against master and emacs-29.
[0001-Fix-alpha-blending-for-webp-images.patch (application/x-patch, attachment)]

Added tag(s) patch. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 14 Aug 2023 00:13:02 GMT) Full text and rfc822 format available.

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

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: luangruo <at> yahoo.com, 59242 <at> debbugs.gnu.org, lg.zevlg <at> gmail.com
Subject: Re: bug#59242: 29.0.50; Poor quality for WebP images
Date: Mon, 14 Aug 2023 05:33:09 +0300
> Cc: 59242 <at> debbugs.gnu.org, Evgeny Zajcev <lg.zevlg <at> gmail.com>
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Mon, 14 Aug 2023 02:11:56 +0200
> 
> Po Lu <luangruo <at> yahoo.com> writes:
> 
> > > Evgeny Zajcev <lg.zevlg <at> gmail.com> writes:
> >
> > > Looks like partial transparency is incorrectly applied for webp images.
> 
> Thanks for the bug report.
> 
> > Stefan, I see the following code in image.c:
> [...]
> > So if the webp library does not blend itself, I think we will have to do
> > that for it.  Am I missing anything here?
> 
> Yes, the old code was not right.  The attached patch should add proper
> alpha blending for webp images.  I have tested it with the example
> images here: https://developers.google.com/speed/webp/gallery2
> 
> Evgeny, could you please test this patch and report back?  It should
> apply cleanly both against master and emacs-29.

Thanks, but please install this on master, not on the emacs-29 branch,
even if this patch does work.  It's too late for such changes on the
release branch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59242; Package emacs. (Mon, 14 Aug 2023 07:09:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: luangruo <at> yahoo.com, 59242 <at> debbugs.gnu.org, lg.zevlg <at> gmail.com
Subject: Re: bug#59242: 29.0.50; Poor quality for WebP images
Date: Mon, 14 Aug 2023 09:08:16 +0200
 Eli Zaretskii <eliz <at> gnu.org> writes:

> Thanks, but please install this on master, not on the emacs-29 branch,
> even if this patch does work.  It's too late for such changes on the
> release branch.

Noted.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59242; Package emacs. (Fri, 25 Aug 2023 18:29:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 59242 <at> debbugs.gnu.org, Evgeny Zajcev <lg.zevlg <at> gmail.com>
Subject: Re: bug#59242: 29.0.50; Poor quality for WebP images
Date: Fri, 25 Aug 2023 20:28:08 +0200
close 59242 30.1
thanks

> Yes, the old code was not right.  The attached patch should add proper
> alpha blending for webp images.  I have tested it with the example
> images here: https://developers.google.com/speed/webp/gallery2

No further comments within 10 days, so I've pushed this to master as
commit eb61bbacef7 and I'm closing the bug.




bug marked as fixed in version 30.1, send any further explanations to 59242 <at> debbugs.gnu.org and Evgeny Zajcev <lg.zevlg <at> gmail.com> Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 25 Aug 2023 18:29:02 GMT) Full text and rfc822 format available.

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

This bug report was last modified 214 days ago.

Previous Next


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