AppleScript Photos export quality
You could use the third-party tool ImageMagick, which can perform a wide variety of image transformations, including converting to a lower quality. You can install it with Homebrew with brew install imagemagick. You would include it through the do shell script command, for example do shell script 'convert input.png -quality 85% output.jpg'.