Skip to content

Commit bffbc84

Browse files
committed
conversion tools: Instead of swapping RGB/BGR after decode, tell TurboJPEG to return RGB
1 parent 93b6916 commit bffbc84

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

cnv_jpeg_to_dng.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import tifffile as TIFF
88
import pyexiv2
9-
from turbojpeg import TurboJPEG
9+
from turbojpeg import TurboJPEG, TJPF_RGB
1010
import argparse
1111
from xphase_data import XphaseTransforms
1212

@@ -51,10 +51,7 @@ def init_TurboJPEG():
5151

5252
with open(args['input'], 'rb') as jpgfile:
5353
#Swap BGR to RGB
54-
bgrdata = jpeg.decode(jpgfile.read())
55-
rgbdata = bgrdata.copy()
56-
rgbdata[:,:,0] = bgrdata[:,:,2]
57-
rgbdata[:,:,2] = bgrdata[:,:,0]
54+
rgbdata = jpeg.decode(jpgfile.read(), pixel_format=TJPF_RGB)
5855

5956
# It seems like every lens except 00, 01, 23, 24 are flipped upside down by PanoManager
6057
(garbage, lensnum, shotnum) = filebase.split("_",3)

cnv_jpeg_to_tiff.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import tifffile
77
import imagecodecs
88
import pyexiv2
9-
from turbojpeg import TurboJPEG
9+
from turbojpeg import TurboJPEG, TJPF_RGB
1010
import argparse
1111
from xphase_data import XphaseTransforms
1212

@@ -50,11 +50,7 @@ def init_TurboJPEG():
5050
'Exif.Image.Model': 'Xphase'}
5151

5252
with open(args['input'], 'rb') as jpgfile:
53-
#Swap BGR to RGB
54-
bgrdata = jpeg.decode(jpgfile.read())
55-
rgbdata = bgrdata.copy()
56-
rgbdata[:,:,0] = bgrdata[:,:,2]
57-
rgbdata[:,:,2] = bgrdata[:,:,0]
53+
rgbdata = jpeg.decode(jpgfile.read(), pixel_format=TJPF_RGB)
5854

5955
# It seems like every lens except 00, 01, 23, 24 are flipped upside down by PanoManager
6056
(garbage, lensnum, shotnum) = filebase.split("_",3)

0 commit comments

Comments
 (0)