This function gives the native pixel dimensions of an image:
(defun es-image-file-pixel-dimensions (file)
(let* ((type (image-type file nil nil))
(spec (list 'image :type type :file file)))
(image-size spec t)))
When
(> (getf (cdr (doc-view-current-image)) :width)
(car (es-image-file-pixel-dimensions
(getf (cdr (doc-view-current-image)) :file))))
there is quality loss.
What I don't want to see is margins having a different width - for the same reasons you wouldn't put a photograph in a frame in the top left corner. Ideally I'd also center vertically (should the image be shorter than the window) and add a window-configuration-change-hook (or there might be an appropriate display-spec), so it's always centered. Unfortunately no image-viewer that currently comes with emacs (image-mode ,doc-view-mode ,image-dired-display-image-mode) does this.
Evgeni