[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: HTML img tags
From: |
Konstantin Shakhnov |
Subject: |
Re: HTML img tags |
Date: |
Wed, 14 Dec 2016 12:51:02 +0300 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Sat, Dec 10, 2016 at 10:53:02AM -0600, Hikaru Ichijyo wrote:
> Is there a mode, or some bit of Lisp code I can put in ~/.emacs, that
> will let Emacs guess the width= and height= attributes of an image file
> from the image itself when I create an img tag in HTML? I realize
> there's probably no way for Emacs to do that without calling external
> programs as a subprocess, so it's unlikely, but it would certainly be
> convenient, and there are some HTML authoring programs that will do that
> for you. The old KDE 3 app Quanta Plus did, but I'd rather do
> everything in Emacs.
If you have imagemagic this will work:
(defun my-insert-html-image-tag (filename)
"Insert html tag for image file"
(interactive "fFile name: ")
(insert
(format "<img src=\"%s\" %s />"
filename
(replace-regexp-in-string
"\n" ""
(shell-command-to-string
(format "identify %s | sed -r 's/^.* ([0-9]+)x([0-9]+) .*/width=\\1
heght=\\2/'" filename))))))