Do you see the same problem when you start Emacs using emacs -Q? I doubt it. If so, and if your Emacs version is recent, report the problem: M-x report-emacs-bug.
If not, then recursively bisect your init file to determine the culprit. You can use command comment-region to comment out a region of text (and with C-u it uncomments a region).
(With emacs -Q, ...
Two methods would be useful to you image-transform-fit-to-width and image-transform-set-scale, you can use these two functions inside a image-mode-hook to setup the display like you want based on the file. You can get the file extension by using file-name-extension on buffer-file-name.
Here is an implementation:
(defun my-image-mode-setup ()
(when (and (...
It does not do what you expect (and request) because the Emacs maintainers rejected that possibility. I even provided a patch to realize it, as soon as text-scaling was made available.
See this message in bug thread #8379.
Fortunately, you can get what you want by using library face-remap+.el. It gives you user option text-scale-resize-window:
Quoting from C-hig (elisp)Frame Font
Each frame has a “default font” which specifies the default character
size for that frame. This size is meant when retrieving or changing the
size of a frame in terms of columns or lines (see Size Parameters).
It is also used when resizing (see Window Sizes) or splitting (see
Splitting Windows) windows.
Variable text-scale-mode-amount holds the number of text-scale-mode steps. (Variable text-scale-mode-step holds the amount to scale for each step.)
Save text-scale-mode-amount, then later pass it to text-scale-increase.
I believe this is related to a recent OS change (from Ubuntu to Arch), which included an Emacs upgrade from 24.3 to 24.4. I think my .emacs.desktop files were not compatible with this update, and this zoom bug was one effect. My desktop files are used to save my open buffers for each emacs session.
Thanks to @Drew's answer, I found the cause of this issue ...