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

Screenshots. #24

Closed
wants to merge 11 commits into from
Closed

Screenshots. #24

wants to merge 11 commits into from

Conversation

rhyek
Copy link

@rhyek rhyek commented Aug 1, 2017

Related: #13.
This is a work in progress. I need to know if this is the approach you were thinking of.

Basically:

await hpc.create(html, options) // pdf
await hpc.create(html, options, 'pdf') // pdf
await hpc.create(html, options, 'screenshot') // screenshot
await hpc.createPDF(html, options) // pdf
await hpc.createScreenshot(html, options) // screenshot

CreateOptions now has:

  screenshotOptions?: {
    /**
     * The options to pass to Chrome's Page.captureScreenshot.
     *
     * @type {ChromeCaptureScreenshotOptions}
     */
    captureScreenShotOptions?: CaptureScreenshotOptions;

    /**
     * The options to pass to Chrome's Emulation.setDeviceMetricsOverride.
     *
     * @type {DeviceMetricsOverrideOptions}
     */
    deviceMetrics?: DeviceMetricsOverrideOptions;

    /**
     * Wether to capture a full-page screenshot.
     *
     * @type {boolean}
     */
    fullPage?: boolean;
  };

@rhyek rhyek changed the title [WIP] Screenshots. Closes #13. [WIP] Screenshots. Aug 1, 2017
@codecov
Copy link

codecov bot commented Aug 1, 2017

Codecov Report

Merging #24 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #24   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      4    +1     
  Lines         108    157   +49     
  Branches       12     17    +5     
=====================================
+ Hits          108    157   +49
Impacted Files Coverage Δ
src/index.ts 100% <100%> (ø) ⬆️
src/Generators.ts 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c695d1...af7054a. Read the comment docs.

@rhyek
Copy link
Author

rhyek commented Aug 4, 2017

Not sure what is causing those test errors. I'll have a look at it later. @westy92 have you had a chance to take a look at this?

@tomasc
Copy link

tomasc commented Aug 6, 2017

Thank you @rhyek, very nice!
I think this is a good approach, I like how the interface matches the PDF one. I assume all the CompletionTrigger options would be the same, correct?

@rhyek
Copy link
Author

rhyek commented Aug 6, 2017

They should work the same, yes. Only thing missing should be tests.

@rhyek
Copy link
Author

rhyek commented Aug 7, 2017

Hm, well I was sort of expecting some tests to fail due to timeouts where OCR scanning is involved. The other tests I noticed are basically inconsistencies in OCR scanning vs my environment, which I wasn't expecting. Things like HELLO! being interpreted as HELLO'. Those are easy to fix.
Others are sort of just random timeouts that I've noticed happen occasionally.

Thoughts on these tests?

@rhyek
Copy link
Author

rhyek commented Aug 7, 2017

To be honest, the OCR thing was mostly me having a little fun with writing these tests. I'm honestly more inclined to just remove them altogether instead of figuring these inconsistencies out. IMO, with the PDF tests, screenshots could be assumed to work fine for the most part and a couple of tests should suffice.

@tomasc
Copy link

tomasc commented Aug 7, 2017

Thank you, @rhyek. Perhaps an idea might be to split this PR into two – one for adding the screenshot interface, other for additional OCR option. That way the screenshot feature could be merged and new package released, and the OCR added separately later on. What do you think?

@rhyek
Copy link
Author

rhyek commented Aug 7, 2017

Yeah, not a bad idea. I just wish @westy92 would share his opinion. Atm I have no idea when or if this might be merged and published.

@tomasc
Copy link

tomasc commented Aug 7, 2017

@rhyek @westy92 usually reacts immediately – I guess he might be on vacation or so.

@westy92
Copy link
Owner

westy92 commented Aug 7, 2017

@rhyek Thank you for the contribution! I plan to take a first look tonight. Sorry for the delay!

Repository owner deleted a comment from codecov bot Aug 9, 2017
@westy92 westy92 self-assigned this Aug 10, 2017
@rhyek
Copy link
Author

rhyek commented Aug 25, 2017

It has been nearly a month since I made this PR. Are there any issues that I can help resolve so this can get merged?

@rhyek rhyek changed the title [WIP] Screenshots. Screenshots. Sep 16, 2017
@rhyek
Copy link
Author

rhyek commented Sep 16, 2017

I cleaned up the tests mostly by removing the OCR ones which I feel were unneeded. The failed tests are are an issue of slow processing on the test server.

If there isn't any interest in this PR please close.

@rhyek rhyek closed this Sep 18, 2017
@tomasc
Copy link

tomasc commented Sep 18, 2017

@westy92 why is this not being merged please? This would be a welcome addition to the library as far as I am concerned.

@graingert
Copy link

@rhyek why did you close this?

@rhyek
Copy link
Author

rhyek commented Sep 19, 2017

@graingert, sorry. I interpreted the lack of attention to this PR as the repo owner having either no interest or different plans for this feature, which is fine.

@graingert
Copy link

@westy92 do you know what's happening with this PR?

@westy92
Copy link
Owner

westy92 commented Sep 19, 2017

I still have not had the time to review this in depth. Since this is a new (large) feature, I plan to investigate methods of generating images, verify this is the best one, and then think about how I want this new functionality integrated into the project. It will take a lot of time that I have not had yet. I just reopened this, as I will get to it eventually.

@westy92 westy92 reopened this Sep 19, 2017
@westy92
Copy link
Owner

westy92 commented Sep 19, 2017

If anyone else wishes to review this changeset, please do. The more eyes, the better.

@graingert
Copy link

graingert commented Sep 19, 2017 via email

@westy92
Copy link
Owner

westy92 commented Sep 19, 2017

@graingert I don't see any code here working with tabs, but that implementation should remain separate.

@rhyek
Copy link
Author

rhyek commented Sep 19, 2017

@westy92, he means this.

I am already using my fork in production and since multiple PDFs and/or screenshots are being generated concurrently, I have found my application crashes frequently without the tab functionality.

For example, I have a page that displays several (20 or so) screenshots at the same time all generated in real-time with a single chrome instance. Without tabs it does not work.

It is very basic since it is just utilizing chrome-remote-interface's API. IMO, the code for both screenshots and tabs is very simple. I think it would be a good idea to review both at the same time in this PR.

There is already a test that utilizes tabs. Currently it only generates 5 concurrent PDFs since the global 15s timeout and slow processing of the test server doesn't allow for more, for some reason. That test itself could use a review as well.


# tesseract.js eng language files
test/langs/*
!test/langs/.gitkeep

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing trailing new line

@graingert
Copy link

@rhyek do you have a fork on npm? and can you separate out the use of tabs for concurrency?

@rhyek
Copy link
Author

rhyek commented Sep 22, 2017 via email

@graingert
Copy link

@rhyek can you separate out the fix to use tabs for concurrency into a different PR?

@rhyek
Copy link
Author

rhyek commented Sep 22, 2017

Sure. I think I'll have some time over the weekend.

@graingert graingert mentioned this pull request Sep 25, 2017
@graingert
Copy link

@rhyek I see you didn't have time over the weekend, but don't worry!

I've extracted from your PR the bits required for parallel generation of PDFs here: #61 would be good to get a review/rebase from you!

@westy92
Copy link
Owner

westy92 commented Nov 22, 2017

@rhyek I think the project is at a decent position to get this merged in! Could you please sync this with master? Thanks!

@rhyek
Copy link
Author

rhyek commented Nov 22, 2017

Sorry, I have 0 interest in this PR. If someone else wants to help you out with a new one with my code that's fine.

@westy92
Copy link
Owner

westy92 commented Nov 22, 2017

Thank you for your contributions so far! I'll take it from here and use this as a starting point.

@straldev
Copy link

straldev commented Apr 2, 2018

@westy92 What's the status on this PR?

@gregbown
Copy link

gregbown commented Aug 1, 2020

@westy92 Was this ever completed? I have the need to render a screenshot prior to agreement because displaying a final pdf in the browser would be equivalent to free. This would be very convenient and streamline the document process.
@rhyek I read that you use this feature in production but had issues with crashing related to tabs. Did you resolve this issue?

Is this project active? I hope Puppeteer has not eaten everybody's lunch?

@vivex
Copy link

vivex commented Dec 1, 2020

any update on this?

@westy92
Copy link
Owner

westy92 commented Apr 19, 2022

Screenshot functionality has been published in version 0.8.0! 🎉

@westy92 westy92 closed this Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants