emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Publishing images to various sizes


From: John Kitchin
Subject: Re: [O] Publishing images to various sizes
Date: Sat, 26 Dec 2015 20:31:51 -0500
User-agent: mu4e 0.9.13; emacs 25.0.50.1

This isn't quite what you want but it is close. It is some code I hacked
a while ago to convert pdf files to png files for html export. You can
probably adapt this to get the sizes that you want by modifying the
shell command.

(defun my-link-format (link contents info)
  (let ((type (org-element-property :type link))
        (path (org-element-property :path link)))
    (cond
     ((and
       (string= type "file")
       (string-match "\.pdf" path))
      (shell-command
       (format
        "convert %s %s"
        path
        (replace-regexp-in-string "\.pdf" ".png" path)))
      (format "<img src=\"%s\">" (replace-regexp-in-string "\.pdf" ".png" 
path)))
     ;; anything else, we just do the regular thing
     (t
      (org-html-link link contents info)))))

(org-export-define-derived-backend 'my-html 'html
  :translate-alist '((link . my-link-format)))


(browse-url (org-export-to-file 'my-html "custom-link.html"))


Arun Isaac writes:

> Hi,
>
> Is there some package that provides a publishing function I can use to
> automatically publish images to various sizes? Probably something that
> wraps around imagemagick's 'convert' command?
>
> When I publish images to my website, I want them to be available in
> various sizes, so that I can choose the appropriate image for the
> context in which it appears, and thus optimize bandwidth usage.
>
> Thanks,
> Arun Isaac.

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]