Score:0

How can I insert an image into the clipboard using a terminal or bash script?

cn flag

I'm making a custom script that uses ImageMagick to take screenshots because I deleted the original application and wanted to do a custom one.

#! /bin/sh.
cd magickScreenshots/
ls -v | cat -n | while read n f; do mv -n "$f" "$n.jpg"; done 
import /home/alnexus/magickScreenshots/screenshot.jpg -quality 100 -trim

What that does is, it goes into the magickScreenshots folder, then renames everything to numbers, and it then uses ImageMagick to take a screenshot (I have to select an area for it to screenshot). The problem is, it only saves the image as screenshot.jpg in that folder (by the way the second line is just so that it renames all files and the new screenshot.jpg doesn't replace the old one, I want to keep all screenshots every session, they all get deleted when the computer starts up). I want to make it so that the screenshot.jpg file is automatically inserted into my clipboard. I tried some stuff but they all only copied the directory from the image, not the image itself (I had used the xclip command only). I've searched a lot and nothing worked, I even tried xclip-copyfile and it didn't seem to work, though I didn't mess with it very much

EDIT

I tried xclip -selection clipboard -t image/png ~/magickScreenshots/screenshot.jpg and it did work on WhatsApp Web, but not on the Discord Desktop Linux app :(

bac0n avatar
cn flag
its a image/jpeg not image/png
i deleted system32 help avatar
cn flag
using image/jpg doesn't work at all. Only image/png
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.