compress jpeg images from terminal
Use ImageMagick.  Instructions for macOS binary installation are on the linked page.

compress -quality X% source.jpg result.jpg

X is a positive integer value (i.e. 85 for 85%); source and result are the original filename and the output filename.