Reputation: 11
I have the following code for a .tif file:
img = Image.open("randompic.tif")
image = Jpeg()
image.encodeRGB("randompic.tif")
print(np.array_equal(image.total_bit_objects, np.asarray(Image.open('randompic.tif').convert('L'))))
I try to adapt it for a .CR2 file :
img = np.fromfile('IMG_4387.CR2', "uint16")
image = Jpeg()
image.encodeRGB("IMG_4387.CR2")
print(np.array_equal(image.total_bit_objects, np.asarray(Image.open('IMG_4387.CR2').convert('L'))))
However, Image.open('IMG_4387.CR2') does not work.
Do you have any idea to fix me ?
Upvotes: 1
Views: 1540
Reputation: 99
Why not try the following code. It uses simple PIL I tried rawpy and rawkit and they had complications with Libraw. Rawpy worked but performed a postprocessing I could not seem to understand
from PIL import Image
im = Image.open("File.CR2")
rgb_im = im.convert('RGB')
rgb_im.save('File.JPG')
Upvotes: 2