CopyQ icon indicating copy to clipboard operation
CopyQ copied to clipboard

Copy/Paste multiple images?

Open waseemv opened this issue 1 year ago • 11 comments

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.

waseemv avatar Sep 08 '23 16:09 waseemv

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 avatar Sep 26 '23 11:09 hluk

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

hluk avatar Sep 26 '23 12:09 hluk

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

waseemv avatar Sep 26 '23 12:09 waseemv

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.

hluk avatar Sep 26 '23 13:09 hluk

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

waseemv avatar Sep 26 '23 13:09 waseemv

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

hluk avatar Sep 26 '23 13:09 hluk

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

Sure, here's what I have:

image

waseemv avatar Sep 26 '23 13:09 waseemv

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 avatar Sep 26 '23 17:09 hluk

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.

waseemv avatar Sep 26 '23 17:09 waseemv

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.

hluk avatar Sep 27 '23 14:09 hluk

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.

waseemv avatar Sep 27 '23 21:09 waseemv