all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#59242: 29.0.50; Poor quality for WebP images
@ 2022-11-13  8:48 Evgeny Zajcev
  2022-11-13  9:44 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 6+ messages in thread
From: Evgeny Zajcev @ 2022-11-13  8:48 UTC (permalink / raw)
  To: 59242

[-- Attachment #1: Type: text/plain, Size: 8995 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 9722 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59242: 29.0.50; Poor quality for WebP images
  2022-11-13  8:48 bug#59242: 29.0.50; Poor quality for WebP images Evgeny Zajcev
@ 2022-11-13  9:44 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-08-14  0:11   ` Stefan Kangas
  0 siblings, 1 reply; 6+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-13  9:44 UTC (permalink / raw)
  To: Evgeny Zajcev; +Cc: 59242, Stefan Kangas

Evgeny Zajcev <lg.zevlg@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?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59242: 29.0.50; Poor quality for WebP images
  2022-11-13  9:44 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-08-14  0:11   ` Stefan Kangas
  2023-08-14  2:33     ` Eli Zaretskii
  2023-08-25 18:28     ` Stefan Kangas
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Kangas @ 2023-08-14  0:11 UTC (permalink / raw)
  To: Po Lu; +Cc: 59242, Evgeny Zajcev

[-- Attachment #1: Type: text/plain, Size: 709 bytes --]

tags 59242 + patch
thanks

Po Lu <luangruo@yahoo.com> writes:

> > Evgeny Zajcev <lg.zevlg@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.

[-- Attachment #2: 0001-Fix-alpha-blending-for-webp-images.patch --]
[-- Type: application/x-patch, Size: 3808 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59242: 29.0.50; Poor quality for WebP images
  2023-08-14  0:11   ` Stefan Kangas
@ 2023-08-14  2:33     ` Eli Zaretskii
  2023-08-14  7:08       ` Stefan Kangas
  2023-08-25 18:28     ` Stefan Kangas
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-08-14  2:33 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: luangruo, 59242, lg.zevlg

> Cc: 59242@debbugs.gnu.org, Evgeny Zajcev <lg.zevlg@gmail.com>
> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Mon, 14 Aug 2023 02:11:56 +0200
> 
> Po Lu <luangruo@yahoo.com> writes:
> 
> > > Evgeny Zajcev <lg.zevlg@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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59242: 29.0.50; Poor quality for WebP images
  2023-08-14  2:33     ` Eli Zaretskii
@ 2023-08-14  7:08       ` Stefan Kangas
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Kangas @ 2023-08-14  7:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, 59242, lg.zevlg

 Eli Zaretskii <eliz@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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#59242: 29.0.50; Poor quality for WebP images
  2023-08-14  0:11   ` Stefan Kangas
  2023-08-14  2:33     ` Eli Zaretskii
@ 2023-08-25 18:28     ` Stefan Kangas
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Kangas @ 2023-08-25 18:28 UTC (permalink / raw)
  To: Po Lu; +Cc: 59242, Evgeny Zajcev

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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-25 18:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-13  8:48 bug#59242: 29.0.50; Poor quality for WebP images Evgeny Zajcev
2022-11-13  9:44 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-14  0:11   ` Stefan Kangas
2023-08-14  2:33     ` Eli Zaretskii
2023-08-14  7:08       ` Stefan Kangas
2023-08-25 18:28     ` Stefan Kangas

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.