in python I use pywand:
def generate_with_wand(self, wand_img: WandImage):
# create stripped down version of our image:
wand_img.strip()
wand_img.auto_orient()
wand_img.compression_quality = 90
thumb = wand_img.clone()
thumb.transform(resize=self.size)
thumb.save(filename=str(self.get_output_path()))