Skip to content

Commit 9c8c378

Browse files
committed
Fixed bug #72735 (Samsung picture thumb not read (zero size))
It seems like there is no maker data for "Samsung", this causes the IDF tag parsing to fail, and it bails early on, despite there still is valid remaining data in image, such as the thumbnail data as reported in the bug. I used the Exiv2 website as a reference guide for tags that's specific to Samsung's EXIF data, which should also mean that we will be able to name some of those tags more specifically now. I have chosen again not to commit this to other branches, simply because I'm not 100% sure on the byte order and offsets for Samsung, I did some research and it seems like there are many variants, but this (very copy/pasted), entry works for this particular image and does not break any other tests. This does add a new feature I suppose, while also fixing a bug, but I will leave it to the other branch RMs to decide on how far down they will want to merge this.
1 parent 1e02e52 commit 9c8c378

File tree

4 files changed

+60
-2
lines changed

4 files changed

+60
-2
lines changed

ext/exif/exif.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,40 @@ static tag_info_array tag_table_VND_OLYMPUS = {
955955
TAG_TABLE_END
956956
};
957957

958+
static tag_info_array tag_table_VND_SAMSUNG = {
959+
{ 0x0001, "Version"},
960+
{ 0x0021, "PictureWizard"},
961+
{ 0x0030, "LocalLocationName"},
962+
{ 0x0031, "LocationName"},
963+
{ 0x0035, "Preview"},
964+
{ 0x0043, "CameraTemperature"},
965+
{ 0xa001, "FirmwareName"},
966+
{ 0xa003, "LensType"},
967+
{ 0xa004, "LensFirmware"},
968+
{ 0xa010, "SensorAreas"},
969+
{ 0xa011, "ColorSpace"},
970+
{ 0xa012, "SmartRange"},
971+
{ 0xa013, "ExposureBiasValue"},
972+
{ 0xa014, "ISO"},
973+
{ 0xa018, "ExposureTime"},
974+
{ 0xa019, "FNumber"},
975+
{ 0xa01a, "FocalLengthIn35mmFormat"},
976+
{ 0xa020, "EncryptionKey"},
977+
{ 0xa021, "WB_RGGBLevelsUncorrected"},
978+
{ 0xa022, "WB_RGGBLevelsAuto"},
979+
{ 0xa023, "WB_RGGBLevelsIlluminator1"},
980+
{ 0xa024, "WB_RGGBLevelsIlluminator2"},
981+
{ 0xa028, "WB_RGGBLevelsBlack"},
982+
{ 0xa030, "ColorMatrix"},
983+
{ 0xa031, "ColorMatrixSRGB"},
984+
{ 0xa032, "ColorMatrixAdobeRGB"},
985+
{ 0xa040, "ToneCurve1"},
986+
{ 0xa041, "ToneCurve2"},
987+
{ 0xa042, "ToneCurve3"},
988+
{ 0xa043, "ToneCurve4"},
989+
TAG_TABLE_END
990+
};
991+
958992
typedef enum mn_byte_order_t {
959993
MN_ORDER_INTEL = 0,
960994
MN_ORDER_MOTOROLA = 1,
@@ -986,6 +1020,7 @@ static const maker_note_type maker_note_array[] = {
9861020
{ tag_table_VND_NIKON, "NIKON", NULL, "Nikon\x00\x01\x00", 8, 8, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
9871021
{ tag_table_VND_NIKON_990, "NIKON", NULL, NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
9881022
{ tag_table_VND_OLYMPUS, "OLYMPUS OPTICAL CO.,LTD", NULL, "OLYMP\x00\x01\x00", 8, 8, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
1023+
{ tag_table_VND_SAMSUNG, "SAMSUNG", NULL, NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL}
9891024
};
9901025
/* }}} */
9911026

@@ -2711,7 +2746,7 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
27112746
int NumDirEntries, old_motorola_intel, offset_diff;
27122747
const maker_note_type *maker_note;
27132748
char *dir_start;
2714-
2749+
27152750
for (i=0; i<=sizeof(maker_note_array)/sizeof(maker_note_type); i++) {
27162751
if (i==sizeof(maker_note_array)/sizeof(maker_note_type))
27172752
return FALSE;
@@ -2726,7 +2761,7 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
27262761
continue;
27272762
break;
27282763
}
2729-
2764+
27302765
if (maker_note->offset >= value_len) {
27312766
/* Do not go past the value end */
27322767
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short: 0x%04X offset 0x%04X", value_len, maker_note->offset);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Bug #72735 (Samsung picture thumb not read (zero size))
3+
--SKIPIF--
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5+
--FILE--
6+
<?php
7+
foreach (['nokia.jpg', 'samsung.jpg'] as $picture) {
8+
echo $picture . ': ';
9+
10+
$len = strlen(exif_thumbnail(__DIR__ . DIRECTORY_SEPARATOR . $picture));
11+
12+
if (!$len) {
13+
echo 'Error, no length returned', PHP_EOL;
14+
15+
continue;
16+
}
17+
18+
echo 'int(' . $len . ')', PHP_EOL;
19+
}
20+
?>
21+
--EXPECTF--
22+
nokia.jpg: int(5899)
23+
samsung.jpg: int(5778)

ext/exif/tests/bug72735/nokia.jpg

192 KB
Loading
158 KB
Loading

0 commit comments

Comments
 (0)