all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* insert picture feature request.
@ 2011-05-02 12:42 Piter_
  2011-05-02 13:28 ` Russell Adams
  0 siblings, 1 reply; 18+ messages in thread
From: Piter_ @ 2011-05-02 12:42 UTC (permalink / raw)
  To: emacs-orgmode

Hi all.
I use org-mode for making note while reading articles.
Sometimes I want to insert picture into notes. Now it takes to much
time. I have to copy paste it into picture editor, save it and than
make a link to it.
I would like to do it in other way. Copy picture into clipboard (from
pdf reader for example), and than run a function in emacs which will
ask for file name, save the picture from clipboard into preset folder
and insert link into org file for it.
I have found those links.
http://stackoverflow.com/questions/1868734/how-to-copy-to-clipboard-with-x11
http://stackoverflow.com/questions/3571179/how-does-x11-clipboard-handle-multiple-data-formats

About handling clipboard images from python.
I think it is possible to write a simple python script which can save
clipboard picture into file, and than some lisp function which do all
I described above using this script.
Unfortunately I dont know  python and lisp on level which allow me to
do it fast end easy. So I ask if someone can do it. I think it would
be useful addition for org-mode. May be even someone have implemented
it, or made another work arround  this problem.
Thanks.
Petro.
P.S. Sorry if you get two copies of request. I had some troubles with
sending it and may sent two versions of this mail.

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

* Re: insert picture feature request.
  2011-05-02 12:42 insert picture feature request Piter_
@ 2011-05-02 13:28 ` Russell Adams
  2011-05-02 14:23   ` brian powell
  2011-05-04  0:37   ` Mark S.
  0 siblings, 2 replies; 18+ messages in thread
From: Russell Adams @ 2011-05-02 13:28 UTC (permalink / raw)
  To: emacs-orgmode

On Mon, May 02, 2011 at 02:42:41PM +0200, Piter_ wrote:
> Hi all.
> I use org-mode for making note while reading articles.
> Sometimes I want to insert picture into notes. Now it takes to much
> time. I have to copy paste it into picture editor, save it and than
> make a link to it.
> I would like to do it in other way. Copy picture into clipboard (from
> pdf reader for example), and than run a function in emacs which will
> ask for file name, save the picture from clipboard into preset folder
> and insert link into org file for it.
> I have found those links.
> http://stackoverflow.com/questions/1868734/how-to-copy-to-clipboard-with-x11
> http://stackoverflow.com/questions/3571179/how-does-x11-clipboard-handle-multiple-data-formats
>
> About handling clipboard images from python.
> I think it is possible to write a simple python script which can save
> clipboard picture into file, and than some lisp function which do all
> I described above using this script.
> Unfortunately I dont know  python and lisp on level which allow me to
> do it fast end easy. So I ask if someone can do it. I think it would
> be useful addition for org-mode. May be even someone have implemented
> it, or made another work arround  this problem.
> Thanks.
> Petro.
> P.S. Sorry if you get two copies of request. I had some troubles with
> sending it and may sent two versions of this mail.
>

There was a discussion with a working solution not long ago for taking
screenshots and inserting them into org automatically.

http://comments.gmane.org/gmane.emacs.orgmode/33770

I suspect the code is on worg.

Enjoy.

------------------------------------------------------------------
Russell Adams                            RLAdams@AdamsInfoServ.com

PGP Key ID:     0x1160DCB3           http://www.adamsinfoserv.com/

Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3

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

* Re: insert picture feature request.
  2011-05-02 13:28 ` Russell Adams
@ 2011-05-02 14:23   ` brian powell
  2011-05-02 23:34     ` Piter_
  2011-05-04  0:37   ` Mark S.
  1 sibling, 1 reply; 18+ messages in thread
From: brian powell @ 2011-05-02 14:23 UTC (permalink / raw)
  To: emacs-orgmode

* This is what I use (thanks to whomever wrote the original):

(defun org-screenshot ()
                           "Take a screenshot into a time stamped
unique-named file in the same directory as the org-buffer and insert a
link to this file."
                           (interactive)
                           (setq filename
                                 (concat
                                  (make-temp-name
                                   (concat (buffer-file-name)
                                           "_"
                                           (format-time-string
"%Y%m%d_%H%M%S_")) ) ".png"))
                           (call-process "import" nil nil nil filename)
                           (insert (concat "[[" filename "]]")))

** Works great for me, puts a timestamp on it and the filename.

** Also, notice the ".png":

*** The link above suggests ".jpg" (as the default)--which is great
for most things; except, JPG is a lossy compression format, but it
does load faster.

**** http://www.turnkeylinux.org/blog/png-vs-jpg

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

* Re: insert picture feature request.
  2011-05-02 14:23   ` brian powell
@ 2011-05-02 23:34     ` Piter_
  0 siblings, 0 replies; 18+ messages in thread
From: Piter_ @ 2011-05-02 23:34 UTC (permalink / raw)
  To: brian powell; +Cc: emacs-orgmode

Thanks.
It is what I need.

Than

On Mon, May 2, 2011 at 4:23 PM, brian powell <briangpowellms@gmail.com> wrote:
> * This is what I use (thanks to whomever wrote the original):
>
> (defun org-screenshot ()
>                           "Take a screenshot into a time stamped
> unique-named file in the same directory as the org-buffer and insert a
> link to this file."
>                           (interactive)
>                           (setq filename
>                                 (concat
>                                  (make-temp-name
>                                   (concat (buffer-file-name)
>                                           "_"
>                                           (format-time-string
> "%Y%m%d_%H%M%S_")) ) ".png"))
>                           (call-process "import" nil nil nil filename)
>                           (insert (concat "[[" filename "]]")))
>
> ** Works great for me, puts a timestamp on it and the filename.
>
> ** Also, notice the ".png":
>
> *** The link above suggests ".jpg" (as the default)--which is great
> for most things; except, JPG is a lossy compression format, but it
> does load faster.
>
> **** http://www.turnkeylinux.org/blog/png-vs-jpg
>
>

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

* Re: insert picture feature request.
  2011-05-02 13:28 ` Russell Adams
  2011-05-02 14:23   ` brian powell
@ 2011-05-04  0:37   ` Mark S.
  2011-05-04 10:01     ` Rainer Stengele
  1 sibling, 1 reply; 18+ messages in thread
From: Mark S. @ 2011-05-04  0:37 UTC (permalink / raw)
  To: emacs-orgmode

This doesn't work under windows even if you have ImageMagick installed. Is there a similar way to capture and insert a picture under windows?

Thanks!

--- On Mon, 5/2/11, Russell Adams <RLAdams@AdamsInfoServ.Com> wrote:

> From: Russell Adams <RLAdams@AdamsInfoServ.Com>
> Subject: Re: [O] insert picture feature request.
> To: emacs-orgmode@gnu.org
> Date: Monday, May 2, 2011, 6:28 AM
> On Mon, May 02, 2011 at 02:42:41PM
> +0200, Piter_ wrote:
> > Hi all.
> > I use org-mode for making note while reading
> articles.
> > Sometimes I want to insert picture into notes. Now it
> takes to much
> > time. I have to copy paste it into picture editor,
> save it and than
> > make a link to it.
> > I would like to do it in other way. Copy picture into
> clipboard (from
> > pdf reader for example), and than run a function in
> emacs which will
> > ask for file name, save the picture from clipboard
> into preset folder
> > and insert link into org file for it.
> > I have found those links.
> > http://stackoverflow.com/questions/1868734/how-to-copy-to-clipboard-with-x11
> > http://stackoverflow.com/questions/3571179/how-does-x11-clipboard-handle-multiple-data-formats
> >
> > About handling clipboard images from python.
> > I think it is possible to write a simple python script
> which can save
> > clipboard picture into file, and than some lisp
> function which do all
> > I described above using this script.
> > Unfortunately I dont know  python and lisp on
> level which allow me to
> > do it fast end easy. So I ask if someone can do it. I
> think it would
> > be useful addition for org-mode. May be even someone
> have implemented
> > it, or made another work arround  this problem.
> > Thanks.
> > Petro.
> > P.S. Sorry if you get two copies of request. I had
> some troubles with
> > sending it and may sent two versions of this mail.
> >
> 
> There was a discussion with a working solution not long ago
> for taking
> screenshots and inserting them into org automatically.
> 
> http://comments.gmane.org/gmane.emacs.orgmode/33770
> 
> I suspect the code is on worg.
> 
> Enjoy.
> 
> ------------------------------------------------------------------
> Russell Adams           
>                 RLAdams@AdamsInfoServ.com
> 
> PGP Key ID:     0x1160DCB3   
>        http://www.adamsinfoserv.com/
> 
> Fingerprint:    1723 D8CA 4280 1EC9 557F 
> 66E8 1154 E018 1160 DCB3
> 
>

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

* Re: insert picture feature request.
  2011-05-04  0:37   ` Mark S.
@ 2011-05-04 10:01     ` Rainer Stengele
  2011-05-04 12:38       ` Jambunathan K
                         ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Rainer Stengele @ 2011-05-04 10:01 UTC (permalink / raw)
  Cc: emacs-orgmode

+1 for windows support.

I would also need such a image copy tool under windows.

A way to capture an image and have it referenced/included in an org file
with a simple keychord would be most welcome.

What most of my colleagues - non Emacs users - do is open MS Word,
paste some captured images and write some simple comments.
No need to copy, save and link to an image.
A documentation including some screenshots is done in a snap.

For me this is one of the things I miss a lot while living in Org.
Anybody knows about a comparable tool to Imagemagick "import" under Windows?

===============================================================================

OK - I searched a bit and found this, which works on command line: (see http://www.irfanview.de)


Example for /capture:
i_view32.exe /capture=0
Capture the whole screen.
i_view32.exe /capture=6
Start in Capture mode, use last used capture dialog settings.

capture values:
0 = whole screen
1 = current monitor, where mouse is located
2 = foreground window
3 = foreground window - client area
4 = rectangle selection
5 = object selected with the mouse
6 = start in capture mode (can't be combined with other commandline options)

Advanced examples:
i_view32.exe /capture=2 /convert=c:\test.jpg
Capture foreground window and save result as file.
i_view32.exe /capture=2 /convert=c:\capture_$U(%d%m%Y_%H%M%S).jpg
Capture foreground window and save result as file; the file name contains time stamp.
===============================================================================

I will try this in my Org environment.

-- Rainer



Am 04.05.2011 02:37, schrieb Mark S.:
> This doesn't work under windows even if you have ImageMagick installed. Is there a similar way to capture and insert a picture under windows?
> 
> Thanks!
> 
> --- On Mon, 5/2/11, Russell Adams <RLAdams@AdamsInfoServ.Com> wrote:
> 
>> From: Russell Adams <RLAdams@AdamsInfoServ.Com>
>> Subject: Re: [O] insert picture feature request.
>> To: emacs-orgmode@gnu.org
>> Date: Monday, May 2, 2011, 6:28 AM
>> On Mon, May 02, 2011 at 02:42:41PM
>> +0200, Piter_ wrote:
>>> Hi all.
>>> I use org-mode for making note while reading
>> articles.
>>> Sometimes I want to insert picture into notes. Now it
>> takes to much
>>> time. I have to copy paste it into picture editor,
>> save it and than
>>> make a link to it.
>>> I would like to do it in other way. Copy picture into
>> clipboard (from
>>> pdf reader for example), and than run a function in
>> emacs which will
>>> ask for file name, save the picture from clipboard
>> into preset folder
>>> and insert link into org file for it.
>>> I have found those links.
>>> http://stackoverflow.com/questions/1868734/how-to-copy-to-clipboard-with-x11
>>> http://stackoverflow.com/questions/3571179/how-does-x11-clipboard-handle-multiple-data-formats
>>>
>>> About handling clipboard images from python.
>>> I think it is possible to write a simple python script
>> which can save
>>> clipboard picture into file, and than some lisp
>> function which do all
>>> I described above using this script.
>>> Unfortunately I dont know  python and lisp on
>> level which allow me to
>>> do it fast end easy. So I ask if someone can do it. I
>> think it would
>>> be useful addition for org-mode. May be even someone
>> have implemented
>>> it, or made another work arround  this problem.
>>> Thanks.
>>> Petro.
>>> P.S. Sorry if you get two copies of request. I had
>> some troubles with
>>> sending it and may sent two versions of this mail.
>>>
>>
>> There was a discussion with a working solution not long ago
>> for taking
>> screenshots and inserting them into org automatically.
>>
>> http://comments.gmane.org/gmane.emacs.orgmode/33770
>>
>> I suspect the code is on worg.
>>
>> Enjoy.
>>
>> ------------------------------------------------------------------
>> Russell Adams           
>>                 RLAdams@AdamsInfoServ.com
>>
>> PGP Key ID:     0x1160DCB3   
>>        http://www.adamsinfoserv.com/
>>
>> Fingerprint:    1723 D8CA 4280 1EC9 557F 
>> 66E8 1154 E018 1160 DCB3
>>
>>
> 
> 

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

* Re: insert picture feature request.
  2011-05-04 10:01     ` Rainer Stengele
@ 2011-05-04 12:38       ` Jambunathan K
  2011-05-04 14:10         ` Jambunathan K
  2011-05-04 13:19       ` Russell Adams
  2011-05-04 13:28       ` Rainer Stengele
  2 siblings, 1 reply; 18+ messages in thread
From: Jambunathan K @ 2011-05-04 12:38 UTC (permalink / raw)
  To: Rainer Stengele; +Cc: emacs-orgmode


> +1 for windows support.
>
> I would also need such a image copy tool under windows.

>
> A way to capture an image and have it referenced/included in an org file
> with a simple keychord would be most welcome.
>
> What most of my colleagues - non Emacs users - do is open MS Word,
> paste some captured images and write some simple comments.
> No need to copy, save and link to an image.
> A documentation including some screenshots is done in a snap.
>
> For me this is one of the things I miss a lot while living in Org.
> Anybody knows about a comparable tool to Imagemagick "import" under
> Windows?

Here comes Emacswiki to the rescue!

http://rasm.ods.org/boxcutter/download/boxcutter-1.3/
http://www.emacswiki.org/emacs/mon-boxcutter.el

Disclaimer: I haven't tried it. This is purely for my link karma.

Jambunathan K.
-- 

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

* Re: insert picture feature request.
  2011-05-04 10:01     ` Rainer Stengele
  2011-05-04 12:38       ` Jambunathan K
@ 2011-05-04 13:19       ` Russell Adams
  2011-05-07 21:33         ` Mark S.
  2011-05-04 13:28       ` Rainer Stengele
  2 siblings, 1 reply; 18+ messages in thread
From: Russell Adams @ 2011-05-04 13:19 UTC (permalink / raw)
  To: Rainer Stengele; +Cc: emacs-orgmode, Mark S.

On Wed, May 04, 2011 at 12:01:53PM +0200, Rainer Stengele wrote:

> i_view32.exe /capture=2 /convert=c:\capture_$U(%d%m%Y_%H%M%S).jpg

(defun org-screenshot ()
  "Take a screenshot into a time stamped
   unique-named file in the same directory as
   the org-buffer and insert a link to this file."
  (interactive)
  (setq filename
        (concat
         (make-temp-name
          (concat (buffer-file-name)
                  "_"
                  (format-time-string
                   "%Y%m%d_%H%M%S_")) ) ".png"))
  (call-process "i_view32.exe" nil nil nil
                "/capture=2" (concat "/convert=" filename) )
  (insert (concat "[[" filename "]]"))
  (org-display-inline-images))

Does that work? Elisp is formatting the filename based on the Org
buffer you're in and adding a timestamp.

------------------------------------------------------------------
Russell Adams                            RLAdams@AdamsInfoServ.com

PGP Key ID:     0x1160DCB3           http://www.adamsinfoserv.com/

Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3

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

* Re: insert picture feature request.
  2011-05-04 10:01     ` Rainer Stengele
  2011-05-04 12:38       ` Jambunathan K
  2011-05-04 13:19       ` Russell Adams
@ 2011-05-04 13:28       ` Rainer Stengele
  2 siblings, 0 replies; 18+ messages in thread
From: Rainer Stengele @ 2011-05-04 13:28 UTC (permalink / raw)
  Cc: emacs-orgmode

Am 04.05.2011 12:01, schrieb Rainer Stengele:
> +1 for windows support.
> 
> I would also need such a image copy tool under windows.
> 
> A way to capture an image and have it referenced/included in an org file
> with a simple keychord would be most welcome.
> 
> What most of my colleagues - non Emacs users - do is open MS Word,
> paste some captured images and write some simple comments.
> No need to copy, save and link to an image.
> A documentation including some screenshots is done in a snap.
> 
> For me this is one of the things I miss a lot while living in Org.
> Anybody knows about a comparable tool to Imagemagick "import" under Windows?
> 
> ===============================================================================
> 
> OK - I searched a bit and found this, which works on command line: (see http://www.irfanview.de)
> 
> 
> Example for /capture:
> i_view32.exe /capture=0
> Capture the whole screen.
> i_view32.exe /capture=6
> Start in Capture mode, use last used capture dialog settings.
> 
> capture values:
> 0 = whole screen
> 1 = current monitor, where mouse is located
> 2 = foreground window
> 3 = foreground window - client area
> 4 = rectangle selection
> 5 = object selected with the mouse
> 6 = start in capture mode (can't be combined with other commandline options)
> 
> Advanced examples:
> i_view32.exe /capture=2 /convert=c:\test.jpg
> Capture foreground window and save result as file.
> i_view32.exe /capture=2 /convert=c:\capture_$U(%d%m%Y_%H%M%S).jpg
> Capture foreground window and save result as file; the file name contains time stamp.
> ===============================================================================
> 
> I will try this in my Org environment.
> 
> -- Rainer
> 
> 
> 
> Am 04.05.2011 02:37, schrieb Mark S.:
>> This doesn't work under windows even if you have ImageMagick installed. Is there a similar way to capture and insert a picture under windows?
>>
>> Thanks!
>>
>> --- On Mon, 5/2/11, Russell Adams <RLAdams@AdamsInfoServ.Com> wrote:
>>
>>> From: Russell Adams <RLAdams@AdamsInfoServ.Com>
>>> Subject: Re: [O] insert picture feature request.
>>> To: emacs-orgmode@gnu.org
>>> Date: Monday, May 2, 2011, 6:28 AM
>>> On Mon, May 02, 2011 at 02:42:41PM
>>> +0200, Piter_ wrote:
>>>> Hi all.
>>>> I use org-mode for making note while reading
>>> articles.
>>>> Sometimes I want to insert picture into notes. Now it
>>> takes to much
>>>> time. I have to copy paste it into picture editor,
>>> save it and than
>>>> make a link to it.
>>>> I would like to do it in other way. Copy picture into
>>> clipboard (from
>>>> pdf reader for example), and than run a function in
>>> emacs which will
>>>> ask for file name, save the picture from clipboard
>>> into preset folder
>>>> and insert link into org file for it.
>>>> I have found those links.
>>>> http://stackoverflow.com/questions/1868734/how-to-copy-to-clipboard-with-x11
>>>> http://stackoverflow.com/questions/3571179/how-does-x11-clipboard-handle-multiple-data-formats
>>>>
>>>> About handling clipboard images from python.
>>>> I think it is possible to write a simple python script
>>> which can save
>>>> clipboard picture into file, and than some lisp
>>> function which do all
>>>> I described above using this script.
>>>> Unfortunately I dont know  python and lisp on
>>> level which allow me to
>>>> do it fast end easy. So I ask if someone can do it. I
>>> think it would
>>>> be useful addition for org-mode. May be even someone
>>> have implemented
>>>> it, or made another work arround  this problem.
>>>> Thanks.
>>>> Petro.
>>>> P.S. Sorry if you get two copies of request. I had
>>> some troubles with
>>>> sending it and may sent two versions of this mail.
>>>>
>>>
>>> There was a discussion with a working solution not long ago
>>> for taking
>>> screenshots and inserting them into org automatically.
>>>
>>> http://comments.gmane.org/gmane.emacs.orgmode/33770
>>>
>>> I suspect the code is on worg.
>>>
>>> Enjoy.
>>>
>>> ------------------------------------------------------------------
>>> Russell Adams           
>>>                 RLAdams@AdamsInfoServ.com
>>>
>>> PGP Key ID:     0x1160DCB3   
>>>        http://www.adamsinfoserv.com/
>>>
>>> Fingerprint:    1723 D8CA 4280 1EC9 557F 
>>> 66E8 1154 E018 1160 DCB3
>>>
>>>
>>
>>
> 
> 
> 
> 
The better approach seems to be to take the screenshot image from the clipboard.
Therefore any screenshot tool will do.

This works for me under Windows XP:
(I had to introduce the tilde-buffer-filename variable for irfanview to work)


(defun org-screenshot ()
  "Take a screenshot into a time stamped unique-named file in the same directory as the org-buffer and insert
a link to this file."
  (interactive)
  (setq tilde-buffer-filename
	(replace-regexp-in-string "/" "\\" (buffer-file-name) t t))
  (setq filename
	(concat
	 (make-temp-name
	  (concat tilde-buffer-filename
		  "_"
		  (format-time-string "%Y%m%d_%H%M%S_")) ) ".jpg"))
  ;; Linux: ImageMagick: (call-process "import" nil nil nil filename)
  ;; Windows: Irfanview
  (call-process "c:\\Programme\\IrfanView\\i_view32.exe" nil nil nil (concat "/clippaste /convert=" filename))
  (insert (concat "[[file:" filename "]]"))
  (org-display-inline-images))


So this is how it works:

1. take a screenshot with any tool you are used to use
2. change to your org buffer and call "org-screenshot" via M-x

Instead of ".jpg" you can use any format IrfanView understands, for example "png".

Very useful!

-- Rainer

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

* Re: insert picture feature request.
  2011-05-04 12:38       ` Jambunathan K
@ 2011-05-04 14:10         ` Jambunathan K
  0 siblings, 0 replies; 18+ messages in thread
From: Jambunathan K @ 2011-05-04 14:10 UTC (permalink / raw)
  To: Rainer Stengele; +Cc: emacs-orgmode

Jambunathan K <kjambunathan@gmail.com> writes:

>> +1 for windows support.
>>
>> I would also need such a image copy tool under windows.
>
>>
>> A way to capture an image and have it referenced/included in an org file
>> with a simple keychord would be most welcome.
>>
>> For me this is one of the things I miss a lot while living in Org.
>> Anybody knows about a comparable tool to Imagemagick "import" under
>> Windows?
>
> Here comes Emacswiki to the rescue!
>
> http://rasm.ods.org/boxcutter/download/boxcutter-1.3/
> http://www.emacswiki.org/emacs/mon-boxcutter.el


From the el above file:

--8<---------------cut here---------------start------------->8---
;; boxcutter.exe is one of the few (perhaps only) screenshot utility
;; that can be called from the command line AND has a compatible license
;; LGPL. This is important, esp. on w32. Many w32 graphics apps lack
;; FOSS licensing...
--8<---------------cut here---------------end--------------->8---

>
> Disclaimer: I haven't tried it. This is purely for my link karma.
>
> Jambunathan K.

-- 

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

* Re: insert picture feature request.
  2011-05-04 13:19       ` Russell Adams
@ 2011-05-07 21:33         ` Mark S.
  2011-05-08  4:29           ` Aankhen
  2011-05-25  9:00           ` Stinky Wizzleteet
  0 siblings, 2 replies; 18+ messages in thread
From: Mark S. @ 2011-05-07 21:33 UTC (permalink / raw)
  To: Russell Adams; +Cc: emacs-orgmode

This is very close ... I think. The problem is that the file name needs to be formatted for Windows. Currently its formatted  using unix style forward slashes. The file name that is passed to irfan in the call process needs to be formatted with Windows style backslashes. Without this fix, irfan will complain that it doesn't recognize the file type. In other languages I could figure out how to do the replace sequence, but it would take me awhile in lisp. Is there a quick fix?

Thanks!
Mark

--- On Wed, 5/4/11, Russell Adams <RLAdams@AdamsInfoServ.Com> wrote:

> From: Russell Adams <RLAdams@AdamsInfoServ.Com>
> Subject: Re: [O] insert picture feature request.
> To: "Rainer Stengele" <rainer.stengele@diplan.de>
> Date: Wednesday, May 4, 2011, 6:19 AM
> On Wed, May 04, 2011 at 12:01:53PM
> +0200, Rainer Stengele wrote:
> 
> > i_view32.exe /capture=2
> /convert=c:\capture_$U(%d%m%Y_%H%M%S).jpg
> 
> (defun org-screenshot ()
>   "Take a screenshot into a time stamped
>    unique-named file in the same directory
> as
>    the org-buffer and insert a link to this
> file."
>   (interactive)
>   (setq filename
>         (concat
>          (make-temp-name
>           (concat
> (buffer-file-name)
>                
>   "_"
>                
>   (format-time-string
>                
>    "%Y%m%d_%H%M%S_")) ) ".png"))
>   (call-process "i_view32.exe" nil nil nil
>                
> "/capture=2" (concat "/convert=" filename) )
>   (insert (concat "[[" filename "]]"))
>   (org-display-inline-images))
> 
> Does that work? Elisp is formatting the filename based on
> the Org
> buffer you're in and adding a timestamp.
> 
> ------------------------------------------------------------------
> Russell Adams           
>                 RLAdams@AdamsInfoServ.com
> 
> PGP Key ID:     0x1160DCB3   
>        http://www.adamsinfoserv.com/
> 
> Fingerprint:    1723 D8CA 4280 1EC9 557F 
> 66E8 1154 E018 1160 DCB3
> 
>

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

* Re: insert picture feature request.
  2011-05-07 21:33         ` Mark S.
@ 2011-05-08  4:29           ` Aankhen
  2011-05-08 16:28             ` Mark S.
  2011-05-25  9:00           ` Stinky Wizzleteet
  1 sibling, 1 reply; 18+ messages in thread
From: Aankhen @ 2011-05-08  4:29 UTC (permalink / raw)
  To: Mark S., Russell Adams, emacs-orgmode

Hullo,

On Sun, May 8, 2011 at 03:03, Mark S. <throaway@yahoo.com> wrote:
> This is very close ... I think. The problem is that the file name needs to be formatted for Windows. Currently its formatted  using unix style forward slashes. The file name that is passed to irfan in the call process needs to be formatted with Windows style backslashes. Without this fix, irfan will complain that it doesn't recognize the file type. In other languages I could figure out how to do the replace sequence, but it would take me awhile in lisp. Is there a quick fix?

I believe ‘convert-standard-filename’ should do it:

,----
| (defun org-screenshot ()
|  "Take a screenshot into a time stamped
|   unique-named file in the same directory as
|   the org-buffer and insert a link to this file."
|  (interactive)
|  (setq filename
|        (convert-standard-filename
|         (concat
|          (make-temp-name
|           (concat (buffer-file-name)
|                   "_"
|                   (format-time-string
|                    "%Y%m%d_%H%M%S_")) ) ".png")))
|  (call-process "i_view32.exe" nil nil nil
|                "/capture=2" (concat "/convert=" filename) )
|  (insert (concat "[[" filename "]]"))
|  (org-display-inline-images))
`----

Seems to work here, although I’m unable to get the resulting image to
display inline.

Aankhen

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

* Re: insert picture feature request.
  2011-05-08  4:29           ` Aankhen
@ 2011-05-08 16:28             ` Mark S.
  2011-05-08 18:51               ` Mark S.
  0 siblings, 1 reply; 18+ messages in thread
From: Mark S. @ 2011-05-08 16:28 UTC (permalink / raw)
  To: emacs-orgmode

Thanks Aankhen.

That seems to have fixed the technical problem. Unfortunately, because of the way irfan works, all I was able to get pictures of was the emacs screen! People with lots of screen real-estate can have emacs and their target application up at the same time, but that doesn't work on my older screen.

So instead, I have the code grab whatever is in the clipboard and use it. Then if I want a screen capture, I can use whatever tool is available. Surfulator has a really nice free screen capture. Also, with this approach I can right-click on images in the browser, click "copy image" and use those images directly. 

As for viewing, the only way I know is to export to HTML. Ctl-c e b is quick. I vaguely remember that there is a way to actually view images inline in Emacs, but its not portable or something.

Modified code below.

Thanks!
Mark

(defun org-screenshot ()
  "Take a screenshot into a time stamped
   unique-named file in the same directory as
   the org-buffer and insert a link to this file."
  (interactive)
  (setq filename
       (convert-standard-filename
        (concat
         (make-temp-name
          (concat (buffer-file-name)
                  "_"
                  (format-time-string
                   "%Y%m%d_%H%M%S_")) ) ".png")))
  (call-process "C:\\Program Files\\IrfanView\\i_view32.exe" nil nil nil
                "/clippaste" (concat "/convert=" filename) )
  (insert (concat "[[" filename "]]"))
  (org-display-inline-images))


--- On Sat, 5/7/11, Aankhen wrote:

> Subject: Re: [O] insert picture feature request.
> 
> I believe ‘convert-standard-filename’ should do it:
> 
> ,----
> | (defun org-screenshot ()
> |  "Take a screenshot into a time stamped
> |   unique-named file in the same directory
> as
> |   the org-buffer and insert a link to this
> file."
> |  (interactive)
> |  (setq filename
> |        (convert-standard-filename
> |         (concat
> |          (make-temp-name
> |           (concat
> (buffer-file-name)
> |               
>    "_"
> |               
>    (format-time-string
> |               
>     "%Y%m%d_%H%M%S_")) ) ".png")))
> |  (call-process "i_view32.exe" nil nil nil
> |               
> "/capture=2" (concat "/convert=" filename) )
> |  (insert (concat "[[" filename "]]"))
> |  (org-display-inline-images))
> `----
> 
> Seems to work here, although I’m unable to get the
> resulting image to
> display inline.
> 
> Aankhen
>

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

* Re: insert picture feature request.
  2011-05-08 16:28             ` Mark S.
@ 2011-05-08 18:51               ` Mark S.
  2011-05-08 23:11                 ` Nick Dokos
  0 siblings, 1 reply; 18+ messages in thread
From: Mark S. @ 2011-05-08 18:51 UTC (permalink / raw)
  To: emacs-orgmode

Additional thought. Having all those pngs in the main directory will get messy. I would like to put them in a sub-directory like "images". But there doesn't seem to be an easy way to insert that into (buffer-file-name). I've looked, but can't seem to be a variable that just holds the current buffer directory. Where would I start?

Thanks!
Mark

--- On Sun, 5/8/11, Mark S. <throaway@yahoo.com> wrote:

> From: Mark S. <throaway@yahoo.com>
> Subject: Re: [O] insert picture feature request.
> To: emacs-orgmode@gnu.org
> Date: Sunday, May 8, 2011, 9:28 AM
> Thanks Aankhen.
> 
> That seems to have fixed the technical problem.
> Unfortunately, because of the way irfan works, all I was
> able to get pictures of was the emacs screen! People with
> lots of screen real-estate can have emacs and their target
> application up at the same time, but that doesn't work on my
> older screen.
> 
> So instead, I have the code grab whatever is in the
> clipboard and use it. Then if I want a screen capture, I can
> use whatever tool is available. Surfulator has a really nice
> free screen capture. Also, with this approach I can
> right-click on images in the browser, click "copy image" and
> use those images directly. 
> 
> As for viewing, the only way I know is to export to HTML.
> Ctl-c e b is quick. I vaguely remember that there is a way
> to actually view images inline in Emacs, but its not
> portable or something.
> 
> Modified code below.
> 
> Thanks!
> Mark
> 
> (defun org-screenshot ()
>   "Take a screenshot into a time stamped
>    unique-named file in the same directory
> as
>    the org-buffer and insert a link to this
> file."
>   (interactive)
>   (setq filename
>        (convert-standard-filename
>         (concat
>          (make-temp-name
>           (concat
> (buffer-file-name)
>                
>   "_"
>                
>   (format-time-string
>                
>    "%Y%m%d_%H%M%S_")) ) ".png")))
>   (call-process "C:\\Program
> Files\\IrfanView\\i_view32.exe" nil nil nil
>                
> "/clippaste" (concat "/convert=" filename) )
>   (insert (concat "[[" filename "]]"))
>   (org-display-inline-images))
> 
> 
> --- On Sat, 5/7/11, Aankhen wrote:
> 
> > Subject: Re: [O] insert picture feature request.
> > 
> > I believe ‘convert-standard-filename’ should do
> it:
> > 
> > ,----
> > | (defun org-screenshot ()
> > |  "Take a screenshot into a time stamped
> > |   unique-named file in the same directory
> > as
> > |   the org-buffer and insert a link to this
> > file."
> > |  (interactive)
> > |  (setq filename
> > |        (convert-standard-filename
> > |         (concat
> > |          (make-temp-name
> > |           (concat
> > (buffer-file-name)
> > |               
> >    "_"
> > |               
> >    (format-time-string
> > |               
> >     "%Y%m%d_%H%M%S_")) ) ".png")))
> > |  (call-process "i_view32.exe" nil nil nil
> > |               
> > "/capture=2" (concat "/convert=" filename) )
> > |  (insert (concat "[[" filename "]]"))
> > |  (org-display-inline-images))
> > `----
> > 
> > Seems to work here, although I’m unable to get the
> > resulting image to
> > display inline.
> > 
> > Aankhen
> >
> 
>

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

* Re: insert picture feature request.
  2011-05-08 18:51               ` Mark S.
@ 2011-05-08 23:11                 ` Nick Dokos
  2011-05-09  2:05                   ` Mark S.
  0 siblings, 1 reply; 18+ messages in thread
From: Nick Dokos @ 2011-05-08 23:11 UTC (permalink / raw)
  To: Mark S.; +Cc: nicholas.dokos, emacs-orgmode

Mark S. <throaway@yahoo.com> wrote:

> Additional thought. Having all those pngs in the main directory will
> get messy. I would like to put them in a sub-directory like
> "images". But there doesn't seem to be an easy way to insert that into
> (buffer-file-name). I've looked, but can't seem to be a variable that
> just holds the current buffer directory. Where would I start?
> 

C-h f file-name-directory <RET>
C-h f file-name-nondirectory <RET>

Nick

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

* Re: insert picture feature request.
  2011-05-08 23:11                 ` Nick Dokos
@ 2011-05-09  2:05                   ` Mark S.
  2011-05-16  8:32                     ` Aankhen
  0 siblings, 1 reply; 18+ messages in thread
From: Mark S. @ 2011-05-09  2:05 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

Thanks Nick!

Revised code below with your help. Note that I've changed the name of function to reflect the fact that we're using the clipboard for the shot. Also, needed "file:" in the insert name for the inline images to view directly.

Note to Aankhen: To get inline images to work, you need to install the PNG and JPEG libraries from http://gnuwin32.sourceforge.net/ . Then put the resulting C:...gnuwin32/bin directory in your windows system path. Maybe everyone here already knew this, but I had to spend a bit of time to work it out.

Thanks!
Mark


(defun org-clipshot ()
  "Take a screenshot into a time stamped
   unique-named file in the same directory as
   the org-buffer and insert a link to this file."
  (interactive)
  (setq filename
       (convert-standard-filename
        (concat
         (make-temp-name
          (concat 
;;                  (buffer-file-name)
                 (file-name-directory (buffer-file-name))
                  "images/"
                 (file-name-nondirectory (buffer-file-name))
                  "_"
                  (format-time-string
                   "%Y%m%d_%H%M%S_")) ) ".png")))
  (call-process "C:\\Program Files\\IrfanView\\i_view32.exe" nil nil nil
                "/clippaste" (concat "/convert=" filename) )
  (insert (concat "[[file:" filename "]]"))
  (org-display-inline-images))




--- On Sun, 5/8/11, Nick Dokos <nicholas.dokos@hp.com> wrote:

> From: Nick Dokos <nicholas.dokos@hp.com>
> Subject: Re: [O] insert picture feature request.
> To: "Mark S." <throaway@yahoo.com>
> Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org
> Date: Sunday, May 8, 2011, 4:11 PM
> Mark S. <throaway@yahoo.com>
> wrote:
> 
> > Additional thought. Having all those pngs in the main
> directory will
> > get messy. I would like to put them in a sub-directory
> like
> > "images". But there doesn't seem to be an easy way to
> insert that into
> > (buffer-file-name). I've looked, but can't seem to be
> a variable that
> > just holds the current buffer directory. Where would I
> start?
> > 
> 
> C-h f file-name-directory <RET>
> C-h f file-name-nondirectory <RET>
> 
> Nick
> 
> 

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

* Re: insert picture feature request.
  2011-05-09  2:05                   ` Mark S.
@ 2011-05-16  8:32                     ` Aankhen
  0 siblings, 0 replies; 18+ messages in thread
From: Aankhen @ 2011-05-16  8:32 UTC (permalink / raw)
  To: Mark S., nicholas.dokos, Org mailing list

Sorry for the late response!  I forgot about this thread.

On Mon, May 9, 2011 at 07:35, Mark S. <throaway@yahoo.com> wrote:
> Note to Aankhen: To get inline images to work, you need to install the PNG and JPEG libraries from http://gnuwin32.sourceforge.net/ . Then put the resulting C:...gnuwin32/bin directory in your windows system path. Maybe everyone here already knew this, but I had to spend a bit of time to work it out.

My local copy of Emacs has all the libraries in place.  The problem
seems to be the path: the directory has spaces in it, and the final
call is:

  i_view32.exe /capture=2 "/convert=Z:/Foo bar/baz.png"

In other words, the entire argument is quoted rather than just the
path.  I fixed this by only passing the file name, as it runs in the
same directory.  Dunno whether there’s a way to disable quoting for
part of an argument.

Aankhen

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

* Re: insert picture feature request.
  2011-05-07 21:33         ` Mark S.
  2011-05-08  4:29           ` Aankhen
@ 2011-05-25  9:00           ` Stinky Wizzleteet
  1 sibling, 0 replies; 18+ messages in thread
From: Stinky Wizzleteet @ 2011-05-25  9:00 UTC (permalink / raw)
  To: emacs-orgmode

Hi All,


I've looked into this as well and I found the following:

On X the "import" function from imagemagick is very versatile. It can 
capoture the entire screen, or a rectangle on the screen selected by the 
user, it is possible to retain that rectangle for subsequent grabs in 
the session by catching the verbose output of the import command.

On windows however, the import command exists in the imagemagick windows 
binaries, but it only grabs X sessions, not an MSwin screen, therefor it 
is useless.
But, among all the screengrabutils for window out there I found 
something that could be of interest here, the Python PIL package allows 
for screengrabs *and* for clipboard dumping:

########## start python src
import os
import sys
import time
import Image
import ImageGrab
def ensure_dir(f):
     d = os.path.dirname(f)
     if not os.path.exists(d):
         os.makedirs(d)
#---------------------------------------------------------
#User Settings:
SaveDirectory=r'c:/Screengrabs'
#taking a screenshot is as simple as:
#img=ImageGrab.grab()

im= ImageGrab.grabclipboard()
savename='ScreenShot_'+time.strftime("%y%m%d_%H_%M_%S")+'.png'
saveas=os.path.join(SaveDirectory,savename)
print "saveas: %s" %saveas
ensure_dir(saveas)
if isinstance(im, Image.Image):
     im.save(saveas)
     print "image saved to %s"% (saveas)
else:
     print "not image in clipboard"

########## end python src

This could be extended to be multiplatform, as I understand that PIL's 
imagegrab does not work on X11 (at least it does not on my n900)

My 2 cents here..

wzzl.
On 7-5-2011 23:33, Mark S. wrote:
> This is very close ... I think. The problem is that the file name needs to be formatted for Windows. Currently its formatted  using unix style forward slashes. The file name that is passed to irfan in the call process needs to be formatted with Windows style backslashes. Without this fix, irfan will complain that it doesn't recognize the file type. In other languages I could figure out how to do the replace sequence, but it would take me awhile in lisp. Is there a quick fix?
>
> Thanks!
> Mark
>
> --- On Wed, 5/4/11, Russell Adams<RLAdams@AdamsInfoServ.Com>  wrote:
>
>> From: Russell Adams<RLAdams@AdamsInfoServ.Com>
>> Subject: Re: [O] insert picture feature request.
>> To: "Rainer Stengele"<rainer.stengele@diplan.de>
>> Date: Wednesday, May 4, 2011, 6:19 AM
>> On Wed, May 04, 2011 at 12:01:53PM
>> +0200, Rainer Stengele wrote:
>>
>>> i_view32.exe /capture=2
>> /convert=c:\capture_$U(%d%m%Y_%H%M%S).jpg
>>
>> (defun org-screenshot ()
>>    "Take a screenshot into a time stamped
>>     unique-named file in the same directory
>> as
>>     the org-buffer and insert a link to this
>> file."
>>    (interactive)
>>    (setq filename
>>          (concat
>>           (make-temp-name
>>            (concat
>> (buffer-file-name)
>>
>>    "_"
>>
>>    (format-time-string
>>
>>     "%Y%m%d_%H%M%S_")) ) ".png"))
>>    (call-process "i_view32.exe" nil nil nil
>>
>> "/capture=2" (concat "/convert=" filename) )
>>    (insert (concat "[[" filename "]]"))
>>    (org-display-inline-images))
>>
>> Does that work? Elisp is formatting the filename based on
>> the Org
>> buffer you're in and adding a timestamp.
>>
>> ------------------------------------------------------------------
>> Russell Adams
>>                  RLAdams@AdamsInfoServ.com
>>
>> PGP Key ID:     0x1160DCB3
>>         http://www.adamsinfoserv.com/
>>
>> Fingerprint:    1723 D8CA 4280 1EC9 557F
>> 66E8 1154 E018 1160 DCB3
>>
>>
>
>

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

end of thread, other threads:[~2011-05-25 14:43 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-02 12:42 insert picture feature request Piter_
2011-05-02 13:28 ` Russell Adams
2011-05-02 14:23   ` brian powell
2011-05-02 23:34     ` Piter_
2011-05-04  0:37   ` Mark S.
2011-05-04 10:01     ` Rainer Stengele
2011-05-04 12:38       ` Jambunathan K
2011-05-04 14:10         ` Jambunathan K
2011-05-04 13:19       ` Russell Adams
2011-05-07 21:33         ` Mark S.
2011-05-08  4:29           ` Aankhen
2011-05-08 16:28             ` Mark S.
2011-05-08 18:51               ` Mark S.
2011-05-08 23:11                 ` Nick Dokos
2011-05-09  2:05                   ` Mark S.
2011-05-16  8:32                     ` Aankhen
2011-05-25  9:00           ` Stinky Wizzleteet
2011-05-04 13:28       ` Rainer Stengele

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.