-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
Systems
OS: CentOS 8 Stream
Pillow: 9.1.0
Steps:
-
Download a "CR2 Photo":
wget https://images.unsplash.com/photo-1648965919745-4ef7713eeb57 -
Add some code:
import os, sys
from PIL import Image
size = (128, 128)
for infile in sys.argv[1:]:
outfile = os.path.splitext(infile)[0] + ".thumbnail"
if infile != outfile:
try:
with Image.open(infile) as im:
im.thumbnail(size)
im.save(outfile, "JPEG")
except OSError:
print("cannot create thumbnail for", infile)-
Run
python3 test_old_jpeg.py ./photo-1648965919745-4ef7713eeb57 -
Get some err infomations:
Traceback (most recent call last):
File "test_old_jpeg.py", line 11, in <module>
im.thumbnail(size)
File "/usr/local/python3/lib/python3.8/site-packages/PIL/Image.py", line 2476, in thumbnail
im = self.resize(size, resample, box=box, reducing_gap=reducing_gap)
File "/usr/local/python3/lib/python3.8/site-packages/PIL/Image.py", line 2063, in resize
return self._new(self.im.resize(size, resample, box))
ValueError: box can't exceed original image sizeExif
[{
"SourceFile": "photo-1648965919745-4ef7713eeb57",
"ExifTool": {
"ExifToolVersion": 11.99
},
"System": {
"FileName": "photo-1648965919745-4ef7713eeb57",
"Directory": ".",
"FileSize": "23 MB",
"FileModifyDate": "2022:04:03 14:05:21+08:00",
"FileAccessDate": "2022:04:05 06:23:59+08:00",
"FileInodeChangeDate": "2022:04:05 06:23:42+08:00",
"FilePermissions": "rw-r--r--"
},
"File": {
"FileType": "CR2",
"FileTypeExtension": "cr2",
"MIMEType": "image/x-canon-cr2",
"ExifByteOrder": "Little-endian (Intel, II)"
},
"IFD0": {
"ImageWidth": 5760,
"ImageHeight": 3840,
"BitsPerSample": "8 8 8",
"Compression": "JPEG (old-style)",
"Make": "Canon",
"Model": "Canon EOS 5D Mark III",
"PreviewImageStart": 89824,
"Orientation": "Rotate 270 CW",
"PreviewImageLength": 1088740,
"XResolution": 72,
"YResolution": 72,
"ResolutionUnit": "inches",
"ModifyDate": "2019:09:08 03:28:14",
"Artist": "",
"Copyright": "",
"PreviewImage": "(Binary data 1088740 bytes, use -b option to extract)"
},
"XMP-xmp": {
"Rating": 0
},
"ExifIFD": {
"ExposureTime": "1/250",
"FNumber": 2.8,
"ExposureProgram": "Manual",
"ISO": 800,
"SensitivityType": "Recommended Exposure Index",
"RecommendedExposureIndex": 800,
"ExifVersion": "0230",
"DateTimeOriginal": "2019:09:08 03:28:14",
"CreateDate": "2019:09:08 03:28:14",
"ComponentsConfiguration": "Y, Cb, Cr, -",
"ShutterSpeedValue": "1/256",
"ApertureValue": 2.8,
"ExposureCompensation": 0,
"MeteringMode": "Multi-segment",
"Flash": "Off, Did not fire",
"FocalLength": "35.0 mm",
"UserComment": "",
"SubSecTime": "00",
"SubSecTimeOriginal": "00",
"SubSecTimeDigitized": "00",
"FlashpixVersion": "0100",
"ColorSpace": "sRGB",
"ExifImageWidth": 5760,
"ExifImageHeight": 3840,
"FocalPlaneXResolution": 3942.505133,
"FocalPlaneYResolution": 3950.617284,
"FocalPlaneResolutionUnit": "inches",
"CustomRendered": "Normal",
"ExposureMode": "Manual",
"WhiteBalance": "Auto",
"SceneCaptureType": "Standard",
"OwnerName": "",
"SerialNumber": "082024021110",
"LensInfo": "16-35mm f/0",
"LensModel": "EF16-35mm f/2.8L II USM",
"LensSerialNumber": "000082e19a"
},
"Canon": {
"MacroMode": "Normal",
"SelfTimer": "Off",
"Quality": "RAW",
"CanonFlashMode": "Off",
"ContinuousDrive": "Single",
"FocusMode": "One-shot AF",
"RecordMode": "CR2",
"CanonImageSize": "n/a",
"EasyMode": "Manual",
"DigitalZoom": "None",
"Contrast": "Normal",
"Saturation": "Normal",
"MeteringMode": "Evaluative",
"FocusRange": "Not Known",
"CanonExposureMode": "Manual",
"LensType": "Canon EF 16-35mm f/2.8L II USM",
"MaxFocalLength": "35 mm",
"MinFocalLength": "16 mm",
"FocalUnits": "1/mm",
"MaxAperture": 2.8,
"MinAperture": 23,
"FlashActivity": 0,
"FlashBits": "(none)",
"ZoomSourceWidth": 0,
"ZoomTargetWidth": 0,
"ManualFlashOutput": "n/a",
"ColorTone": "Normal",
"SRAWQuality": "n/a",
"FocalLength": "35 mm",
"FocalPlaneXUnknown": 53893,
"FocalPlaneYUnknown": 12236,
"CanonFlashInfo": "0 0 0 0",
"AutoISO": 100,
"BaseISO": 800,
"MeasuredEV": 6.50,
"TargetAperture": 2.8,
"TargetExposureTime": "1/256",
"ExposureCompensation": 0,
"WhiteBalance": "Auto",
"SlowShutter": "None",
"SequenceNumber": 0,
"OpticalZoomCode": "n/a",
"CameraTemperature": "27 C",
"FlashGuideNumber": 0,
"FlashExposureComp": 0,
"AutoExposureBracketing": "Off",
"AEBBracketValue": 0,
"ControlMode": "Camera Local Control",
"FNumber": 2.8,
"ExposureTime": "1/256",
"MeasuredEV2": 5,
"BulbDuration": 0,
"CameraType": "EOS High-end",
"NDFilter": "n/a",
"CanonImageType": "Canon EOS 5D Mark III",
"CanonFirmwareVersion": "Firmware Version 1.3.3",
"OwnerName": "",
"ISO": 800,
"CameraOrientation": "Rotate 270 CW",
"LensSerialNumber": "000082e19a",
"FirmwareVersion": "1.3.3",
"FileIndex": 8428,
"FileIndex2": 8207,
"DirectoryIndex": 100,
"DirectoryIndex2": 100,
"ContrastStandard": 0,
"SharpnessStandard": 3,
"SaturationStandard": 0,
"ColorToneStandard": 0,
"FilterEffectStandard": "n/a",
"ToningEffectStandard": "n/a",
"ContrastPortrait": 0,
"SharpnessPortrait": 2,
"SaturationPortrait": 0,
"ColorTonePortrait": 0,
"FilterEffectPortrait": "n/a",
"ToningEffectPortrait": "n/a",
"ContrastLandscape": 0,
"SharpnessLandscape": 4,
"SaturationLandscape": 0,
"ColorToneLandscape": 0,
"FilterEffectLandscape": "n/a",
"ToningEffectLandscape": "n/a",
"ContrastNeutral": 0,
"SharpnessNeutral": 0,
"SaturationNeutral": 0,
"ColorToneNeutral": 0,
"FilterEffectNeutral": "n/a",
"ToningEffectNeutral": "n/a",
"ContrastFaithful": 0,
"SharpnessFaithful": 0,
"SaturationFaithful": 0,
"ColorToneFaithful": 0,
"FilterEffectFaithful": "n/a",
"ToningEffectFaithful": "n/a",
"ContrastMonochrome": 0,
"SharpnessMonochrome": 3,
"SaturationMonochrome": "n/a",
"ColorToneMonochrome": "n/a",
"FilterEffectMonochrome": "None",
"ToningEffectMonochrome": "None",
"ContrastAuto": 0,
"SharpnessAuto": 3,
"SaturationAuto": 0,
"ColorToneAuto": 0,
"FilterEffectAuto": "n/a",
"ToningEffectAuto": "n/a",
"ContrastUserDef1": -4,
"SharpnessUserDef1": 0,
"SaturationUserDef1": -4,
"ColorToneUserDef1": 2,
"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": "Standard",
"UserDef2PictureStyle": "Standard",
"UserDef3PictureStyle": "Standard",
"CanonModelID": "EOS 5D Mark III",
"ThumbnailImageValidArea": "0 159 7 112",
"Canon_0x0019": 1,
"AFInfoSize": 530,
"AFAreaMode": "Single-point AF",
"NumAFPoints": 61,
"ValidAFPoints": 61,
"CanonImageWidth": 5760,
"CanonImageHeight": 3840,
"AFImageWidth": 5760,
"AFImageHeight": 3840,
"AFAreaWidths": "190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190",
"AFAreaHeights": "188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188 188",
"AFAreaXPositions": "288 0 -288 1520 1232 944 639 288 0 -1520 -1232 -944 -639 -288 1520 1232 944 639 288 0 -1520 -1232 -944 -639 -288 1520 1232 944 639 288 0 -1520 -1232 -944 -639 -288 1520 1232 944 639 288 0 -1520 -1232 -944 -639 -288 1520 1232 944 639 288 0 -1520 -1232 -944 -639 -288 288 0 -288",
"AFAreaYPositions": "-648 -648 -648 -433 -433 -433 -433 -433 -433 -433 -433 -433 -433 -433 -215 -215 -215 -215 -215 -215 -215 -215 -215 -215 -215 0 0 0 0 0 0 0 0 0 0 0 215 215 215 215 215 215 215 215 215 215 215 433 433 433 433 433 433 433 433 433 433 433 648 648 648",
"AFPointsInFocus": 30,
"AFPointsSelected": 30,
"TimeZone": "-05:00",
"TimeZoneCity": "Chicago",
"DaylightSavings": "On",
"BracketMode": "Off",
"BracketValue": 0,
"BracketShotNumber": 0,
"RawJpgSize": "Large",
"WBBracketMode": "Off",
"WBBracketValueAB": 0,
"WBBracketValueGM": 0,
"LiveViewShooting": "Off",
"FocusDistanceUpper": "2.19 m",
"FocusDistanceLower": "1.13 m",
"FlashExposureLock": "Off",
"LensModel": "EF16-35mm f/2.8L II USM",
"InternalSerialNumber": "",
"DustRemovalData": "(Binary data 1024 bytes, use -b option to extract)",
"CropLeftMargin": 0,
"CropRightMargin": 0,
"CropTopMargin": 0,
"CropBottomMargin": 0,
"AspectRatio": "3:2",
"CroppedImageWidth": 5760,
"CroppedImageHeight": 3840,
"CroppedImageLeft": 0,
"CroppedImageTop": 0,
"ToneCurve": "Standard",
"Sharpness": 0,
"SharpnessFrequency": "n/a",
"SensorRedLevel": 0,
"SensorBlueLevel": 0,
"WhiteBalanceRed": 0,
"WhiteBalanceBlue": 0,
"ColorTemperature": 2500,
"PictureStyle": "Neutral",
"DigitalGain": 0,
"WBShiftAB": 0,
"WBShiftGM": 0,
"MeasuredRGGB": "247 1024 1024 1244",
"ColorSpace": "sRGB",
"VRDOffset": 0,
"SensorWidth": 5920,
"SensorHeight": 3950,
"SensorLeftBorder": 140,
"SensorTopBorder": 96,
"SensorRightBorder": 5899,
"SensorBottomBorder": 3935,
"BlackMaskLeftBorder": 0,
"BlackMaskTopBorder": 0,
"BlackMaskRightBorder": 0,
"BlackMaskBottomBorder": 0,
"ColorDataVersion": "10 (1DX/5DmkIII/6D/70D/100D/650D/700D/M)",
"WB_RGGBLevelsAsShot": "1551 1024 1024 2140",
"ColorTempAsShot": 3542,
"WB_RGGBLevelsAuto": "1551 1024 1024 2140",
"ColorTempAuto": 3542,
"WB_RGGBLevelsMeasured": "1551 1024 1024 2140",
"ColorTempMeasured": 3542,
"WB_RGGBLevelsUnknown": "1551 1024 1024 2140",
"ColorTempUnknown": 3542,
"WB_RGGBLevelsUnknown2": "1024 1024 1024 1024",
"ColorTempUnknown2": 4405,
"WB_RGGBLevelsUnknown3": "1024 1024 1024 1024",
"ColorTempUnknown3": 4405,
"WB_RGGBLevelsUnknown4": "1551 1024 1024 2140",
"ColorTempUnknown4": 3542,
"WB_RGGBLevelsUnknown5": "1551 1024 1024 2140",
"ColorTempUnknown5": 3542,
"WB_RGGBLevelsUnknown6": "1551 1024 1024 2140",
"ColorTempUnknown6": 3542,
"WB_RGGBLevelsUnknown7": "1549 1024 1024 2140",
"ColorTempUnknown7": 3542,
"WB_RGGBLevelsUnknown8": "1549 1024 1024 2140",
"ColorTempUnknown8": 3542,
"WB_RGGBLevelsUnknown9": "798 1022 1023 1200",
"ColorTempUnknown9": 3072,
"WB_RGGBLevelsUnknown10": "862 1170 1170 481",
"ColorTempUnknown10": 3076,
"WB_RGGBLevelsDaylight": "2024 1024 1024 1631",
"ColorTempDaylight": 5200,
"WB_RGGBLevelsShade": "2325 1024 1024 1391",
"ColorTempShade": 7000,
"WB_RGGBLevelsCloudy": "2180 1024 1024 1502",
"ColorTempCloudy": 6000,
"WB_RGGBLevelsTungsten": "1458 1024 1024 2427",
"ColorTempTungsten": 3200,
"WB_RGGBLevelsFluorescent": "1768 1024 1024 2330",
"ColorTempFluorescent": 3714,
"WB_RGGBLevelsKelvin": "1160 1024 1024 3093",
"ColorTempKelvin": 2494,
"WB_RGGBLevelsFlash": "2255 1024 1024 1477",
"ColorTempFlash": 6314,
"WB_RGGBLevelsUnknown11": "2024 1024 1024 1631",
"ColorTempUnknown11": 5189,
"WB_RGGBLevelsUnknown12": "2024 1024 1024 1631",
"ColorTempUnknown12": 5189,
"WB_RGGBLevelsUnknown13": "2024 1024 1024 1631",
"ColorTempUnknown13": 5189,
"WB_RGGBLevelsUnknown14": "2024 1024 1024 1631",
"ColorTempUnknown14": 5189,
"WB_RGGBLevelsUnknown15": "2024 1024 1024 1631",
"ColorTempUnknown15": 5189,
"WB_RGGBLevelsUnknown16": "1018 1024 1024 1019",
"ColorTempUnknown16": 4405,
"WB_RGGBLevelsUnknown17": "1018 1024 1024 1019",
"ColorTempUnknown17": 4405,
"WB_RGGBLevelsUnknown18": "1018 1024 1024 1019",
"ColorTempUnknown18": 4405,
"WB_RGGBLevelsUnknown19": "1018 1024 1024 1019",
"ColorTempUnknown19": 4405,
"WB_RGGBLevelsUnknown20": "1018 1024 1024 1019",
"ColorTempUnknown20": 4405,
"CameraColorCalibration01": "-309 390 892 (10900K)",
"CameraColorCalibration02": "-291 399 869 (10000K)",
"CameraColorCalibration03": "-245 422 811 (8300K)",
"CameraColorCalibration04": "-193 451 754 (7000K)",
"CameraColorCalibration05": "-139 481 698 (6000K)",
"CameraColorCalibration06": "-111 498 672 (5600K)",
"CameraColorCalibration07": " -81 518 643 (5200K)",
"CameraColorCalibration08": " -33 546 596 (4700K)",
"CameraColorCalibration09": " 23 585 548 (4200K)",
"CameraColorCalibration10": " 77 628 507 (3800K)",
"CameraColorCalibration11": " 126 668 471 (3500K)",
"CameraColorCalibration12": " 183 719 432 (3200K)",
"CameraColorCalibration13": " 230 758 397 (3000K)",
"CameraColorCalibration14": " 270 807 378 (2800K)",
"CameraColorCalibration15": " 376 937 327 (2400K)",
"AverageBlackLevel": "2048 2048 2048 2048",
"RawMeasuredRGGB": "28794 117836 115237 142120",
"PerChannelBlackLevel": "2047 2047 2048 2048",
"NormalWhiteLevel": 14809,
"SpecularWhiteLevel": 15321,
"LinearityUpperMargin": 10156,
"CRWParam": "(Binary data 43572 bytes, use -b option to extract)",
"Flavor": "(Binary data 16792 bytes, use -b option to extract)",
"PictureStyleUserDef": "Standard; Standard; Standard",
"PictureStylePC": "None; None; None",
"CustomPictureStyleFileName": "",
"Canon_0x4011": "[...]",
"Canon_0x4012": "",
"AFMicroAdjMode": "Disable",
"AFMicroAdjValue": 0,
"VignettingCorrVersion": 0,
"PeripheralLighting": "On",
"DistortionCorrection": "Off",
"ChromaticAberrationCorr": "On",
"PeripheralLightingValue": 60,
"DistortionCorrectionValue": 100,
"OriginalImageWidth": 5760,
"OriginalImageHeight": 3840,
"PeripheralLightingSetting": "On",
"ChromaticAberrationSetting": "On",
"PeripheralIlluminationCorr": "Off",
"AutoLightingOptimizer": "Off",
"HighlightTonePriority": "Off",
"LongExposureNoiseReduction": "Off",
"HighISONoiseReduction": "Standard",
"MultiExposure": "Off",
"MultiExposureControl": "Additive",
"MultiExposureShots": 0,
"HDR": "Off",
"HDREffect": "Natural",
"Canon_0x4027": "20 590343 2846162996 121374208 13684944",
"AFConfigTool": "Case 1",
"AFTrackingSensitivity": 0,
"AFAccelDecelTracking": 0,
"AFPointSwitching": 0,
"AIServoFirstImage": "Equal Priority",
"AIServoSecondImage": "Equal Priority",
"USMLensElectronicMF": "Enable After AF",
"AFAssistBeam": "Enable",
"OneShotAFRelease": "Focus Priority",
"LensDriveWhenAFImpossible": "Continue Focus Search",
"SelectAFAreaSelectionMode": "Single-point AF, Auto, Zone AF, AF Point Expansion (4 point), Spot AF, AF Point Expansion (8 point)",
"AFAreaSelectionMethod": "M-Fn Button",
"OrientationLinkedAF": "Same for Vert/Horiz Points",
"ManualAFPointSelPattern": "Stops at AF Area Edges",
"AFPointDisplayDuringFocus": "Selected (constant)",
"VFDisplayIllumination": "Auto"
},
"CanonCustom": {
"ExposureLevelIncrements": "1/3 Stop",
"ISOSpeedIncrements": "1/3 Stop",
"AEBAutoCancel": "On",
"AEBSequence": "0,-,+",
"AEBShotCount": "3 shots",
"SafetyShift": "Disable",
"ViewfinderWarnings": "Monochrome, WB corrected, One-touch image quality",
"LVShootingAreaDisplay": "Outlined",
"CustomControls": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 3",
"DialDirectionTvAv": "Normal",
"MultiFunctionLock": "Off; Quick control dial",
"AddAspectRatioInfo": "Off",
"DefaultEraseOption": "Cancel selected"
},
"InteropIFD": {
"InteropIndex": "R98 - DCF basic file (sRGB)",
"InteropVersion": "0100"
},
"GPS": {
"GPSVersionID": "2.3.0.0"
},
"IFD1": {
"ThumbnailOffset": 80324,
"ThumbnailLength": 9497,
"ThumbnailImage": "(Binary data 9497 bytes, use -b option to extract)"
},
"IFD2": {
"ImageWidth": 592,
"ImageHeight": 395,
"BitsPerSample": "16 16 16",
"Compression": "Uncompressed",
"PhotometricInterpretation": "RGB",
"StripOffsets": 1178564,
"SamplesPerPixel": 3,
"RowsPerStrip": 395,
"StripByteCounts": 1403040,
"PlanarConfiguration": "Chunky",
"Exif_0xc5d9": 2,
"SRawType": 3,
"Exif_0xc6dc": "577 386 14 9"
},
"IFD3": {
"Compression": "JPEG (old-style)",
"StripOffsets": 2915268,
"StripByteCounts": 21439884,
"Exif_0xc5d8": 1,
"CR2CFAPattern": "[Red,Green][Green,Blue]",
"RawImageSegmentation": "1 2960 2960",
"SRawType": 1
},
"Composite": {
"DriveMode": "Single-frame Shooting",
"FileNumber": "100-8428",
"ISO": 800,
"Lens": "16.0 - 35.0 mm",
"ShootingMode": "Manual",
"WB_RGGBLevels": "1551 1024 1024 2140",
"Aperture": 2.8,
"BlueBalance": 2.089844,
"ImageSize": "5760x3840",
"LensID": "Canon EF 16-35mm f/2.8L II USM",
"Megapixels": 22.1,
"RedBalance": 1.514648,
"ScaleFactor35efl": 1.0,
"ShutterSpeed": "1/250",
"SubSecCreateDate": "2019:09:08 03:28:14.00",
"SubSecDateTimeOriginal": "2019:09:08 03:28:14.00",
"SubSecModifyDate": "2019:09:08 03:28:14.00",
"Lens35efl": "16.0 - 35.0 mm (35 mm equivalent: 15.5 - 34.0 mm)",
"CircleOfConfusion": "0.031 mm",
"DOF": "0.39 m (1.49 - 1.88 m)",
"FOV": "55.8 deg",
"FocalLength35efl": "35.0 mm (35 mm equivalent: 34.0 mm)",
"HyperfocalDistance": "14.13 m",
"LightValue": 7.9
}
}]Metadata
Metadata
Assignees
Labels
No labels