I have a directory of BMP images. All the images are represented in the RGB color space, though some only actually contain black and white.
I need to convert the BMP to JPG images. All the JPG images also have to be in the RGB color space.
I ran
mogrify -format jpg *.bmp
This creates JPG images for each of my BMPs. However, the BMPs that contain just two colors end up as grayscale JPGs instead of RGB. I also tried
mogrify -format jpg *.bmp -colorspace RGB
and got the same thing.
How do covert a set of BMPs to JPGs and force the RGB color space?
macOS 10.15.7
Nevermind. It's easy with Pillow.
#!/usr/bin/env python
from PIL import Image
from pathlib import Path
import sys
for filename in Path(sys.argv[1]).glob("*.bmp"):
Image.open(filename).save(filename.with_suffix(".jpg"))