This tool is available via Homebrew on MacOS as well as on linux
Use ImageMagick's convert
tool to reduce the file size of an image without really affecting resolution:
convert filename.jpg -quality 50% filename.jpg
convert in.png -resize 1024x1024 out.png