Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create screenshot from region #154

Closed
parkpaya opened this issue Jun 24, 2020 · 3 comments · Fixed by #191
Closed

Create screenshot from region #154

parkpaya opened this issue Jun 24, 2020 · 3 comments · Fixed by #191
Labels
feature New features

Comments

@parkpaya
Copy link

parkpaya commented Jun 24, 2020

Short summary
Trying to take screenshot on specific region of screen but still can't figure how

Detailed question
What expected

const {  Region ,ImageWriter,ScreenAction} = require("@nut-tree/nut-js");
ImageWriter.store(new ScreenAction.grabScreenRegion(new Region(x,y,w,h)),"myImage.png");

but get an error

@parkpaya
Copy link
Author

parkpaya commented Jun 24, 2020

OK, I figure it out now.

const regionCapture = async (selectedRegion,outputFilename) => {
  var regionImage =  await screen.vision.grabScreenRegion(selectedRegion);
  screen.vision.saveImage(regionImage,outputFilename);
};

regionCapture(new Region(x,y,w,h),"myImage.png");

@s1hofmann
Copy link
Member

Hi @parkpaya,

functionality to capture screen regions is indeed missing on the screen public interface.
Since you already dug into it, want to contribute? Would be more than happy about a PR

@svettwer
Copy link
Contributor

svettwer commented Dec 4, 2020

I recently worked with the workaround proposed by @parkpaya. It works great. 👍 It's a little ugly, because you have to grab deep into the dists for the import but it works.

As I assume, I'm not the only person who requires that feature, I'll reopen this issue and alter the public api as you suggested @s1hofmann.

@svettwer svettwer reopened this Dec 4, 2020
@svettwer svettwer changed the title Trying to take screenshot on specific region of screen but still can't figure how Create screenshot from region Dec 4, 2020
@s1hofmann s1hofmann added the feature New features label Dec 4, 2020
s1hofmann added a commit that referenced this issue Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants