RSS/Atom feed Twitter
Site is read-only, email is disabled

Copy png to clipboard via gimp-console

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

Copy png to clipboard via gimp-console pUlI 14 Feb 11:03
  Copy png to clipboard via gimp-console Ofnuts 14 Feb 23:23
   Copy png to clipboard via gimp-console pUlI 15 Feb 17:33
pUlI
2017-02-14 11:03:10 UTC (about 7 years ago)

Copy png to clipboard via gimp-console

Hi all,

I would like to copy a png file to the clipboard using (for instance):

gimp-console-2.8 -i -d -f -b '(png-copy "snapshot1.png")' -b '(gimp-quit 0)'

The scheme code I have for the same is attached "png-copy.scm"

However, it does not work as expected. Only an empty "carriage return" newline is copied to the clipboard. Can someone point out what needs to be changed in my scheme file?

Thanks for your help!

Best regards, pUlI

png-copy.scm:

(define (png-copy pattern) (let* (
(filelist (cadr (file-glob pattern 1))) )
(while (not (null? filelist))
(begin
(catch ()
(let* (
(filename (car filelist)) (image (car (file-png-load RUN-NONINTERACTIVE filename filename))) (drawablealpha (car (gimp-image-get-active-drawable image))) (gimp-selection-all image)
(gimp-edit-copy-visible drawablealpha) )
(begin
(gimp-selection-all image)
(gimp-edit-copy (car (gimp-image-get-active-layer image))) )
)
)
(set! filelist (cdr filelist)) )
)
)
)

Ofnuts
2017-02-14 23:23:19 UTC (about 7 years ago)

Copy png to clipboard via gimp-console

On 14/02/17 12:03, pUlI wrote:

Hi all,

I would like to copy a png file to the clipboard using (for instance):

gimp-console-2.8 -i -d -f -b '(png-copy "snapshot1.png")' -b '(gimp-quit 0)'

The scheme code I have for the same is attached "png-copy.scm"

However, it does not work as expected. Only an empty "carriage return" newline is copied to the clipboard. Can someone point out what needs to be changed in my scheme file?

Thanks for your help!

Best regards, pUlI

png-copy.scm:

(define (png-copy pattern) (let* (
(filelist (cadr (file-glob pattern 1))) )
(while (not (null? filelist))
(begin
(catch ()
(let* (
(filename (car filelist)) (image (car (file-png-load RUN-NONINTERACTIVE filename filename))) (drawablealpha (car (gimp-image-get-active-drawable image))) (gimp-selection-all image)
(gimp-edit-copy-visible drawablealpha) )
(begin
(gimp-selection-all image)
(gimp-edit-copy (car (gimp-image-get-active-layer image))) )
)
)
(set! filelist (cdr filelist)) )
)
)
)

Attachments:
* http://www.gimpusers.com/system/attachments/483/original/png-copy.scm

That can't work. Big objects such as images are not copied to the clipboard (on Linux and AFAIK also on Windows). When you copy an image the clipboard only contains a message that allows the receiving process to connect to the source process and get the data directly form it. In your case, since Gimp exits immediately after copying the data, the receiving process cannot connect to it.

Try this:

* Start another application (word processor) * Open an image in Gimp
* Copy to clipboard (Ctrl-A, Ctrl-C) * Back to the word processor: Ctrl-V to copy the image: it should work * Ctrl-V to copy the image a second time: it should work * Close the Gimp image window (but keep Gimp up) * Ctrl-V to copy the image a third time: it should work * Close Gimp completely
* Ctrl-V to copy the image a fourth time: it won't work, because Gimp is no longer here to service it.

On a side note, having batch process use the clipboard is treacherous; while they run you cannot do anything on your system since they could overwrite what you put in the clipboard.

pUlI
2017-02-15 17:33:42 UTC (about 7 years ago)

Copy png to clipboard via gimp-console

Thanks for the response. It was helpful!

That can't work. Big objects such as images are not copied to the clipboard (on Linux and AFAIK also on Windows). When you copy an image the clipboard only contains a message that allows the receiving process
to connect to the source process and get the data directly form it. In your case, since Gimp exits immediately after copying the data, the receiving process cannot connect to it.

Try this:

* Start another application (word processor) * Open an image in Gimp
* Copy to clipboard (Ctrl-A, Ctrl-C) * Back to the word processor: Ctrl-V to copy the image: it should work
* Ctrl-V to copy the image a second time: it should work * Close the Gimp image window (but keep Gimp up) * Ctrl-V to copy the image a third time: it should work * Close Gimp completely
* Ctrl-V to copy the image a fourth time: it won't work, because Gimp
is no longer here to service it.

On a side note, having batch process use the clipboard is treacherous; while they run you cannot do anything on your system since they could overwrite what you put in the clipboard.