hluk / CopyQ

Clipboard manager with advanced features
GNU General Public License v3.0
8.47k stars 436 forks source link

Copy/Paste multiple images? #2456

Open waseemv opened 11 months ago

waseemv commented 11 months ago

Hi,

Is there a way to copy and paste multiple images? We can do that for text items, but it doesn't work for images..

There is a related comment here: https://github.com/hluk/CopyQ/issues/597#issuecomment-265170680 But this also does not work for multiple images (but does work for text).

Thanks.

hluk commented 11 months ago

I don't know if there is a clipboard format that enables passing multiple image data. Do you know? Which apps support pasting multiple images?

hluk commented 11 months ago

You can try the following command which adds Paste All to menu/toolbar (and triggers on Enter key) to paste selected items one by one (here is how to add the command to CopyQ):

[Command]
Command="
    copyq:
    const sel = ItemSelection().current();
    for ( index = 0; index < sel.length; ++index) {
       const item = sel.itemAtIndex(index);
       copy(item);
       hide();
       paste();
    }"
Icon=\xf0ea
InMenu=true
Name=Paste All
Shortcut=return, enter
waseemv commented 11 months ago

I don't know if there is a clipboard format that enables passing multiple image data. Do you know? Which apps support pasting multiple images?

Hi dear hluk, Thanks for looking into this.

Yes, I know one program that supports pasting multiple images, it's called Ditto. You can select multiple images, then Special Paste -> Multiple Images Vertically It will paste all in one go (not one by one).

image

hluk commented 11 months ago

What formats does Ditto put into clipboard? Does it create one big image? If so, it is probably not a good idea to do that in CopyQ - better use another utility to "concatenate" the images.

waseemv commented 11 months ago

What formats does Ditto put into clipboard? Does it create one big image? If so, it is probably not a good idea to do that in CopyQ - better use another utility to "concatenate" the images.

Hi hluk,

No, it doesn't create a new/combined image in the clipboard. But when I paste, all images appear in one go:

It uses this format: CF DIB, 1736996

image

hluk commented 11 months ago

Can you check the clipboard formats from CopyQ? You can do that by pressing Ctrl+Shift+C.

waseemv commented 11 months ago

Can you check the clipboard formats from CopyQ? You can do that by pressing Ctrl+Shift+C.

Sure, here's what I have:

image

hluk commented 11 months ago

No, it doesn't create a new/combined image in the clipboard.

I can see Ditto creates a big bitmap with all the images: https://github.com/sabrogden/Ditto/blob/195166bf932f409cad3c93b1ec78e0af66fbcf4b/BitmapHelper.cpp#L161

Maybe there is some trick to it I'm missing and which would perhaps only work on Windows anyways.

It is probably not something I would likely implement in CopyQ unless I need it.

waseemv commented 11 months ago

Thanks for looking into this, hluk

I see; I don't know the code, but what I meant was that it didn't put a new image in the clipboard, that I could see :)

So just two last things on this then:

  1. Even if you don't implement it, is this something I can add on my end, with a Command perhaps?

  2. The "Paste All" command that you shared above, is it the same as "Paste Selected" (Ctrl+Shift+Return)? I don't recall where I got the Paste Selected command from, but here's the code:

copyq: hide(); //focusPrevious();

var items = selectedItemsData(); for (var item of items.values()) { copy(item); paste(); copy('\n'); paste(); }

No, it doesn't create a new/combined image in the clipboard.

I can see Ditto creates a big bitmap with all the images: https://github.com/sabrogden/Ditto/blob/195166bf932f409cad3c93b1ec78e0af66fbcf4b/BitmapHelper.cpp#L161

Maybe there is some trick to it I'm missing and which would perhaps only work on Windows anyways.

It is probably not something I would likely implement in CopyQ unless I need it.

hluk commented 11 months ago

Even if you don't implement it, is this something I can add on my end, with a Command perhaps?

Sure, but it is possible that you would need some other utility that can store the multiple images in clipboard - it may not be possible from CopyQ by itself.

The "Paste All" command that you shared above, is it the same as "Paste Selected" ?

Yes, it is basically the same.

waseemv commented 11 months ago

Thanks hluk,

I don't have the skill to do it myself, so no worries :) But if in the future you feel like it, please do re-visit it to see if CopyQ can have this, as an optional Command/feature.

Even if you don't implement it, is this something I can add on my end, with a Command perhaps?

Sure, but it is possible that you would need some other utility that can store the multiple images in clipboard - it may not be possible from CopyQ by itself.

The "Paste All" command that you shared above, is it the same as "Paste Selected" ?

Yes, it is basically the same.