1

I want to take a screenshot of whole screen in python which is doable(feasible) to me. But if i want to take screenshot of a desired clipped area like the picture shown below means first of all, user should select(clip) a region using mouse pointer and then take screenshot of that area. So i want to say that how to clip a portion of an image in a clipboard?

NOTE: I have found some packages like "clipboard" and "pyperclip" but i couldn't understand how to clip an image? Help me

I got a code but it shows to clip only text. What modifications should be made in it to clip a desired area of an image.

import clipboard
clipboard.copy("abc") 
text = clipboard.paste() 
print(text)

enter image description here

Tech Learner
  • 241
  • 3
  • 12

1 Answers1

-2

I would find a python module that allowed you to edit image files, or use a binding to an external program. A tool like pyperclip will enable you to get at the image in python, you will then have to edit the image yourself using a module or something else.

Ratto
  • 24
  • 1
  • please explain with the example. – Tech Learner Oct 05 '17 at 11:19
  • If you give me some of your code I'll be able to show you – Ratto Oct 05 '17 at 11:25
  • 2. you're copying text into the clipboard and not an image – Ratto Oct 05 '17 at 11:33
  • dear it's obvious and above example is all about clipping and showing that text. Now if you know, how to clip an image, then give me example. And i have explained a bit given example as well still you are posting a comment like dumb. If you do not know the answer, then do not comment. – Tech Learner Oct 05 '17 at 11:34
  • 1
    'only handles plain text for now' is what it says in pyperclib documentation, which is what clipboard is based on. [Here](https://stackoverflow.com/questions/7045264/how-do-i-read-a-jpg-or-png-from-the-windows-clipboard-in-python-and-vice-versa) they use PIL, which seems to be able to get images directly from the (Windows) clipboard. – Jeronimo Oct 05 '17 at 12:24
  • but firstly i have to set the image in clipboard. So tell me how to clip a portion of an image in a clipboard? @Jeronimo – Tech Learner Oct 05 '17 at 22:55
  • Does it matter? Why not take the whole image and clip it yourself? You may even put the clipped image back into the clipboard, if you want it to be available there for the user later on. It's not clear to me what exactly you'd like to achieve. – Jeronimo Oct 06 '17 at 08:40