emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* inline images
@ 2008-10-01 15:33 Richard Riley
  2008-10-02  0:47 ` Lindsay Todd
  0 siblings, 1 reply; 10+ messages in thread
From: Richard Riley @ 2008-10-01 15:33 UTC (permalink / raw)
  To: org-mode


I sometimes turn on inline images in my org file using code posted here.

,----
| ;; inline images in org files
| ;;iimage
| (require 'iimage)
| (setq iimage-mode-image-search-path (expand-file-name "~/"))
| ;;Match org file: links
| (add-to-list 'iimage-mode-image-regex-alist
|             (cons (concat "\\[\\[file:\\(~?" iimage-mode-image-filename-regex
|                           "\\)\\]")  1))
| (define-key org-mode-map [(control c) ?i] 'iimage-mode)
`----

It might be an idea to make it a setting as to whether the target image
is inlined too. e.g I have a lot of links of this type:

[[file:../images/gud.png][file:../images/guds.png]]

And would like to only see the small preview png file in this case and
not the large one.

Has anyone implemented something like this or has the code above already
been merged into org?

regards,

r.

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

* Re: inline images
  2008-10-01 15:33 inline images Richard Riley
@ 2008-10-02  0:47 ` Lindsay Todd
  2008-10-02 19:56   ` Felipe Csaszar
  0 siblings, 1 reply; 10+ messages in thread
From: Lindsay Todd @ 2008-10-02  0:47 UTC (permalink / raw)
  To: org-mode

It would also be useful if you could specify the size of the image.
I'd like to use org-mode to organize pictures that I want to use for
LaTeX documents -- see the image, as well as the copyright info, etc.
But an image suitable for a presentation is way, way too large for
inline inclusion.  Yet having to manually build thumbnail images
misses the point of easy organization!

On Wed, Oct 1, 2008 at 11:33 AM, Richard Riley
<rileyrgdev@googlemail.com> wrote:
>
> I sometimes turn on inline images in my org file using code posted here.
>
> ,----
> | ;; inline images in org files
> | ;;iimage
> | (require 'iimage)
> | (setq iimage-mode-image-search-path (expand-file-name "~/"))
> | ;;Match org file: links
> | (add-to-list 'iimage-mode-image-regex-alist
> |             (cons (concat "\\[\\[file:\\(~?" iimage-mode-image-filename-regex
> |                           "\\)\\]")  1))
> | (define-key org-mode-map [(control c) ?i] 'iimage-mode)
> `----
>
> It might be an idea to make it a setting as to whether the target image
> is inlined too. e.g I have a lot of links of this type:
>
> [[file:../images/gud.png][file:../images/guds.png]]
>
> And would like to only see the small preview png file in this case and
> not the large one.
>
> Has anyone implemented something like this or has the code above already
> been merged into org?
>
> regards,
>
> r.
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

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

* Re: inline images
  2008-10-02  0:47 ` Lindsay Todd
@ 2008-10-02 19:56   ` Felipe Csaszar
  2008-10-03  3:34     ` Sebastian Rose
  0 siblings, 1 reply; 10+ messages in thread
From: Felipe Csaszar @ 2008-10-02 19:56 UTC (permalink / raw)
  To: emacs-orgmode

Lindsay Todd <rltodd.ml1 <at> gmail.com> writes:

> 
> It would also be useful if you could specify the size of the image.
> I'd like to use org-mode to organize pictures that I want to use for
> LaTeX documents -- see the image, as well as the copyright info, etc.
> But an image suitable for a presentation is way, way too large for
> inline inclusion.  Yet having to manually build thumbnail images
> misses the point of easy organization!
>


A nice way to solve this would be to add a few customizable variables to iimage:

- iimage-max-size-x: do not display image is width > N
- iimage-max-size-y: do not display image is height > N
- iimage-scale-if-oversize: if non-nil, re-scale oversized image so that it fits
within iimage-max-size-x and iimage-max-size-y

Just my two cents.  Best,

Felipe

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

* Re: Re: inline images
  2008-10-02 19:56   ` Felipe Csaszar
@ 2008-10-03  3:34     ` Sebastian Rose
  2008-10-03 16:51       ` Felipe Csaszar
  0 siblings, 1 reply; 10+ messages in thread
From: Sebastian Rose @ 2008-10-03  3:34 UTC (permalink / raw)
  To: emacs-orgmode

Hi Felipe,


did ever try `M-x tumme' alias `M-x image-dired' ???

Displays thumbnails. And there is a possibility to annotate
files (does NOT write EXIF data):

Just press `c' and enter your comments. When ever you select
that image in the thumbnail window (or in dired even??) therafter,
the comment will show up again in the minibuffer.

You may even tag your images (`tt'), remove images from the
thumbnail-view (e.g. to sort them out to find a decision)
and more.



Hmm - emacs has some support for images, but I think it's not the ideal
environment for organising them yet.


How about some programm, that is able to handle a fair amount of
images and has features for organising them? They all create thumbnails
automatically and support tagging, anotations, editing, creation of
HTML-slideshows and and and...


I simply use http://gthumb.sourceforge.net/features.html.





Best Regards,

   - Sebastian



Felipe Csaszar wrote:
> Lindsay Todd <rltodd.ml1 <at> gmail.com> writes:
> 
>> It would also be useful if you could specify the size of the image.
>> I'd like to use org-mode to organize pictures that I want to use for
>> LaTeX documents -- see the image, as well as the copyright info, etc.
>> But an image suitable for a presentation is way, way too large for
>> inline inclusion.  Yet having to manually build thumbnail images
>> misses the point of easy organization!
>>
> 
> 
> A nice way to solve this would be to add a few customizable variables to iimage:
> 
> - iimage-max-size-x: do not display image is width > N
> - iimage-max-size-y: do not display image is height > N
> - iimage-scale-if-oversize: if non-nil, re-scale oversized image so that it fits
> within iimage-max-size-x and iimage-max-size-y
> 
> Just my two cents.  Best,
> 
> Felipe

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

* Re: inline images
  2008-10-03  3:34     ` Sebastian Rose
@ 2008-10-03 16:51       ` Felipe Csaszar
  2008-10-07  2:50         ` gregory mitchell
  0 siblings, 1 reply; 10+ messages in thread
From: Felipe Csaszar @ 2008-10-03 16:51 UTC (permalink / raw)
  To: emacs-orgmode

Sebastian Rose <sebastian_rose <at> gmx.de> writes:

> 
> Hi Felipe,
> 
> did ever try `M-x tumme' alias `M-x image-dired' ???
> 
> Displays thumbnails. And there is a possibility to annotate
> files (does NOT write EXIF data):

Hi Sebastian,

The use case I think Lindsay refers to is not about tagging
images, but about displaying images inline in org-mode (as
muse-mode can do).  Iimage does a lot of the work towards
that goal, but it would be nice to have some control about
what to do with oversized images (e.g., not displaying or
scaling them).  That's my interpretation of Linday's comment
and a functionality I would like.  Any volunteers?  

Best,

Felipe

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

* Re: Re: inline images
  2008-10-03 16:51       ` Felipe Csaszar
@ 2008-10-07  2:50         ` gregory mitchell
  2011-01-07  8:06           ` Vladimir Alexiev
  0 siblings, 1 reply; 10+ messages in thread
From: gregory mitchell @ 2008-10-07  2:50 UTC (permalink / raw)
  To: emacs-orgmode

Hey all,

my first post to this list.  This topic has been bugging me for some time also.

The following is a snippet of elisp that can be used to take a file
name in a buffer and paste the image file right below it.  The image
is inserted just as any other character, and can be moved, yanked,
copied and/or pasted as such.

This only works for png, but it's easy enough to modify for jpeg, etc
as well.  I often use this method in combination with various other
things to generate postscript/pstricks/latex diagrams, etc, and view
the results immediately.



(global-set-key (kbd "C-S-p") 'insert-png-wrapper)
(defun insert-png-wrapper ()
  (interactive)
  (setq oldmark (mark)) ; save old mark
  (setq oldpoint (point))  ; and old point
  (beginning-of-line)
  (set-mark (point))     (end-of-line)
  (setq filename (buffer-substring (mark) (point)))  ; copy line
  (newline 1)
	(clear-image-cache)  ; images are cached until cleared
	(insert-image (create-image filename 'png))
  )


If you load "eimp.el" as a minor mode, you can use the functions
"eimp-increase-image-size" and "eimp-decrease-image-size" to make the
image smaller or larger.

There's my 2.5 cents.  Cheers.

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

* Re: inline images
  2008-10-07  2:50         ` gregory mitchell
@ 2011-01-07  8:06           ` Vladimir Alexiev
  2011-01-07 16:31             ` [PATCH] org-display-inline-images to reduce image size Vladimir Alexiev
  0 siblings, 1 reply; 10+ messages in thread
From: Vladimir Alexiev @ 2011-01-07  8:06 UTC (permalink / raw)
  To: emacs-orgmode

eimp.el uses an external program (mogrify) to actually modify the image. 
That's not what is wanted. The image should remain the same, 
just be displayed in emacs in a smaller size

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

* [PATCH] org-display-inline-images to reduce image size
  2011-01-07  8:06           ` Vladimir Alexiev
@ 2011-01-07 16:31             ` Vladimir Alexiev
  2011-01-10  8:31               ` Vladimir Alexiev
  0 siblings, 1 reply; 10+ messages in thread
From: Vladimir Alexiev @ 2011-01-07 16:31 UTC (permalink / raw)
  To: emacs-orgmode

Here's a patch that introduces two custom options
org-display-inline-image-width, org-display-inline-image-height
and patches org-display-inline-images to respect them as
max width, height settings for inline images.

(Someone please defcustom them for me, I only know defvar syntax).

org-display-inline-images uses overlay-put.
(iimage.el uses text-properties, which are recommended in emacs).
(The refs below are (elisp) info nodes.)
Both overlays and text-properties use "Display Property", 
"Other Display Specifications" to setup an image. 
Of all "Image" formats, only "ImageMagick Images" (maybe XBM and PS) 
support scaling. 
That is, IF you build Emacs with ImageMagick (a big if indeed!)

So the patch uses scaling if (fboundp 'imagemagick-types)
  and in this case you must call (imagemagick-register-types) in your .emacs;
else it uses a slice the top left corner (cropping the rest).

diff --git a/doc/org.texi b/doc/org.texi
index 96ea986..9e1c5cf 100755
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -3266,13 +3266,31 @@ variable @code{org-display-internal-link-with-indirect-
buffer}}.
 @vindex org-startup-with-inline-images
 @cindex @code{inlineimages}, STARTUP keyword
 @cindex @code{noinlineimages}, STARTUP keyword
-Toggle the inline display of linked images.  Normally this will only inline
+Toggle the inline display of linked images. 
+Works only for links that start with @code{file:},
+"." (current dir), "/" (root dir) or "~" (home dir). 
+Normally this will only inline
 images that have no description part in the link, i.e. images that will also
 be inlined during export.  When called with a prefix argument, also display
 images that do have a link description.  You can ask for inline images to be
 displayed at startup by configuring the variable
 @code{org-startup-with-inline-images}@footnote{with corresponding
 @code{#+STARTUP} keywords @code{inlineimages} and @code{inlineimages}}.
+
+@vindex org-display-inline-image-width
+@vindex org-display-inline-image-height
+Maximum image size that Orgmode will display inline. Images are reduced by 
EITHER:
+@itemize @bullet
+@itemize Scaling down: supported when Emacs is compiled with ImageMagic, in 
which case
+  the function @code{imagemagick-types} is bound. You should invoke
+  @code{(imagemagick-register-types)} in your @code{.emacs}, OR
+@itemize Slicing the top left corner and cropping the rest
+@end itemize
+Integer specifies maximum number of pixels.
+Floating number specifies maximum ratio to the frame width/height respectively.
+nil places no restriction on the respective dimension. 
+If both are set, scaling can distort the aspect ratio
+
 @orgcmd{C-c %,org-mark-ring-push}
 @cindex mark ring
 Push the current position onto the mark ring, to be able to return
	Modified lisp/org.el
diff --git a/lisp/org.el b/lisp/org.el
index 53039e4..836286c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16156,6 +16156,55 @@ INCLUDE-LINKED is passed to `org-display-inline-
images'."
 		 (length org-inline-image-overlays))
       (message "No images to display inline"))))
 
+;; TODO: defcustom
+(defvar org-display-inline-image-width nil
+"*Maximum image width that Orgmode will display inline.
+Images are reduced by:
+- Scaling down: supported when Emacs is compiled with ImageMagic, in which case
+  (fboundp 'imagemagick-types). You should invoke (imagemagick-register-types) 
in .emacs. 
+- Otherwise: slicing the top left corner and cropping the rest
+Integer specifies maximum number of pixels.
+Floating point specifies maximum ratio to the frame width.
+nil places no restriction.
+If both org-display-inline-image-width and org-display-inline-image-height are 
set, 
+scaling can distort the aspect ratio")
+
+;; TODO: defcustom
+(defvar org-display-inline-image-height nil
+"*Maximum image height that Orgmode will display inline.
+Works similarly to org-display-inline-image-width, which see.")
+
+;; TODO tested only in GNU Emacs 24.0.50.1
+;; TODO scaling not tested (don't have ImageMagick)!
+(defun org-display-inline-images-scale-or-slice (img)
+  ;; Return eventually scaled or sliced down version of image IMG.
+  ;; Scaling is an image property (after 'image)
+  ;; Slicing is a display property (for overlay or text-property) (before 
'image).
+  (when (or org-display-inline-image-width org-display-inline-image-height)
+    (let (c w h width height width height)
+      (setq c (image-size img 'pixels))
+      (setq w (car c) h (cdr c))
+      (setq width (cond
+                   ((integerp org-display-inline-image-width)
+                    org-display-inline-image-width)
+                   ((floatp org-display-inline-image-width)
+                    (truncate (* org-display-inline-image-width (frame-pixel-
width))))))
+      (setq height (cond
+                    ((integerp org-display-inline-image-height)
+                     org-display-inline-image-height)
+                    ((floatp org-display-inline-image-height) 
+                     (truncate (* org-display-inline-image-height (frame-pixel-
height))))))
+      (setq width (and width (> w width) width)) ; if set and w>width then 
width
+      (setq height (and height (> h height) height)) ; if height and h>height 
then height
+      (cond ((fboundp 'imagemagick-types) ; do scaling (it's preferred)
+             ;; FIXME: here we assume that :width :height are given to 
ImageMagick in pixels, 
+             ;; but they could be ratio of original size
+             (if width (setq img (append img (list :width width))))
+             (if height (setq img (append img (list :height height)))))
+            ((or width height)         ; do slicing
+             (setq img (list (list 'slice 0 0 width height) img))))))
+  img)
+
 (defun org-display-inline-images (&optional include-linked refresh beg end)
   "Display inline images.
 Normally only links without a description part are inlined, because this
@@ -16190,7 +16239,7 @@ BEG and END default to the buffer boundaries."
 	      (setq img (save-match-data (create-image file)))
 	      (when img
 		(setq ov (make-overlay (match-beginning 0) (match-end 0)))
-		(overlay-put ov 'display img)
+		(overlay-put ov 'display (org-display-inline-images-scale-or-
slice img))
 		(overlay-put ov 'face 'default)
 		(overlay-put ov 'org-image-overlay t)
 		(overlay-put ov 'modification-hooks

TINYCHANGE

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

* Re: [PATCH] org-display-inline-images to reduce image size
  2011-01-07 16:31             ` [PATCH] org-display-inline-images to reduce image size Vladimir Alexiev
@ 2011-01-10  8:31               ` Vladimir Alexiev
  2011-02-07  8:33                 ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Vladimir Alexiev @ 2011-01-10  8:31 UTC (permalink / raw)
  To: emacs-orgmode

How to avoid line breakage in the patch? 
Some source lines are naturally >80 chars and I wouldn't like to shorten them.
I posted from the web (http://post.gmane.org/post.php?group=gmane.emacs.orgmode)
I guess I should get an account and post from a real mail client?

Furthermore, the "Comments" at the patchwork server 
(http://patchwork.newartisans.com/patch/526/)
mess up the patch, though the patch itself is ok
(http://patchwork.newartisans.com/patch/526/raw/)

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

* Re: Re: [PATCH] org-display-inline-images to reduce image size
  2011-01-10  8:31               ` Vladimir Alexiev
@ 2011-02-07  8:33                 ` Bastien
  0 siblings, 0 replies; 10+ messages in thread
From: Bastien @ 2011-02-07  8:33 UTC (permalink / raw)
  To: Vladimir Alexiev; +Cc: emacs-orgmode

Hi Vladimir,

Vladimir Alexiev <vladimir@sirma.bg> writes:

> How to avoid line breakage in the patch? 

Better to use plain text emails from your client - sending from gmane
will result in messing up long lines.

> Some source lines are naturally >80 chars and I wouldn't like to shorten them.
> I posted from the web (http://post.gmane.org/post.php?group=gmane.emacs.orgmode)
> I guess I should get an account and post from a real mail client?
>
> Furthermore, the "Comments" at the patchwork server 
> (http://patchwork.newartisans.com/patch/526/)
> mess up the patch, though the patch itself is ok
> (http://patchwork.newartisans.com/patch/526/raw/)

I downloaded the patch and lines are not well wrapped - they are wrapped
the way patchwork displays it.

Could you resubmit your patch?  I'm willing to test it.

Thanks!

-- 
 Bastien

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

end of thread, other threads:[~2011-02-07  8:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-01 15:33 inline images Richard Riley
2008-10-02  0:47 ` Lindsay Todd
2008-10-02 19:56   ` Felipe Csaszar
2008-10-03  3:34     ` Sebastian Rose
2008-10-03 16:51       ` Felipe Csaszar
2008-10-07  2:50         ` gregory mitchell
2011-01-07  8:06           ` Vladimir Alexiev
2011-01-07 16:31             ` [PATCH] org-display-inline-images to reduce image size Vladimir Alexiev
2011-01-10  8:31               ` Vladimir Alexiev
2011-02-07  8:33                 ` Bastien

Code repositories for project(s) associated with this public inbox

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

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