flameshot icon indicating copy to clipboard operation
flameshot copied to clipboard

[feature request] scan QR code from selected region

Open cdluminate opened this issue 6 years ago • 19 comments

It would be better if flameshot can scan QR code from the selected region, and put the decoded text to clipboard.

cdluminate avatar Apr 24 '19 11:04 cdluminate

Code reference: https://launchpad.net/qr-tools

cdluminate avatar Apr 24 '19 11:04 cdluminate

@cdluminate Your idea is good, I will achieve it. Thanks again.

holazt avatar Apr 30 '19 01:04 holazt

I think quirc is better. This library included to OpenCV.

data-man avatar Apr 30 '19 06:04 data-man

Flameshot is a screenshot tool. Adding QR grabber to it will look like making knife and flashlight in one tool. IMHO, that's not a good idea. Better to concentrate attention on actual bugs and issues.

greno4ka avatar May 06 '19 16:05 greno4ka

Ubuntu 20.04 can do this by following steps.

# install zbar-tools
sudo apt install zbar-tools

# qr-scan script
cat > qr-scan
#!/bin/bash

flameshot gui -r | zbarimg - | sed "s/^QR-Code://g" | xclip -selection clipboard 2>/dev/null
Ctrl+D

# add keyboard shortcut for qr-scan script

martianzhang avatar Sep 30 '21 14:09 martianzhang

Definitely would love this feature as integrated option in flameshot. Alternatively it might be a good feature to have something like a queue, which pipe the image - that was created - to any script we'd like to. In this case we simply could create an entry "qr-codeScanner" and put the zbarimg-stuff into it.

xstable avatar Jan 11 '22 09:01 xstable

@martianzhang I had modified your suggestion to be able to analyse any still taken image (which inside xclip) for qr-code:

#!/bin/bash
xclip -selection clipboard -t image/jpeg -o | zbarimg - | sed "s/^QR-Code://g" | xclip -selection clipboard 2>/dev/null 

In my case, I do add it straight to the Klipper (KDE) as action: image

image

xstable avatar Jan 11 '22 10:01 xstable

I think zbarimg - | sed "s/^QR-Code://g" can be replaced to zbarimg --raw -q.

data-man avatar Jan 11 '22 10:01 data-man

@xstable

Alternatively it might be a good feature to have something like a queue, which pipe the image we create to every script we like. In this case we simply could create an entry "qr-codeScanner" and put the zbarimg-stuff into it.

This is already possible since version 8 if I don't make mistake. You can use flameshot gui --raw to output to stdout and pipe it to whatever you want. Some months ago I wrote a blog post in which I used this for reading barcode:

https://mehrad.ai/posts/20210702-extracting-payment-info-in-rasterized-invoice/

mmahmoudian avatar Jan 11 '22 15:01 mmahmoudian

@mmahmoudian Ok, but I don't mean to create an own script which only use flameshot, I mean a section inside flameshot which do a predefined action based on the current made image.

For example there could be a button "A" for "Actions" and if you click on it, you can choose between the scripts you entered.

It's more handy in my opinion, as to have a shortcut on OS-Layer for each script, which finally use flameshot only internally. This way you all the time only open flameshot, but you are able to pipe the made image to every of the 1000000 ;) scripts you made. (Handy encapsulated below one single button in the flameshot-gui)

xstable avatar Jan 11 '22 15:01 xstable

@xstable there have been active discussions about adding plugin support to Flameshot. If you are interested, I suggest searching them in the issues and discussions and also join our Matrix room to know the most recent discussions over there (#flameshot-org:matrix.org)

Btw, you might want to take a look at https://codeberg.org/mehrad/dmenu_shot to see if you can adopt that for your workflow

mmahmoudian avatar Jan 11 '22 15:01 mmahmoudian

I think this would be a great idea, a button that scan and copy to clipboard image

stefanocudini avatar Jan 12 '22 19:01 stefanocudini

A temporary solution for anyone eager for this functionality:

If you have zbar and xclip installed, you can set up a keybind for this one-liner:

flameshot gui -r | zbarimg -1q --raw - | xclip -selection clipboard

This copies the QR code link decoded from the capture to your clipboard.

deron-dev avatar Mar 02 '23 17:03 deron-dev

I'm glad to see I'm not the only one who has had this idea, I'm just sorry it took me this long to think of it.

I'm also sad that no tools have implemented this yet that I have seen.

ghost avatar Sep 19 '24 07:09 ghost

For those on wayland, this seems to work (slight modification to @deron-dev's command):

flameshot gui -r | zbarimg -1q --raw - | wl-copy

The scanned QR output will be copied to clipboard, just like the original command.

arch-btw avatar Feb 10 '25 09:02 arch-btw

for the love of god PLEASE

sayore avatar Apr 25 '25 09:04 sayore

There are a lot of wanted features that are possible through command line piping.

  • Reading a QR code
  • Reading a 1D code
  • Doing OCR
  • special processing
  • special uploading
  • special scripts
  • AI stuff
  • ....

I would vote for a feature where we can create custom buttons to 'push the resulting image to a command-line prompt". This would make Flameshot exponentially more powerful for everyone.

phulstaert avatar Oct 14 '25 07:10 phulstaert

@phulstaert

I would vote for a feature where we can create custom buttons to 'push the resulting image to a command-line prompt". This would make Flameshot exponentially more powerful for everyone.

This is true, and in principal it should be easy for a plugin to do this. Basically all Flameshot plugin system should do is to pass the image to the plugin. After that the plugin can store it in a temp file and cat the file into the chain of pipes the user has specified.

At the moment our plugin system (#3661) can somewhat do that, but it still has some rough edges and the PR is not yet merged.

mmahmoudian avatar Oct 15 '25 00:10 mmahmoudian

@mmahmoudian

I'm new at the repository, so sorry if I'm talking nonsense, but I don't totally agree with this.

A plugin could do a load of different stuff. If you have a OCR or Barcode (1D/2D), you would expect there to be text in the clipboard, not an image. If you would have a plugin to convert the image to svg, it would also be text, but with image/svg+xml (if the clipboard has a content-type sort of thing) If you would have a prompt to push the image to an AI to make it cartoon-like, you would expect an image in the clipboard.

But if there are plugins, we should ask ourself: should flameshot check that the plugin does not return scripts or executable code (for security)?

And another thing is that plugins would have dependencies. How do we deal with this? Does it autoinstall them on debian and fedora distributions, of just a mention of them? How do we deal with errors (for example if a newer version of a dependancy is installed and not backwards compatible?)

And finally, not every plugin would be as fast as the current features. This would demand for a "please wait" 'modal', but maybe with a timeout if it should crash. Or -if possible- a progressbar if the plugin supports it.

I do agree that a quick and dirty implementation is possible, but for a professional product, it will take some time and thinking.

phulstaert avatar Oct 15 '25 07:10 phulstaert