termux-api icon indicating copy to clipboard operation
termux-api copied to clipboard

Ability to copy image files to clipboard

Open Juhan280 opened this issue 1 year ago • 7 comments

Feature description termux-clipboard-set can copy text into clipboard. But if we pass an image file, nothing happens.

I would like to be able to copy image files into android clipboard.

Reference implementation

All the major browsers can copy image to clipboard. Screenshot_20240903-012028_Brave

Juhan280 avatar Sep 02 '24 19:09 Juhan280

Is anyone working in this issue?

ajay-vishnu avatar Oct 07 '24 19:10 ajay-vishnu

Browsers allows you to copy images but can you tell where do you paste these images

tathastu871 avatar Oct 14 '24 00:10 tathastu871

In the DMs mainly and other things that I can't think of from the top of my head.

ajay-vishnu avatar Oct 14 '24 03:10 ajay-vishnu

Convert Bitmap to blob Get contentUri to blob use clipData.newUri

tathastu871 avatar Oct 14 '24 03:10 tathastu871

Convert Bitmap to blob Get contentUri to blob use clipData.newUri

Sorry, I don't quite understand this. Can you explain it a bit further or point me to somewhere i can read more?

Juhan280 avatar Oct 15 '24 09:10 Juhan280

@Grimler91 Cant you add support for clipboatdManger setNew Uri content provider from termux shared fails

Need to converr images to

content://media/external/images/media/171412

and then setUri on clipboard

Theres is app called com.slash.clipboard on play stotr that can copy images it had copy activity that can be trigger using intent but it cannot handle fails fot termux content provider

If using files app i select share image and intercept intent and get content://media/external/images/media/171412

then from termux am start -n content://media/external/images/media/171412

am start -n com.slash.clipboard/com.slash.clipboard.CopyActivity -a android.intent.action.SEND -t image/* --eu android.intent.extra.STREAM content://media/external/images/media/171412 It does work to copy image to clipbaord

But file provider from termux content://com.termux.sharedfiles/storage/emulated/0/DCIM/Camera/20241021_204401.jpgapp cannot handle these and fails

tathastu871 avatar Oct 23 '24 04:10 tathastu871

Convert Bitmap to blob Get contentUri to blob use clipData.newUri

Sorry, I don't quite understand this. Can you explain it a bit further or point me to somewhere i can read more?

That requires java code for modification in libtermux api file

Till Them best you can do is install termuxGUI plugin and its python dependencu

its utility called termux-gui-view image.jpg it opens images in floating popup that you can fullscreen and also it automatically closes after 3or5 seconds within that you screenshot and on samsing phones and many other screenshoting adds images to keybord clipboard

tathastu871 avatar Oct 23 '24 16:10 tathastu871