1

I've recently taken to creating imges and sharing them. It's quite fun to be able to put things straight on the clipboard and share them rather than having to mess with files. Some tools like, Spectacle have features for this and I've hacked up my own using ffmpeg -f x11grab when they don't exist xclip -i -t image/png. Now I'm dabbling with a little image editing with GIMP.

What I would ideally like to do would me to export an image directly from GIMP to the clipboard - but I could work out a way to do this. I would just take a screenshot but there is a dashed line around the image.

Copying layers with Ctrl + C seems to work so one work around is to flatten copy the layers and undo. Also there is gimp-console, so I could probably do anything I want with that - but it feels a bit like using powertools to hang a poster.

Progress

I found this Stack Overflow answer.

It looks like script-fu has no access to the clipboard. It can however export to files. I got this far with script-fu and the approach would work using gimp --batch to run the script. But the number of arguments I need to specify for file-png-save put me off. I wonder if pythonfu has default parameters.

(if (not (= (vector-length (cadr (gimp-image-list))) 1)) (error "More than one image"))
(define image (vector-ref (cadr (gimp-image-list)) 0))
(define copied-image (car (gimp-image-duplicate image)))
(define flat-layer (gimp-image-flatten copied-image))
(file-png-save...)

Pythonfu

I switched to Pythonfu. Unforunately, pythonfu was missing from GIMP. I fixed this by switching to GIMP 3's AppImage - I needed to change the theme to the system default for the fonts in the Python console to be readable.

The following snippet works from the pythonfu console:

image, = Gimp.get_images()
copy = image.duplicate()
copy.flatten()
Gimp.file_save(Gimp.RunMode.NONINTERACTIVE, copy, Gio.File.new_for_path(str(Path.home() / "tmp" / "gimp_clip.png")))
subprocess.check_call(["xclip", "-i", str(path), "-selection", "CLIPBOARD", "-t", "image/png"])
copy.delete()

3 Answers 3

2
  • Flatten image (Ctrl+M), Select All (Ctrl+A), Copy (Ctrl+C), (=> image in clipboard)
  • Then Undo (Ctrl+Z) - to "unflatten".

What more is there?
What other do you expect?

If you do not flatten the image, then I'm not sure any other software can interpret what there possibly is in the clipboard; i.e. I'd expect a Gimp-internal data format.

1
  • A single shortcut or command to do it because I intend to do it quite often. C-M, C-C C-Z isn't too bad. Commented Apr 29, 2025 at 21:10
1

If you have Windows 10 or 11 it's very easy to capture an area of choice: just hit WinKey-Shift-S

Then paste into any app.

2
  • Similar shortcut-keys exists in not only "the Last Lost OS". For Ubuntu, Settings > Keyboard > has an option to "customize shortcut keys", there is also an option to list the present existing ones. Commented Apr 30, 2025 at 18:06
  • uhh... Ubuntu: hit Print-Screen on the keyboard. Commented May 1, 2025 at 5:51
1

Using Flameshot would be the Linux/cross-system way of doing it with the screenshot method.

Use its region capture capability, which is available on PrtSc by default, to capture the area around your working area:

Flameshot region capture

You can drag the corners to match the content borders in case you miss them first time.

Note: this and other similar solutions, e.g. the Windows one, require the images to be smaller than your resolution, of course. You'd need to do a scrolling capture otherwise, but Flameshot doesn't support it currently. Not sure about Linux alternatives that have it, but on Windows e.g. ShareX has.

3
  • 1
    Ubuntu linux 24.04: Hold Shift hit PrintScreen, select the frame, hit Enter Commented May 1, 2025 at 5:52
  • How do I avoid the dotted line (besides accuracy) Commented May 2, 2025 at 0:26
  • Not sure what you mean. The line ofc isn't part of the results, it's just there to help with selection. Why do you want to avoid it? Commented May 2, 2025 at 10:08

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.