all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Image View mode and image dimensions Q
@ 2008-10-10 22:14 srdjan.markovich
  2008-10-10 22:48 ` Lennart Borgman
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: srdjan.markovich @ 2008-10-10 22:14 UTC (permalink / raw)
  To: help-gnu-emacs

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?

Regards


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Image View mode and image dimensions Q
  2008-10-10 22:14 Image View mode and image dimensions Q srdjan.markovich
@ 2008-10-10 22:48 ` Lennart Borgman
  2008-10-11 11:01 ` Xah
  2008-10-13 12:13 ` srdjan.markovich
  2 siblings, 0 replies; 7+ messages in thread
From: Lennart Borgman @ 2008-10-10 22:48 UTC (permalink / raw)
  To: srdjan.markovich@gmail.com; +Cc: help-gnu-emacs

On Sat, Oct 11, 2008 at 12:14 AM, srdjan.markovich@gmail.com
<srdjan.markovich@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?

           (let ((sizes (image-size (create-image (expand-file-name src)) t)))




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Image View mode and image dimensions Q
  2008-10-10 22:14 Image View mode and image dimensions Q srdjan.markovich
  2008-10-10 22:48 ` Lennart Borgman
@ 2008-10-11 11:01 ` Xah
  2008-10-11 11:14   ` Xah
  2008-10-11 11:48   ` Lennart Borgman
  2008-10-13 12:13 ` srdjan.markovich
  2 siblings, 2 replies; 7+ messages in thread
From: Xah @ 2008-10-11 11:01 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 10, 3:14 pm, "srdjan.markov...@gmail.com"
<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 “emacs_logo.png”, then it will
became
“<img src=\"emacs_logo.png\" alt=\"emacs logo\" width=\"123\" height=
\"456\">”.

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 "<img src=\"" imgPath "\""
                           " "
                           "alt=\"" altText "\""
                           " "
                           "width=\"" width "\" "
                           "height=\"" height "\">"))

    (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
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Image View mode and image dimensions Q
  2008-10-11 11:01 ` Xah
@ 2008-10-11 11:14   ` Xah
  2008-10-11 11:48   ` Lennart Borgman
  1 sibling, 0 replies; 7+ messages in thread
From: Xah @ 2008-10-11 11:14 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 11, 4:01 am, Xah <xah...@gmail.com> wrote:
> On Oct 10, 3:14 pm, "srdjan.markov...@gmail.com"
>
> <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?

forgot to paste the img dimension function. Here it is:

(defun get-image-dimensions (img-file-relative-path)
  "Returns a image file's width and height as a list."
  (let (tmp dimen)
    (clear-image-cache)
    (setq tmp
          (create-image (concat default-directory img-file-relative-
path)))
    (setq dimen (image-size tmp t))
    (list (car dimen) (cdr dimen))
  )
)

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Image View mode and image dimensions Q
  2008-10-11 11:01 ` Xah
  2008-10-11 11:14   ` Xah
@ 2008-10-11 11:48   ` Lennart Borgman
  1 sibling, 0 replies; 7+ messages in thread
From: Lennart Borgman @ 2008-10-11 11:48 UTC (permalink / raw)
  To: Xah; +Cc: help-gnu-emacs

On Sat, Oct 11, 2008 at 1:01 PM, Xah <xahlee@gmail.com> wrote:
> On Oct 10, 3:14 pm, "srdjan.markov...@gmail.com"
> <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.

In nXhtml you have this kind of thing too (but coupled with XHTML completion).

One thing that I would like however is the ability to get dimensions
of an image that is on the web instead of in a local file. Is there
anyone who have code for this?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Image View mode and image dimensions Q
  2008-10-10 22:14 Image View mode and image dimensions Q srdjan.markovich
  2008-10-10 22:48 ` Lennart Borgman
  2008-10-11 11:01 ` Xah
@ 2008-10-13 12:13 ` srdjan.markovich
  2008-10-13 12:16   ` srdjan.markovich
  2 siblings, 1 reply; 7+ messages in thread
From: srdjan.markovich @ 2008-10-13 12:13 UTC (permalink / raw)
  To: help-gnu-emacs

Thank you very much Xah!

By the way - you have an excellent site! Lot's of valuable resources
and tutorials!!!

Best regards


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Image View mode and image dimensions Q
  2008-10-13 12:13 ` srdjan.markovich
@ 2008-10-13 12:16   ` srdjan.markovich
  0 siblings, 0 replies; 7+ messages in thread
From: srdjan.markovich @ 2008-10-13 12:16 UTC (permalink / raw)
  To: help-gnu-emacs

Thank you Lennart too

I am about to start using nXhtml so I'll investigate its
possibilities...


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-10-13 12:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-10 22:14 Image View mode and image dimensions Q srdjan.markovich
2008-10-10 22:48 ` Lennart Borgman
2008-10-11 11:01 ` Xah
2008-10-11 11:14   ` Xah
2008-10-11 11:48   ` Lennart Borgman
2008-10-13 12:13 ` srdjan.markovich
2008-10-13 12:16   ` srdjan.markovich

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.