Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs under Windows and PNG files

Tags:

emacs

windows

Would anyone have any pointers on getting PNG images to display in Emacs 23 under Win32?.. I have installed the gnuwin32 set of utilities, including libpng and zlib; C:\Program Files\GnuWin32\bin is in path. JPG files started working but not PNGs. I'd appreciate any hints on getting this to work.

EDIT: PNG thumbnails actually display fine (e.g. in dired via C-t C-t). However, opening them fails (opens as garbage in fundamental mode, and M-x image-mode says "invalid image specification").

like image 417
Leo Alekseyev Avatar asked Apr 16 '10 01:04

Leo Alekseyev


4 Answers

You have to copy one of these dlls "libpng12d.dll" "libpng12.dll" "libpng.dll" "libpng13d.dll" "libpng13.dll" to your emacs-23.1/bin/ directory. They require zlib1.dll which you have to copy as well. I did the same thing for jpeg62.dll and giflib4.dll and now my emacs supports jpg, gif and png files. For some reason it does not work if I simply put these dlls in the path.

You can check (image-type-available-p 'png) to see if png is supported. image-library-alist maps image type to a list of dlls which support it.

like image 78
Oleg Pavliv Avatar answered Nov 03 '22 16:11

Oleg Pavliv


According to the official manual:

3.3 How do I get image support?

Emacs has built in support for XBM and PBM/PGM/PPM images. This is sufficient to see the monochrome splash screen and tool-bar icons. Since 22.2, the official precompiled binaries for Windows have bundled libXpm, which is required to display the color versions of those images.

Emacs is compiled to recognize JPEG, PNG, GIF and TIFF images also, but displaying these image types require external DLLs which are not bundled with Emacs. See Other useful ports.

Those dlls for the various image formats are (as far as I know) - XPM (xpm4.dll), PNG (libpng13.dll, zlib1.dll), JPEG (jpeg62.dll), TIFF (libtiff3.dll) and GIF (giflib4.dll);

like image 6
Bozhidar Batsov Avatar answered Nov 03 '22 17:11

Bozhidar Batsov


Starting with Emacs 25 the Emacs Windows download directory includes -deps zip packages, that can be extracted to your emacs installation folder and include image libraries for PNG, SVG, JPEG, GIF, TIFF and more.

See also this emacs.stackexchange answer.

like image 5
FlyingFoX Avatar answered Nov 03 '22 17:11

FlyingFoX


To display which version of the PNG dll your Emacs for Windows version requires, you can evaluate (cdr (assq 'png dynamic-library-alist))

like image 1
David Avatar answered Nov 03 '22 17:11

David