Skip to content

Instantly share code, notes, and snippets.

@persones
Created August 10, 2021 08:08
Show Gist options
  • Save persones/7f43665aa8f76ae2a495536e01fdd0e0 to your computer and use it in GitHub Desktop.
Save persones/7f43665aa8f76ae2a495536e01fdd0e0 to your computer and use it in GitHub Desktop.
Convert .cr2 to .png
import numpy as np
from PIL import Image
from rawkit.raw import Raw
filename = '/path/to/your/image.cr2'
raw_image = Raw(filename)
buffered_image = np.array(raw_image.to_buffer())
image = Image.frombytes('RGB', (raw_image.metadata.width, raw_image.metadata.height), buffered_image)
image.save('/path/to/your/new/image.png', format='png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment