Summary: | FILEIO : add new option to use quality of the original JPEG picture | ||
---|---|---|---|
Product: | [Applications] digikam | Reporter: | S. Burmeister <sven.burmeister> |
Component: | Plugin-DImg-JPEG | Assignee: | Digikam Developers <digikam-bugs-null> |
Status: | REPORTED --- | ||
Severity: | wishlist | CC: | ahuggel, caulier.gilles, cfeck |
Priority: | NOR | ||
Version: | 2.9.0 | ||
Target Milestone: | --- | ||
Platform: | openSUSE | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
S. Burmeister
2009-12-09 13:52:21 UTC
Andreas, Do you have an idea, how gimp can take the image quality value (JPEG compression) from file ? It's recorded somewhere in metadata ? Gilles Caulier ImageMagick's "identify" tool can display Quality (and lots of other parameters the image was saved with) See http://www.imagemagick.org/script/identify.php GraphicsMagick might be an option, too, but haven't checked. imagemagick is already a dependency of digikam. So it could be used indeed. Thanks for the hint! no, IM is not a depency of digiKam, but to kipi-plugins, as run-time... Gilles Caulier Well, you could have a look at ImageMagick's source to see how to compute the average Quality from the quantization coefficient matrix. An IM example : [gilles@localhost Camera]$ identify -verbose Bryce_2007_0102.jpg Image: Bryce_2007_0102.jpg Format: JPEG (Joint Photographic Experts Group JFIF format) Class: DirectClass Geometry: 3872x2592+0+0 Resolution: 300x300 Print size: 12.9067x8.64 Units: PixelsPerInch Type: TrueColor Endianess: Undefined Colorspace: sRGB Depth: 8-bit Channel depth: red: 8-bit green: 8-bit blue: 8-bit Channel statistics: Red: min: 4 (0.0156863) max: 255 (1) mean: 112.346 (0.440574) standard deviation: 49.9501 (0.195883) kurtosis: -0.905399 skewness: 0.0162092 Green: min: 3 (0.0117647) max: 239 (0.937255) mean: 94.4013 (0.370201) standard deviation: 56.1 (0.22) kurtosis: -0.899077 skewness: 0.540585 Blue: min: 0 (0) max: 232 (0.909804) mean: 92.1944 (0.361547) standard deviation: 71.8705 (0.281845) kurtosis: -1.19741 skewness: 0.634281 Image statistics: Overall: min: 0 (0) max: 255 (1) mean: 99.6473 (0.390774) standard deviation: 60.0211 (0.235377) kurtosis: -1.00412 skewness: 0.407677 Rendering intent: Perceptual Gamma: 0.45455 Chromaticity: red primary: (0.64,0.33) green primary: (0.3,0.6) blue primary: (0.15,0.06) white point: (0.3127,0.329) Interlace: None Background color: white Border color: srgb(223,223,223) Matte color: grey74 Transparent color: black Compose: Over Page geometry: 3872x2592+0+0 Dispose: Undefined Iterations: 0 Compression: JPEG Quality: 99 Orientation: TopLeft Properties: comment: Bryce Canyon NP. Thor's hammer (si j'avais un marteau ...) Mais que pouvait bien venir faire Thor dans cet endroit ?? date:create: 2012-07-11T09:05:33+02:00 date:modify: 2008-03-06T00:00:00+01:00 exif:CFAPattern: 0, 2, 0, 2, 1, 0, 2, 1 exif:ColorSpace: 1 exif:ComponentsConfiguration: 1, 2, 3, 0 exif:CompressedBitsPerPixel: 4/1 exif:Compression: 6 exif:Contrast: 0 exif:CustomRendered: 0 exif:DateTime: 2007:07:30 08:44:54 exif:DateTimeDigitized: 2007:07:30 08:44:54 exif:DateTimeOriginal: 2007:07:30 08:44:54 exif:DigitalZoomRatio: 1/1 exif:ExifImageLength: 2592 exif:ExifImageWidth: 3872 exif:ExifOffset: 277 exif:ExifVersion: 48, 50, 50, 49 exif:ExposureBiasValue: 0/6 exif:ExposureMode: 0 exif:ExposureProgram: 3 exif:ExposureTime: 10/800 exif:FileSource: 3 exif:Flash: 0 exif:FlashPixVersion: 48, 49, 48, 48 exif:FNumber: 100/10 exif:FocalLength: 180/10 exif:FocalLengthIn35mmFilm: 27 exif:GainControl: 0 exif:GPSInfo: 3378 exif:GPSVersionID: 2, 2, 0, 0 exif:InteroperabilityIndex: R98 exif:InteroperabilityOffset: 3348 exif:InteroperabilityVersion: 48, 49, 48, 48 exif:ISOSpeedRatings: 100 exif:JPEGInterchangeFormat: 3502 exif:JPEGInterchangeFormatLength: 9141 exif:LightSource: 9 exif:Make: NIKON CORPORATION exif:MakerNote: 78, 105, 107, 111, 110, 0, 2, 16, 0, 0, 77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 0, 0, 3, 11, 0, 135, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 136, 0, 7, 0, 0, 0, 4, 0, 9, 2, 0, 0, 137, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 138, 0, 3, 0, 0, 0, 1, 0, 2, 0, 0, 0, 139, 0, 7, 0, 0, 0, 4, 64, 1, 12, 0, 0, 141, 0, 2, 0, 0, 0, 9, 0, 0, 3, 43, 0, 144, 0, 2, 0, 0, 0, 12, 0, 0, 3, 52, 0, 145, 0, 7, 0, 0, 3, 16, 0, 0, 3, 64, 0, 146, 0, 8, 0, 0, 0, 1, 0, 0, 0, 0, 0, 149, 0, 2, 0, 0, 0, 5, 0, 0, 6, 80, 0, 151, 0, 7, 0, 0, 2, 96, 0, 0, 6, 85, 0, 152, 0, 7, 0, 0, 0, 31, 0, 0, 8, 181, 0, 154, 0, 5, 0, 0, 0, 2, 0, 0, 8, 212, 0, 162, 0, 4, 0, 0, 0, 1, 0, 85, 42, 200, 0, 163, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 165, 0, 4, 0, 0, 0, 1, 0, 0, 9, 115, 0, 166, 0, 4, 0, 0, 0, 1, 0, 0, 0, 0, 0, 167, 0, 4, 0, 0, 0, 1, 0, 0, 9, 115, 0, 168, 0, 7, 0, 0, 0, 20, 0, 0, 8, 228, 0, 169, 0, 2, 0, 0, 0, 16, 0, 0, 8, 248, 0, 170, 0, 2, 0, 0, 0, 16, 0, 0, 9, 8, 0, 176, 0, 7, 0, 0, 0, 16, 0, 0, 9, 24, 0, 177, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 67, 79, 76, 79, 82, 0, 70, 73, 78, 69, 32, 32, 32, 0, 83, 85, 78, 78, 89, 32, 32, 32, 32, 32, 32, 32, 0, 78, 79, 82, 77, 65, 76, 0, 65, 70, 45, 83, 32, 32, 0, 78, 79, 82, 77, 65, 76, 32, 32, 32, 32, 32, 32, 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 0, 0, 0, 1, 206, 0, 0, 1, 0, 0, 0, 1, 102, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 15, 32, 10, 32, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 15, 64, 10, 56, 15, 64, 10, 56, 0, 0, 0, 0, 32, 32, 32, 32, 32, 32, 32, 0, 65, 85, 84, 79, 32, 32, 32, 32, 0, 0, 0, 0, 180, 0, 0, 0, 10, 0, 0, 2, 188, 0, 0, 0, 10, 0, 0, 0, 35, 0, 0, 0, 10, 0, 0, 0, 45, 0, 0, 0, 10, 77, 79, 68, 69, 51, 32, 32, 32, 0, 78, 65, 84, 85, 82, 65, 76, 32, 32, 32, 32, 0, 48, 50, 48, 55, 44, 200, 40, 99, 140, 36, 162, 43, 21, 117, 252, 27, 87, 176, 38, 185, 105, 54, 32, 39, 75, 140, 234, 101, 253, 178, 132, 115, 127, 168, 238, 81, 209, 110, 40, 255, 243, 4, 50, 125, 229, 106, 12, 203, 167, 160, 182, 233, 57, 166, 48, 215, 155, 124, 122, 149, 205, 34, 148, 35, 207, 152, 126, 129, 161, 222, 56, 175, 67, 244, 194, 173, 55, 252, 52, 71, 247, 144, 1, 27, 9, 86, 14, 101, 240, 108, 54, 227, 181, 146, 164, 218, 108, 136, 14, 177, 113, 9, 74, 95, 181, 228, 82, 221, 133, 74, 44, 43, 71, 248, 251, 73, 137, 134, 80, 55, 48, 172, 74, 200, 107, 250, 52, 69, 110, 253, 158, 224, 6, 24, 79, 15, 227, 114, 150, 13, 85, 186, 60, 218, 208, 112, 102, 121, 169, 231, 113, 246, 186, 236, 23, 133, 0, 114, 249, 27, 130, 104, 47, 139, 17, 47, 242, 191, 51, 48, 114, 60, 57, 236, 156, 77, 55, 128, 38, 84, 72, 195, 132, 50, 47, 153, 124, 240, 157, 249, 212, 202, 15, 24, 190, 65, 225, 158, 120, 111, 129, 180, 7, 115, 235, 155, 24, 7, 116, 80, 134, 217, 73, 194, 240, 83, 7, 44, 74, 132, 165, 127, 155, 211, 114, 20, 98, 69, 53, 34, 126, 93, 243, 254, 150, 157, 197, 31, 105, 235, 135, 65, 20, 9, 25, 9, 16, 247, 123, 28, 250, 148, 201, 130, 244, 122, 63, 56, 215, 168, 136, 94, 152, 199, 35, 148, 34, 205, 149, 122, 126, 155, 215, 48, 166, 57, 233, 166, 160, 167, 203, 14, exif:MaxApertureValue: 36/10 exif:MeteringMode: 2 exif:Model: NIKON D200 exif:Orientation: 1 exif:ResolutionUnit: 2 exif:Saturation: 0 exif:SceneCaptureType: 0 exif:SceneType: 1 exif:SensingMethod: 2 exif:Sharpness: 0 exif:Software: Ver.2.00 exif:SubjectDistanceRange: 0 exif:SubSecTime: 73 exif:SubSecTimeDigitized: 73 exif:SubSecTimeOriginal: 73 exif:UserComment: 65, 83, 67, 73, 73, 0, 0, 0, 66, 114, 121, 99, 101, 32, 67, 97, 110, 121, 111, 110, 32, 78, 80, 46, 32, 32, 84, 104, 111, 114, 39, 115, 32, 104, 97, 109, 109, 101, 114, 32, 40, 115, 105, 32, 106, 39, 97, 118, 97, 105, 115, 32, 117, 110, 32, 109, 97, 114, 116, 101, 97, 117, 32, 46, 46, 46, 41, 32, 77, 97, 105, 115, 32, 113, 117, 101, 32, 112, 111, 117, 118, 97, 105, 116, 32, 98, 105, 101, 110, 32, 118, 101, 110, 105, 114, 32, 102, 97, 105, 114, 101, 32, 84, 104, 111, 114, 32, 100, 97, 110, 115, 32, 99, 101, 116, 32, 101, 110, 100, 114, 111, 105, 116, 32, 63, 63, 32 exif:WhiteBalance: 1 exif:XResolution: 300/1 exif:YCbCrPositioning: 2 exif:YResolution: 300/1 jpeg:colorspace: 2 jpeg:sampling-factor: 2x1,1x1,1x1 signature: 70f55c68fa1f5a1e244988f290246cb5b6ee2939208fb6695c2c8994a945889d unknown: digiKam-0.9.2-final Profiles: Profile-8bim: 290 bytes Profile-exif: 12649 bytes Profile-iptc: 277 bytes Originating Program[2,65]: digiKam Program Version[2,70]: 0.9.2-final Caption[2,120]: Bryce Canyon NP. Thor's hammer (si j'avais un marteau ...) Mais que pouvait bien venir faire Thor dans cet endroit ?? Priority[2,10]: 5 Byline[2,80]: Pottier Michel Byline Title[2,85]: Credit[2,110]: Src[2,115]: Copyright String[2,116]: Pottier Created Date[2,55]: 20070730 Created Time[2,60]: 084454+0000 Keyword[2,25]: Nature/Paysage Keyword[2,25]: lieux/USA/Bryce NP Artifacts: filename: Bryce_2007_0102.jpg verbose: true Tainted: False Filesize: 5.595MB Number pixels: 10.04M Pixels per second: 10.68MB User time: 0.670u Elapsed time: 0:01.940 Version: ImageMagick 6.7.5-10 2012-08-22 Q16 http://www.imagemagick.org Look relevant info : Compression: JPEG Quality: 99 Gilles Caulier Code taken from IM JPEG codec : { ssize_t j, qvalue, sum; register ssize_t i; /* Determine the JPEG compression quality from the quantization tables. */ sum=0; for (i=0; i < NUM_QUANT_TBLS; i++) { if (jpeg_info->quant_tbl_ptrs[i] != NULL) for (j=0; j < DCTSIZE2; j++) sum+=jpeg_info->quant_tbl_ptrs[i]->quantval[j]; } if ((jpeg_info->quant_tbl_ptrs[0] != NULL) && (jpeg_info->quant_tbl_ptrs[1] != NULL)) { ssize_t hash[101] = { 1020, 1015, 932, 848, 780, 735, 702, 679, 660, 645, 632, 623, 613, 607, 600, 594, 589, 585, 581, 571, 555, 542, 529, 514, 494, 474, 457, 439, 424, 410, 397, 386, 373, 364, 351, 341, 334, 324, 317, 309, 299, 294, 287, 279, 274, 267, 262, 257, 251, 247, 243, 237, 232, 227, 222, 217, 213, 207, 202, 198, 192, 188, 183, 177, 173, 168, 163, 157, 153, 148, 143, 139, 132, 128, 125, 119, 115, 108, 104, 99, 94, 90, 84, 79, 74, 70, 64, 59, 55, 49, 45, 40, 34, 30, 25, 20, 15, 11, 6, 4, 0 }, sums[101] = { 32640, 32635, 32266, 31495, 30665, 29804, 29146, 28599, 28104, 27670, 27225, 26725, 26210, 25716, 25240, 24789, 24373, 23946, 23572, 22846, 21801, 20842, 19949, 19121, 18386, 17651, 16998, 16349, 15800, 15247, 14783, 14321, 13859, 13535, 13081, 12702, 12423, 12056, 11779, 11513, 11135, 10955, 10676, 10392, 10208, 9928, 9747, 9564, 9369, 9193, 9017, 8822, 8639, 8458, 8270, 8084, 7896, 7710, 7527, 7347, 7156, 6977, 6788, 6607, 6422, 6236, 6054, 5867, 5684, 5495, 5305, 5128, 4945, 4751, 4638, 4442, 4248, 4065, 3888, 3698, 3509, 3326, 3139, 2957, 2775, 2586, 2405, 2216, 2037, 1846, 1666, 1483, 1297, 1109, 927, 735, 554, 375, 201, 128, 0 }; qvalue=(ssize_t) (jpeg_info->quant_tbl_ptrs[0]->quantval[2]+ jpeg_info->quant_tbl_ptrs[0]->quantval[53]+ jpeg_info->quant_tbl_ptrs[1]->quantval[0]+ jpeg_info->quant_tbl_ptrs[1]->quantval[DCTSIZE2-1]); for (i=0; i < 100; i++) { if ((qvalue < hash[i]) && (sum < sums[i])) continue; if (((qvalue <= hash[i]) && (sum <= sums[i])) || (i >= 50)) image->quality=(size_t) i+1; if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Quality: %.20g (%s)",(double) i+1,(qvalue <= hash[i]) && (sum <= sums[i]) ? "exact" : "approximate"); break; } } else if (jpeg_info->quant_tbl_ptrs[0] != NULL) { ssize_t hash[101] = { 510, 505, 422, 380, 355, 338, 326, 318, 311, 305, 300, 297, 293, 291, 288, 286, 284, 283, 281, 280, 279, 278, 277, 273, 262, 251, 243, 233, 225, 218, 211, 205, 198, 193, 186, 181, 177, 172, 168, 164, 158, 156, 152, 148, 145, 142, 139, 136, 133, 131, 129, 126, 123, 120, 118, 115, 113, 110, 107, 105, 102, 100, 97, 94, 92, 89, 87, 83, 81, 79, 76, 74, 70, 68, 66, 63, 61, 57, 55, 52, 50, 48, 44, 42, 39, 37, 34, 31, 29, 26, 24, 21, 18, 16, 13, 11, 8, 6, 3, 2, 0 }, sums[101] = { 16320, 16315, 15946, 15277, 14655, 14073, 13623, 13230, 12859, 12560, 12240, 11861, 11456, 11081, 10714, 10360, 10027, 9679, 9368, 9056, 8680, 8331, 7995, 7668, 7376, 7084, 6823, 6562, 6345, 6125, 5939, 5756, 5571, 5421, 5240, 5086, 4976, 4829, 4719, 4616, 4463, 4393, 4280, 4166, 4092, 3980, 3909, 3835, 3755, 3688, 3621, 3541, 3467, 3396, 3323, 3247, 3170, 3096, 3021, 2952, 2874, 2804, 2727, 2657, 2583, 2509, 2437, 2362, 2290, 2211, 2136, 2068, 1996, 1915, 1858, 1773, 1692, 1620, 1552, 1477, 1398, 1326, 1251, 1179, 1109, 1031, 961, 884, 814, 736, 667, 592, 518, 441, 369, 292, 221, 151, 86, 64, 0 }; qvalue=(ssize_t) (jpeg_info->quant_tbl_ptrs[0]->quantval[2]+ jpeg_info->quant_tbl_ptrs[0]->quantval[53]); for (i=0; i < 100; i++) { if ((qvalue < hash[i]) && (sum < sums[i])) continue; if (((qvalue <= hash[i]) && (sum <= sums[i])) || (i >= 50)) image->quality=(size_t) i+1; if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Quality: %.20g (%s)",(double) i+1,(qvalue <= hash[i]) && (sum <= sums[i]) ? "exact" : "approximate"); break; } } } See JPEGSetImageQuality() method from here for details : https://www.imagemagick.org/subversion/ImageMagick/trunk/coders/jpeg.c Maik, Another entry not too difficult to implement as IM code is here. A new method must be created in JPEGUtils to determine the JPEG compression quality from the quantization tables. A new option in JPEG IO File Settings must be add to use it as well. Gilles Git commit e908aa4e278967ad7276086eeb9ee61a8400f29b by Maik Qualmann. Committed on 30/06/2015 at 20:11. Pushed by mqualmann into branch 'master'. function added to get the JPEG quality from image, first used for lossy transform M +168 -0 libs/jpegutils/jpegutils.cpp M +1 -0 libs/jpegutils/jpegutils.h http://commits.kde.org/digikam/e908aa4e278967ad7276086eeb9ee61a8400f29b Git commit 60b3d50b19920499cc34814e37da4fa229252589 by Gilles Caulier. Committed on 01/07/2015 at 07:58. Pushed by cgilles into branch 'frameworks'. backport commit #e908aa4e278967ad7276086eeb9ee61a8400f29b from git/master to frameworks branch M +168 -0 libs/jpegutils/jpegutils.cpp M +1 -0 libs/jpegutils/jpegutils.h http://commits.kde.org/digikam/60b3d50b19920499cc34814e37da4fa229252589 |