How to automatically determine how to crop an image in NodeJS? - node.js

I am currently making a Discord bot in NodeJS that can process game screenshots as text through OCR. The OCR works fine but one thing is that the user needs to crop the screenshot to a specific window first in order for the bot to be able to read the text without interference from the text outside the window.
For reference, an example game screenshot would be like this (not necessarily on an emulator)
And the bot only needs this part of the image.
Considering that screenshtos can come in different resolutions and aspect ratios, what is a good way to automatically determine how to crop an image like this?

following npm module use for image cropping :
https://www.npmjs.com/package/image-clipper
https://www.npmjs.com/package/jimp

Related

Anyway to deploy svg image online?

my question is really simple and I still didn't find the answer, maybe because I misspoke about it or didn't use the right keywords, anyways here is the topic:
I have an SVG script that contains some animation (like Bezier curves), I want to put it online, so I get back a link and whenever a user clicks on it, it's going to display my SVG file on the browser.
Is it possible?

AfterEffects Script - I want to set the display settings of the layer panel with a script

halo!
I would like to explain in words, but I am Japanese and rely on Google Translate, so let me explain with pictures.
I would like to implement a script that increases the header like the second image when I press the arrow on the first image.
I'm having trouble finding anyone who can answer that it's the Japanese community.
1st2st

how to customise elementor functionality(how do I find the right bit of code?)

I'm trying to make a web page formatted similar to that of Netflix. Where a list of videos are displayed in a div with two arrows in either direction on each side. When the number of videos are more than the width of the window clicking the arrows moves the displayed videos in the corresponding direction by one video.
And(key part), when a video is clicked, the clicked video gets displayed on another div(main part of the screen) with a text of introduction and an excerpt of the video playing in the background of that section, plus a "play" button to start the video.
I would probably be able to sort it out with vanilla code. But this page is managed by WordPress so I would have to plug in my code with wordpress.
My assumption is that hacking the existing elementor code for the video widget would be the quickest way to do it. But I don't know how to find the code corresponding to the functionality I need to modify to customize it to do what I want. I can locate the video-widget file, but still, it's a huge file with lots of code. How do I find the functionality I need specifically to import into my own code?
Thank you and sorry for the verbose phrasing.

Pyautogui mouse click on different resolution

I'm writing a script for automatizing some tasks at my job. However, I need to make my script portable and try it on different screen resolution.
So far right now I've tried to multiply my coordinate with the ratio between the old and new resolutions, but this doesn't work properly.
Do you know how I can convert my X, Y coordinates for mouse's clicks make it works on different resolution?
Quick question: Are you trying to get it to click on certain buttons? (i.e. buttons that look the same on every computer you plug it into) And by portable, do you mean on a thumb drive (usb)?
You may be able to take an image of the button (i.e. cropping a screenshot), pass it on to the opencv module, one of the modules has an Image within Image searching ability. you can pass that image along with a screenshot (using pyautogui.screenshot()) and it will return the (x,y) coordinates of the button, pass that on to pyautogui.moveto(x,y) and pyautogui.click(), it might be able to work. you might have to describe the action you are trying to get Pyautogui to do a little better.

Green square on game canvas using Phaser

Can someone please tell me why I'm getting a green square on my Phaser game canvas as below?
Without seeing any code I can tell you that you'll see that when an image can't be loaded by the Phaser framework.
Open developer tools in your browser of choice and refresh after opening the Network tab. You should see a 404 for one of your images.
I believe if you look at the standard browser console you may also see messages about the name of the asset that it failed to load.
I had a slightly different case. Images were being loaded in the init function, which apparently doesn't work. I renamed that function to preload and suddenly the green squares are gone and the images show up.
My case was also a little different too; it appeared that all my image resources were loaded, but I think I was trying to create the sprites a little too quickly - in order words, I was trying to create and add sprites to my scene before the scene was properly loaded.
I'm going to try waiting until 'scene.scene.isActive(key);' returns a boolean of true.....maybe that's what will solve my issue. Failing that, I might just put in some sort of sleep/await promise of 1 second or something (not ideal, but might work)
ALSO NOTE: Part of the reason I was able to create my sprites too quickly was because I was doing so in my own custom function, not the typical create() function. Actually, the best solution is probably to create my sprites in the create() function and not a custom function...

Resources