From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: Re: Image View mode and image dimensions Q Date: Sat, 11 Oct 2008 04:01:59 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1223725281 9248 80.91.229.12 (11 Oct 2008 11:41:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 11 Oct 2008 11:41:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 11 13:42:17 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KocrJ-0004n9-SB for geh-help-gnu-emacs@m.gmane.org; Sat, 11 Oct 2008 13:42:10 +0200 Original-Received: from localhost ([127.0.0.1]:35732 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KocqF-0007ay-Gf for geh-help-gnu-emacs@m.gmane.org; Sat, 11 Oct 2008 07:41:03 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!news-out.readnews.com!transit3.readnews.com!postnews.google.com!z18g2000prn.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 66 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1223722919 9794 127.0.0.1 (11 Oct 2008 11:01:59 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 11 Oct 2008 11:01:59 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z18g2000prn.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:163347 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:58690 Archived-At: On Oct 10, 3:14=C2=A0pm, "srdjan.markov...@gmail.com" wrote: > Hi there! > > I am looking for solution to display image dimensions in Image View > mode. > I really like the possibility to display image in dired mode. The only > thing I am not able to find is to retrieve the width and height of > displayed image. > Is there a way to do this? (defun image-linkify () "Replace a path to image file with a HTML img tag. Example, if cursor is on the word =E2=80=9Cemacs_logo.png=E2=80=9D, then it= will became =E2=80=9C3D\"emacs=E2=80=9D. If region is active, use region as file name." (interactive) (let (imgPath bds imgDimen width height altText myResult) (setq bds (if (and transient-mark-mode mark-active) (cons (region-beginning) (region-end)) (bounds-of-thing-at-point 'filename) )) (setq imgPath (buffer-substring-no-properties (car bds) (cdr bds)) ) (if (file-exists-p imgPath) (progn (setq altText (file-name-nondirectory imgPath)) (setq altText (replace-regexp-in-string "\\.[A-Za-z]\\{3,4\\}$" "" altText t t)) (setq altText (replace-regexp-in-string "_" " " altText t t)) (setq imgDimen (get-image-dimensions imgPath)) (setq width (number-to-string (car imgDimen))) (setq height (number-to-string (car (last imgDimen)))) (setq myResult (concat "")) (delete-region (car bds) (cdr bds)) (insert myResult) ) (error "File does not exist") ) )) for a full tutorial on this code, see: http://xahlee.org/emacs/elisp_image_tag.html Xah =E2=88=91 http://xahlee.org/ =E2=98=84