Export JPEG and get file size in UXP

Can the “export” you are talking about be substituted with “saveAs”?

Here’s an example

Document about saveAs

Document about save options