From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.bugs Subject: bug#13887: 24.3; doc-view will render blurry images when image-magick is available Date: Wed, 06 Mar 2013 20:43:16 +0100 Message-ID: <877glkgvqj.fsf@thinkpad.tsdh.de> References: <8762153qc8.fsf@thinkpad.tsdh.de> <8762143co6.fsf@thinkpad.tsdh.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1362599039 19199 80.91.229.3 (6 Mar 2013 19:43:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Mar 2013 19:43:59 +0000 (UTC) Cc: 13887@debbugs.gnu.org To: E Sabof Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Mar 06 20:44:19 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UDKG5-0005ef-2v for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Mar 2013 20:44:13 +0100 Original-Received: from localhost ([::1]:44619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDKFj-0004Jf-Ae for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Mar 2013 14:43:51 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDKFc-0004HK-0b for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 14:43:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDKFT-0001J3-Sd for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 14:43:43 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDKFT-0001Im-Hn for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 14:43:35 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UDKFu-0007BW-Hk for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 14:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tassilo Horn Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Mar 2013 19:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13887 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13887-submit@debbugs.gnu.org id=B13887.136259903327593 (code B ref 13887); Wed, 06 Mar 2013 19:44:02 +0000 Original-Received: (at 13887) by debbugs.gnu.org; 6 Mar 2013 19:43:53 +0000 Original-Received: from localhost ([127.0.0.1]:34769 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UDKFj-0007Aw-JU for submit@debbugs.gnu.org; Wed, 06 Mar 2013 14:43:53 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:55978) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UDKFe-0007Al-Ht for 13887@debbugs.gnu.org; Wed, 06 Mar 2013 14:43:50 -0500 Original-Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id B2B6B20798; Wed, 6 Mar 2013 14:43:18 -0500 (EST) Original-Received: from frontend1.nyi.mail.srv.osa ([10.202.2.160]) by compute3.internal (MEProxy); Wed, 06 Mar 2013 14:43:18 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:cc:subject:references:date :in-reply-to:message-id:mime-version:content-type; s=smtpout; bh=3Vxz9nBE/fFgRwGZ5SL8PzX5NsY=; b=Ga9VT0Vt3/Cm5/CnROS3ycUjAgZ4 Fa3cukD1f85c5DrpUoWalR7BzItrGvov0cMJPBKDs/YS5LAtD7g04pqHxB/3J6QW 7Y6oPP3YL+iaGAPzA4Usyca3X8/NfG+IfpQ/O/lwkQ5O3VkxbuPiGujb1VHq+J7u zuPUwOVjUbyDWn0= X-Sasl-enc: hLXM2gXY5mQQ//f/mqJ4NOQ6zceIVbkYcdVKfWuQPP4Q 1362598998 Original-Received: from thinkpad.tsdh.de (unknown [91.67.10.84]) by mail.messagingengine.com (Postfix) with ESMTPA id 1B583C80E8D; Wed, 6 Mar 2013 14:43:18 -0500 (EST) In-Reply-To: (E. Sabof's message of "Wed, 6 Mar 2013 14:19:19 +0000") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:72177 Archived-At: E Sabof writes: > 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. Hm, ok. Maybe I'll give it a whirl. > 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. Could you test-drive this patch. It implements horizontal centering of the image. --8<---------------cut here---------------start------------->8--- === modified file 'lisp/doc-view.el' --- lisp/doc-view.el 2013-02-28 04:02:36 +0000 +++ lisp/doc-view.el 2013-03-06 19:35:43 +0000 @@ -1250,23 +1250,34 @@ (when doc-view-pending-cache-flush (clear-image-cache) (setq doc-view-pending-cache-flush nil)) - (let ((ol (doc-view-current-overlay)) - (image (if (and file (file-readable-p file)) - (if (not (and doc-view-scale-internally - (fboundp 'imagemagick-types))) - (apply 'create-image file doc-view--image-type nil args) - (unless (member :width args) - (setq args `(,@args :width ,doc-view-image-width))) - (apply 'create-image file 'imagemagick nil args)))) - (slice (doc-view-current-slice))) + (let* ((ol (doc-view-current-overlay)) + (image (if (and file (file-readable-p file)) + (if (not (and doc-view-scale-internally + (fboundp 'imagemagick-types))) + (apply 'create-image file doc-view--image-type nil args) + (unless (member :width args) + (setq args `(,@args :width ,doc-view-image-width))) + (apply 'create-image file 'imagemagick nil args)))) + (slice (doc-view-current-slice)) + (img-width (car (image-size image))) + (displayed-img-width (if slice + (* (/ (float (nth 2 slice)) + (car (image-size image 'pixels))) + img-width) + img-width)) + (window-width (window-width (selected-window)))) (setf (doc-view-current-image) image) (move-overlay ol (point-min) (point-max)) + (when (> window-width displayed-img-width) + (overlay-put ol 'before-string + (propertize " " 'display + `(space :align-to (+ center (-0.5 . ,displayed-img-width)))))) (overlay-put ol 'display (cond (image (if slice (list (cons 'slice slice) image) - image)) + image)) ;; We're trying to display a page that doesn't exist. (doc-view-current-converter-processes ;; Maybe the page doesn't exist *yet*. --8<---------------cut here---------------end--------------->8--- > Ideally I'd also center vertically (should the image be shorter than > the window) I think vertical centering is a bit more tricky since there's nothing like :align-to or vertically stretchable spaces... Bye, Tassilo