Page 1 of 1

Converting CR2 to PNG messes up the colors

Posted: 2019-03-12T04:19:48-07:00
by FlashT
I do understand that CR2 is a complicated format. But why windows image preview app can read it properly, while every convertion / reading tool messes up the colors? How do I convert it properly?

Example:

Good colors
Image

More like sepia colors:
Image

Re: Converting CR2 to PNG messes up the colors

Posted: 2019-03-12T07:35:10-07:00
by snibgo
A CR2 file contains two types of images:

1. The raw sensor image. This needs debayering and white balancing to make a human-visible image.

2. One or more JPG versions of the image, made by the camera. This is debayered, with whatever white balancing the camera controls indicated. It has also been "prettified", modifying tones and saturation, sharpened, etc.

Windows preview apps generally read one of the JPG images. ImageMagick and other processors read the raw image.

Re: Converting CR2 to PNG messes up the colors

Posted: 2019-03-12T07:59:47-07:00
by FlashT
Any way to read that JPEG then?
(the first one is the one that looks better in my opinion, and it is generated by windows preview)

Re: Converting CR2 to PNG messes up the colors

Posted: 2019-03-12T08:04:49-07:00
by snibgo
I suggest exiftool, such as ...

Code: Select all

exiftool -Composite:PreviewImage -b myfile.cr2 >preview.jpg
.... or ...

Code: Select all

exiftool -Composite:ThumbnailImage -b myfile.cr2 >thumb.jpg
For "myfile.cr2", use your own filename.

Re: Converting CR2 to PNG messes up the colors

Posted: 2019-03-12T10:16:24-07:00
by FlashT
which exiftool? the one by Phil Harvey? gives me empty file, I really doubt it's a preview image, as it's full resolution... jpeg of that size (and compression) would be bigger than actual CR2 file, and I can't see any artifacts, images are basically the same, but in different colors, same with google drive, it previews it the same way, you can see that it reads it sector by sector

Re: Converting CR2 to PNG messes up the colors

Posted: 2019-03-12T10:33:00-07:00
by snibgo
FlashT wrote:which exiftool? the one by Phil Harvey?
Yes.

Perhaps your CR2 doesn't have the JPGs I suggested. "exiftool -args myfile.cr2" will tell you what JPG images are embedded. For example:

Code: Select all

f:\web\im>exiftool -args myfile.cr2 |grep Binary
-DustRemovalData=(Binary data 1024 bytes, use -b option to extract)
-PreviewImage=(Binary data 1706501 bytes, use -b option to extract)
-ThumbnailImage=(Binary data 17031 bytes, use -b option to extract)

Re: Converting CR2 to PNG messes up the colors

Posted: 2019-03-12T11:10:49-07:00
by FlashT
Hmm... so it does have a preview image, but tool doesn't seem to be working then... doesn't output anything.
-ExifToolVersion=11.31
-FileName=IMG_3724.CR2
-Directory=.
-FileSize=26 MB
-FileModifyDate=2019:03:12 11:36:25+01:00
-FileAccessDate=2019:03:12 19:09:17+01:00
-FileCreateDate=2019:03:12 18:14:17+01:00
-FilePermissions=rw-rw-rw-
-FileType=CR2
-FileTypeExtension=cr2
-MIMEType=image/x-canon-cr2
-ExifByteOrder=Little-endian (Intel, II)
-ImageWidth=5184
-ImageHeight=3456
-BitsPerSample=8 8 8
-Compression=JPEG (old-style)
-Make=Canon
-Model=Canon EOS 700D
-PreviewImageStart=92664
-Orientation=Horizontal (normal)
-PreviewImageLength=3575269
-XResolution=72
-YResolution=72
-ResolutionUnit=inches
-ModifyDate=2016:11:17 14:35:48
-Artist=
-Rating=0
-Copyright=
-ExposureTime=1/1600
-FNumber=4.0
-ExposureProgram=Shutter speed priority AE
-ISO=100
-SensitivityType=Recommended Exposure Index
-RecommendedExposureIndex=100
-ExifVersion=0230
-DateTimeOriginal=2016:11:17 14:35:48
-CreateDate=2016:11:17 14:35:48
-ComponentsConfiguration=Y, Cb, Cr, -
-ShutterSpeedValue=1/1579
-ApertureValue=4.0
-Flash=Off, Did not fire
-FocalLength=35.0 mm
-MacroMode=Normal
-SelfTimer=10 s
-Quality=RAW
-CanonFlashMode=Off
-ContinuousDrive=Single
-FocusMode=Manual Focus (3)
-RecordMode=CR2
-CanonImageSize=n/a
-EasyMode=Manual
-DigitalZoom=None
-Contrast=Normal
-Saturation=Normal
-CameraISO=Auto
-MeteringMode=Evaluative
-FocusRange=Not Known
-CanonExposureMode=Shutter speed priority AE
-LensType=Canon EF 35mm f/2 IS USM
-MaxFocalLength=35 mm
-MinFocalLength=35 mm
-FocalUnits=1/mm
-MaxAperture=2
-MinAperture=23
-FlashActivity=0
-FlashBits=(none)
-ZoomSourceWidth=0
-ZoomTargetWidth=0
-ManualFlashOutput=n/a
-ColorTone=Normal
-SRAWQuality=n/a
-AutoISO=100
-BaseISO=100
-MeasuredEV=14.50
-TargetAperture=4
-TargetExposureTime=1/1625
-ExposureCompensation=0
-WhiteBalance=Auto
-SlowShutter=None
-SequenceNumber=0
-OpticalZoomCode=n/a
-CameraTemperature=4 C
-FlashGuideNumber=0
-FlashExposureComp=0
-AutoExposureBracketing=Off
-AEBBracketValue=0
-ControlMode=Unknown (2)
-MeasuredEV2=14.875
-BulbDuration=0
-CameraType=EOS High-end
-NDFilter=n/a
-CanonImageType=Canon EOS 700D
-CanonFirmwareVersion=Firmware Version 1.1.3
-CameraOrientation=Horizontal (normal)
-FirmwareVersion=1.1.3
-FileIndex=3724
-DirectoryIndex=100
-ContrastStandard=0
-SharpnessStandard=3
-SaturationStandard=0
-ColorToneStandard=0
-ContrastPortrait=0
-SharpnessPortrait=2
-SaturationPortrait=0
-ColorTonePortrait=0
-ContrastLandscape=0
-SharpnessLandscape=4
-SaturationLandscape=0
-ColorToneLandscape=0
-ContrastNeutral=0
-SharpnessNeutral=0
-SaturationNeutral=0
-ColorToneNeutral=0
-ContrastFaithful=0
-SharpnessFaithful=0
-SaturationFaithful=0
-ColorToneFaithful=0
-ContrastMonochrome=0
-SharpnessMonochrome=3
-FilterEffectMonochrome=None
-ToningEffectMonochrome=None
-ContrastAuto=0
-SharpnessAuto=3
-SaturationAuto=0
-ColorToneAuto=0
-FilterEffectAuto=n/a
-ToningEffectAuto=n/a
-ContrastUserDef1=0
-SharpnessUserDef1=3
-SaturationUserDef1=0
-ColorToneUserDef1=0
-FilterEffectUserDef1=None
-ToningEffectUserDef1=None
-ContrastUserDef2=0
-SharpnessUserDef2=3
-SaturationUserDef2=0
-ColorToneUserDef2=0
-FilterEffectUserDef2=None
-ToningEffectUserDef2=None
-ContrastUserDef3=0
-SharpnessUserDef3=3
-SaturationUserDef3=0
-ColorToneUserDef3=0
-FilterEffectUserDef3=None
-ToningEffectUserDef3=None
-UserDef1PictureStyle=Auto
-UserDef2PictureStyle=Auto
-UserDef3PictureStyle=Auto
-CanonModelID=EOS Rebel T5i / 700D / Kiss X7i
-ThumbnailImageValidArea=0 159 7 112
-AFAreaMode=Off (Manual Focus)
-NumAFPoints=31
-ValidAFPoints=9
-CanonImageWidth=5184
-CanonImageHeight=3456
-AFImageWidth=5184
-AFImageHeight=3456
-AFAreaWidths=129 129 129 181 222 181 129 129 129 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-AFAreaHeights=172 172 172 117 224 117 172 172 172 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-AFAreaXPositions=-1368 -819 -819 0 0 0 819 819 1368 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-AFAreaYPositions=0 387 -387 763 0 -763 387 -387 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-AFPointsInFocus=(none)
-AFPointsSelected=0,1,2,3,4,5,6,7,8
-TimeZone=+00:00
-TimeZoneCity=London
-DaylightSavings=Off
-BracketMode=Off
-BracketValue=0
-BracketShotNumber=0
-RawJpgSize=Large
-WBBracketMode=Off
-WBBracketValueAB=0
-WBBracketValueGM=0
-LiveViewShooting=Off
-FocusDistanceUpper=inf
-FocusDistanceLower=5.95 m
-FlashExposureLock=Off
-InternalSerialNumber=DA3337496
-DustRemovalData=(Binary data 1024 bytes, use -b option to extract)
-CropLeftMargin=0
-CropRightMargin=0
-CropTopMargin=0
-CropBottomMargin=0
-ExposureLevelIncrements=1/3 Stop
-ISOExpansion=Off
-AFAssistBeam=Emits
-MirrorLockup=Disable
-ShutterButtonAFOnButton=Metering + AF start
-SetButtonWhenShooting=Normal (disabled)
-LCDDisplayAtPowerOn=Display
-AspectRatio=3:2
-CroppedImageWidth=5184
-CroppedImageHeight=3456
-CroppedImageLeft=0
-CroppedImageTop=0
-ToneCurve=Standard
-Sharpness=4
-SharpnessFrequency=n/a
-SensorRedLevel=0
-SensorBlueLevel=0
-WhiteBalanceRed=0
-WhiteBalanceBlue=0
-ColorTemperature=5200
-PictureStyle=Landscape
-DigitalGain=0
-WBShiftAB=0
-WBShiftGM=0
-MeasuredRGGB=511 1024 1024 650
-VRDOffset=0
-SensorWidth=5280
-SensorHeight=3528
-SensorLeftBorder=84
-SensorTopBorder=64
-SensorRightBorder=5267
-SensorBottomBorder=3519
-BlackMaskLeftBorder=0
-BlackMaskTopBorder=0
-BlackMaskRightBorder=0
-BlackMaskBottomBorder=0
-ColorDataVersion=10 (1DX/5DmkIII/6D/70D/100D/650D/700D/M)
-WB_RGGBLevelsAsShot=2106 1024 1024 1631
-ColorTempAsShot=5057
-WB_RGGBLevelsAuto=2106 1024 1024 1631
-ColorTempAuto=5057
-WB_RGGBLevelsMeasured=2114 1024 1024 1626
-ColorTempMeasured=5087
-WB_RGGBLevelsDaylight=2171 1024 1024 1618
-ColorTempDaylight=5200
-WB_RGGBLevelsShade=2509 1024 1024 1378
-ColorTempShade=7000
-WB_RGGBLevelsCloudy=2330 1024 1024 1487
-ColorTempCloudy=6000
-WB_RGGBLevelsTungsten=1551 1024 1024 2439
-ColorTempTungsten=3200
-WB_RGGBLevelsFluorescent=1889 1024 1024 2300
-ColorTempFluorescent=3720
-WB_RGGBLevelsKelvin=2171 1024 1024 1618
-ColorTempKelvin=5189
-WB_RGGBLevelsFlash=2422 1024 1024 1475
-ColorTempFlash=6277
-AverageBlackLevel=2047 2047 2047 2047
-RawMeasuredRGGB=352827 706351 709358 441336
-PerChannelBlackLevel=2047 2047 2047 2048
-NormalWhiteLevel=11765
-SpecularWhiteLevel=12277
-LinearityUpperMargin=10000
-PictureStyleUserDef=Auto; Auto; Auto
-PictureStylePC=None; None; None
-CustomPictureStyleFileName=
-AFMicroAdjMode=Disable
-AFMicroAdjValue=0
-VignettingCorrVersion=0
-PeripheralLighting=On
-ChromaticAberrationCorr=Off
-PeripheralLightingValue=70
-OriginalImageWidth=5184
-OriginalImageHeight=3456
-PeripheralLightingSetting=On
-ChromaticAberrationSetting=Off
-PeripheralIlluminationCorr=Off
-AutoLightingOptimizer=Standard
-HighlightTonePriority=Off
-LongExposureNoiseReduction=Off
-HighISONoiseReduction=Standard
-AmbienceSelection=Standard
-HDR=Off
-HDREffect=Natural
-UserComment=
-SubSecTime=19
-SubSecTimeOriginal=19
-SubSecTimeDigitized=19
-FlashpixVersion=0100
-ColorSpace=sRGB
-ExifImageWidth=5184
-ExifImageHeight=3456
-InteropIndex=R98 - DCF basic file (sRGB)
-InteropVersion=0100
-FocalPlaneXResolution=5798.657718
-FocalPlaneYResolution=5788.944724
-FocalPlaneResolutionUnit=inches
-CustomRendered=Normal
-ExposureMode=Auto
-SceneCaptureType=Standard
-OwnerName=
-SerialNumber=153032010024
-LensInfo=35mm f/0
-LensModel=EF35mm f/2 IS USM
-LensSerialNumber=0000003019
-GPSVersionID=2.3.0.0
-GPSLatitudeRef=South
-GPSLongitudeRef=West
-GPSAltitudeRef=Above Sea Level
-GPSTimeStamp=14:35:48
-GPSSatellites=12
-GPSStatus=Measurement Active
-GPSMeasureMode=3-Dimensional Measurement
-GPSDOP=1.5
-GPSSpeedRef=Unknown ()
-GPSSpeed=0
-GPSTrackRef=Unknown ()
-GPSTrack=0
-GPSMapDatum=WGS-84
-GPSDestLatitudeRef=Unknown ()
-GPSDestLongitudeRef=Unknown ()
-GPSDestBearingRef=Unknown ()
-GPSDestBearing=0
-GPSDestDistanceRef=Unknown ()
-GPSDestDistance=0
-GPSProcessingMethod=
-GPSAreaInformation=
-GPSDateStamp=2016:11:17
-GPSDifferential=Unknown (65535)
-ThumbnailOffset=80084
-ThumbnailLength=12580
-PhotometricInterpretation=RGB
-SamplesPerPixel=3
-RowsPerStrip=441
-PlanarConfiguration=Chunky
-StripOffsets=5414296
-StripByteCounts=22230280
-CR2CFAPattern=[Red,Green][Green,Blue]
-RawImageSegmentation=1 2640 2640
-SRawType=1
-Aperture=4.0
-DriveMode=Self-timer Operation
-FileNumber=100-3724
-GPSAltitude=489 m Above Sea Level
-GPSDateTime=2016:11:17 14:35:48Z
-GPSDestLatitude=0 deg 0' 0.00" N
-GPSDestLongitude=0 deg 0' 0.00" E
-GPSLatitude=62 deg 10' 32.96" S
-GPSLongitude=58 deg 26' 42.94" W
-GPSPosition=62 deg 10' 32.96" S, 58 deg 26' 42.94" W
-ImageSize=5184x3456
-Lens=35.0 mm
-LensID=Canon EF 35mm f/2 IS USM
-Megapixels=17.9
-PreviewImage=(Binary data 3575269 bytes, use -b option to extract)
-ScaleFactor35efl=1.6
-ShootingMode=Shutter speed priority AE
-ShutterSpeed=1/1600
-SubSecCreateDate=2016:11:17 14:35:48.19
-SubSecDateTimeOriginal=2016:11:17 14:35:48.19
-SubSecModifyDate=2016:11:17 14:35:48.19
-ThumbnailImage=(Binary data 12580 bytes, use -b option to extract)
-WB_RGGBLevels=2106 1024 1024 1631
-BlueBalance=1.592773
-CircleOfConfusion=0.019 mm
-DOF=inf (15.40 m - inf)
-FOV=36.0 deg
-FocalLength35efl=35.0 mm (35 mm equivalent: 55.5 mm)
-HyperfocalDistance=16.15 m
-Lens35efl=35.0 mm (35 mm equivalent: 55.5 mm)
-LightValue=14.6
-RedBalance=2.056641

Re: Converting CR2 to PNG messes up the colors

Posted: 2019-03-12T11:12:43-07:00
by FlashT
Maybe that would help to make the correct conversion output? for example it says "-WB_RGGBLevels=2106 1024 1024 1631", that means that red is overexposed I guess... and that would match my feelings about the output

Re: Converting CR2 to PNG messes up the colors

Posted: 2019-03-12T11:38:07-07:00
by snibgo
That doesn't mean the red channel is overexposed. "2106 1024 1024 1631" are the ratios the raw channel values should be multiplied by to make a gray in the photographed scene have equal values in the RGB channels. These are reasonable values for any DSLR. From your text, we can see this is fairly close to "-ColorTempDaylight=5200", which is reasonable.

Re: Converting CR2 to PNG messes up the colors

Posted: 2019-03-12T11:54:05-07:00
by FlashT
From what I saw it, it was more like on the first image tbh