23 lines
702 B
Python
23 lines
702 B
Python
import os
|
|
import rawpy
|
|
import cv2
|
|
|
|
directory = 'arw'
|
|
|
|
for root, _, files in os.walk(directory):
|
|
for fname in files:
|
|
if fname.lower().endswith('.arw'):
|
|
in_path = os.path.join(root, fname)
|
|
out_path = os.path.splitext(in_path)[0] + '.jpg'
|
|
print(f'Convirtiendo {in_path} → {out_path}')
|
|
|
|
# Lee y procesa RAW
|
|
with rawpy.imread(in_path) as raw:
|
|
rgb = raw.postprocess()
|
|
|
|
# OpenCV usa BGR por defecto
|
|
bgr = cv2.cvtColor(rgb, cv2.COLOR_RGB2BGR)
|
|
|
|
# Guarda JPG (calidad 100)
|
|
cv2.imwrite(out_path, bgr, [int(cv2.IMWRITE_JPEG_QUALITY), 100])
|