termux / termux-api

Termux add-on app which exposes device functionality as API to command line programs.
https://f-droid.org/en/packages/com.termux.api/
2.34k stars 459 forks source link

Ability to copy image files to clipboard #705

Open Juhan280 opened 2 months ago

Juhan280 commented 2 months ago

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

ajay-vishnu commented 1 month ago

Is anyone working in this issue?

tathastu871 commented 1 month ago

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

ajay-vishnu commented 1 month ago

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

tathastu871 commented 1 month ago

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

Juhan280 commented 1 month ago

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?

tathastu871 commented 3 weeks ago

@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 commented 3 weeks ago

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