The jpegs saved by gdal_translate_jpegs are not in the correct colorspace and are saved with 4 channels instead of 3.
Dan and I have worked on a solution to save them to the sRGB colorspace with 3 channels instead.
While we were troubleshooting I discovered that GDAL_JPEG_TO_RGB was set to NO which might have also been causing issues. Unfortunately, changing this variable did not solve the issue at the docs said it would https://gdal.org/drivers/raster/jpeg.html#raster-jpeg .
from osgeo import gdal
# Set GDAL_JPEG_TO_RGB to YES
gdal.SetConfigOption("GDAL_JPEG_TO_RGB", "YES")
# Check if the option is set to YES
jpeg_to_rgb_option = gdal.GetConfigOption("GDAL_JPEG_TO_RGB")
if jpeg_to_rgb_option == "YES":
print("GDAL_JPEG_TO_RGB is set to YES")
else:
print("Setting GDAL_JPEG_TO_RGB to YES failed")
to check the colorspace of an image, I use the imagemagick too 'identify' e.g. magick identify -verbose multiband0_USDA_NAIP_DOQQ_m_4012408_sw_10_1_20100629.jpg
The jpegs saved by
gdal_translate_jpegs
are not in the correct colorspace and are saved with 4 channels instead of 3. Dan and I have worked on a solution to save them to the sRGB colorspace with 3 channels instead.While we were troubleshooting I discovered that
GDAL_JPEG_TO_RGB
was set to NO which might have also been causing issues. Unfortunately, changing this variable did not solve the issue at the docs said it would https://gdal.org/drivers/raster/jpeg.html#raster-jpeg .to check the colorspace of an image, I use the imagemagick too 'identify' e.g.
magick identify -verbose multiband0_USDA_NAIP_DOQQ_m_4012408_sw_10_1_20100629.jpg