Re: [O] Publishing images to various sizes

2015-12-26 Thread John Kitchin
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 "" (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



Re: [O] Publishing images to various sizes

2015-12-26 Thread Arun Isaac

John Kitchin  writes:
> (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 "" (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"))

Thank you. I'll adapt this to my needs.

Regards,
Arun Isaac



[O] Publishing images to various sizes

2015-12-24 Thread Arun Isaac

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.


signature.asc
Description: PGP signature