unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Konstantin Shakhnov <kastian@mail.ru>
To: help-gnu-emacs@gnu.org
Subject: Re: HTML img tags
Date: Wed, 14 Dec 2016 12:51:02 +0300	[thread overview]
Message-ID: <20161214095101.GA8977@eee> (raw)
In-Reply-To: <8xxoa0johe9.fsf@village.keycorner.org>

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))))))



  parent reply	other threads:[~2016-12-14  9:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-10 16:53 HTML img tags Hikaru Ichijyo
2016-12-10 17:55 ` Eli Zaretskii
2016-12-12 15:46 ` HASM
2016-12-14  4:44 ` James K. Lowden
2016-12-14  9:05   ` B.V. Raghav
2016-12-14  9:39 ` Lars Magne Ingebrigtsen
2016-12-14  9:51 ` Konstantin Shakhnov [this message]
2016-12-14 10:48   ` tomas
2016-12-14 13:27     ` Konstantin Shakhnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161214095101.GA8977@eee \
    --to=kastian@mail.ru \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).