Lines Matching refs:ImageInfo

296 #define EXIF_ERRLOG_FILEEOF(ImageInfo)    exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, …  argument
297 #define EXIF_ERRLOG_CORRUPT(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, … argument
298 #define EXIF_ERRLOG_THUMBEOF(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, … argument
299 #define EXIF_ERRLOG_FSREALLOC(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, … argument
1558 static void exif_error_docref(const char *docref EXIFERR_DC, const image_info_type *ImageInfo, int … in exif_error_docref() argument
1568 php_verror(docref, ImageInfo->FileName?ImageInfo->FileName:"", type, buf, args); in exif_error_docref()
1572 php_verror(docref, ImageInfo->FileName?ImageInfo->FileName:"", type, format, args); in exif_error_docref()
1592 static int exif_file_sections_add(image_info_type *ImageInfo, int type, size_t size, uchar *data) in exif_file_sections_add() argument
1595 int count = ImageInfo->file.count; in exif_file_sections_add()
1597 tmp = safe_erealloc(ImageInfo->file.list, (count+1), sizeof(file_section), 0); in exif_file_sections_add()
1598 ImageInfo->file.list = tmp; in exif_file_sections_add()
1599 ImageInfo->file.list[count].type = 0xFFFF; in exif_file_sections_add()
1600 ImageInfo->file.list[count].data = NULL; in exif_file_sections_add()
1601 ImageInfo->file.list[count].size = 0; in exif_file_sections_add()
1602 ImageInfo->file.count = count+1; in exif_file_sections_add()
1608 ImageInfo->file.list[count].type = type; in exif_file_sections_add()
1609 ImageInfo->file.list[count].data = data; in exif_file_sections_add()
1610 ImageInfo->file.list[count].size = size; in exif_file_sections_add()
1618 static int exif_file_sections_realloc(image_info_type *ImageInfo, int section_index, size_t size) in exif_file_sections_realloc() argument
1625 if (section_index >= ImageInfo->file.count) { in exif_file_sections_realloc()
1626 EXIF_ERRLOG_FSREALLOC(ImageInfo) in exif_file_sections_realloc()
1629 tmp = safe_erealloc(ImageInfo->file.list[section_index].data, 1, size, 0); in exif_file_sections_realloc()
1630 ImageInfo->file.list[section_index].data = tmp; in exif_file_sections_realloc()
1631 ImageInfo->file.list[section_index].size = size; in exif_file_sections_realloc()
1639 static int exif_file_sections_free(image_info_type *ImageInfo) in exif_file_sections_free() argument
1643 if (ImageInfo->file.count) { in exif_file_sections_free()
1644 for (i=0; i<ImageInfo->file.count; i++) { in exif_file_sections_free()
1645 EFREE_IF(ImageInfo->file.list[i].data); in exif_file_sections_free()
1648 EFREE_IF(ImageInfo->file.list); in exif_file_sections_free()
1649 ImageInfo->file.count = 0; in exif_file_sections_free()
2274 static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, char *offset_base,…
2275 static int exif_process_IFD_TAG( image_info_type *ImageInfo, char *dir_entry, char *offset_base,…
2430 static void exif_thumbnail_build(image_info_type *ImageInfo) { in exif_thumbnail_build() argument
2441 if (!ImageInfo->read_thumbnail || !ImageInfo->Thumbnail.offset || !ImageInfo->Thumbnail.size) { in exif_thumbnail_build()
2445 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: filetype = %d", ImageInfo->Thu… in exif_thumbnail_build()
2447 switch(ImageInfo->Thumbnail.filetype) { in exif_thumbnail_build()
2454 info_list = &ImageInfo->info_list[SECTION_THUMBNAIL]; in exif_thumbnail_build()
2457 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: size of signature + directory(… in exif_thumbnail_build()
2468 new_data = safe_erealloc(ImageInfo->Thumbnail.data, 1, ImageInfo->Thumbnail.size, new_size); in exif_thumbnail_build()
2469 ImageInfo->Thumbnail.data = new_data; in exif_thumbnail_build()
2470 …memmove(ImageInfo->Thumbnail.data + new_move, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size… in exif_thumbnail_build()
2471 ImageInfo->Thumbnail.size += new_size; in exif_thumbnail_build()
2473 if (ImageInfo->motorola_intel) { in exif_thumbnail_build()
2479 php_ifd_set16u(new_data, info_list->count, ImageInfo->motorola_intel); in exif_thumbnail_build()
2485 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: process tag(x%04X=%s): %s%s (%… in exif_thumbnail_build()
2488 php_ifd_set16u(new_data + 0, info_data->tag, ImageInfo->motorola_intel); in exif_thumbnail_build()
2489 php_ifd_set16u(new_data + 2, TAG_FMT_ULONG, ImageInfo->motorola_intel); in exif_thumbnail_build()
2490 php_ifd_set32u(new_data + 4, 1, ImageInfo->motorola_intel); in exif_thumbnail_build()
2491 php_ifd_set32u(new_data + 8, new_move, ImageInfo->motorola_intel); in exif_thumbnail_build()
2493 php_ifd_set16u(new_data + 0, info_data->tag, ImageInfo->motorola_intel); in exif_thumbnail_build()
2494 php_ifd_set16u(new_data + 2, info_data->format, ImageInfo->motorola_intel); in exif_thumbnail_build()
2495 php_ifd_set32u(new_data + 4, info_data->length, ImageInfo->motorola_intel); in exif_thumbnail_build()
2496 value_ptr = exif_ifd_make_value(info_data, ImageInfo->motorola_intel); in exif_thumbnail_build()
2500 php_ifd_set32u(new_data+8, new_value, ImageInfo->motorola_intel); in exif_thumbnail_build()
2502 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: writing with value offset: 0x%… in exif_thumbnail_build()
2504 memmove(ImageInfo->Thumbnail.data+new_value, value_ptr, byte_count); in exif_thumbnail_build()
2513 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: created"); in exif_thumbnail_build()
2522 static void exif_thumbnail_extract(image_info_type *ImageInfo, char *offset, size_t length) { in exif_thumbnail_extract() argument
2523 if (ImageInfo->Thumbnail.data) { in exif_thumbnail_extract()
2524 …exif_error_docref("exif_read_data#error_mult_thumb" EXIFERR_CC, ImageInfo, E_WARNING, "Multiple po… in exif_thumbnail_extract()
2527 if (!ImageInfo->read_thumbnail) { in exif_thumbnail_extract()
2531 if (ImageInfo->Thumbnail.size >= 65536 in exif_thumbnail_extract()
2532 || ImageInfo->Thumbnail.size <= 0 in exif_thumbnail_extract()
2533 || ImageInfo->Thumbnail.offset <= 0 in exif_thumbnail_extract()
2535 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Illegal thumbnail size/offset"); in exif_thumbnail_extract()
2539 if (ImageInfo->Thumbnail.size > length in exif_thumbnail_extract()
2540 || (ImageInfo->Thumbnail.offset + ImageInfo->Thumbnail.size) > length in exif_thumbnail_extract()
2541 || ImageInfo->Thumbnail.offset > length - ImageInfo->Thumbnail.size in exif_thumbnail_extract()
2543 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_thumbnail_extract()
2546ImageInfo->Thumbnail.data = estrndup(offset + ImageInfo->Thumbnail.offset, ImageInfo->Thumbnail.si… in exif_thumbnail_extract()
2547 exif_thumbnail_build(ImageInfo); in exif_thumbnail_extract()
2605 static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoPtr, char **pszEncod… in exif_process_user_comment() argument
2630 } else if (ImageInfo->motorola_intel) { in exif_process_user_comment()
2631 decode = ImageInfo->decode_unicode_be; in exif_process_user_comment()
2633 decode = ImageInfo->decode_unicode_le; in exif_process_user_comment()
2635 to = zend_multibyte_fetch_encoding(ImageInfo->encode_unicode); in exif_process_user_comment()
2658 to = zend_multibyte_fetch_encoding(ImageInfo->encode_jis); in exif_process_user_comment()
2659 …from = zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_jis_be : ImageI… in exif_process_user_comment()
2693 static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char … in exif_process_unicode() argument
2703 zend_multibyte_fetch_encoding(ImageInfo->encode_unicode), in exif_process_unicode()
2704 …zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_unicode_be : ImageInfo in exif_process_unicode()
2714 static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * value_ptr, int value_le… in exif_process_IFD_in_MAKERNOTE() argument
2725 …(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "No maker note data found. Detected maker: %s (length = %d)… in exif_process_IFD_in_MAKERNOTE()
2734 if (maker_note->make && (!ImageInfo->make || strcmp(maker_note->make, ImageInfo->make))) in exif_process_IFD_in_MAKERNOTE()
2736 if (maker_note->model && (!ImageInfo->model || strcmp(maker_note->model, ImageInfo->model))) in exif_process_IFD_in_MAKERNOTE()
2745 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short… in exif_process_IFD_in_MAKERNOTE()
2752 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s @x%04X + 0x%04X=%d: %s", exif_… in exif_process_IFD_in_MAKERNOTE()
2755 ImageInfo->sections_found |= FOUND_MAKERNOTE; in exif_process_IFD_in_MAKERNOTE()
2757 old_motorola_intel = ImageInfo->motorola_intel; in exif_process_IFD_in_MAKERNOTE()
2760 ImageInfo->motorola_intel = 0; in exif_process_IFD_in_MAKERNOTE()
2763 ImageInfo->motorola_intel = 1; in exif_process_IFD_in_MAKERNOTE()
2770 NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); in exif_process_IFD_in_MAKERNOTE()
2780 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short… in exif_process_IFD_in_MAKERNOTE()
2783 offset_diff = 2 + NumDirEntries*12 + 4 - php_ifd_get32u(dir_start+10, ImageInfo->motorola_intel); in exif_process_IFD_in_MAKERNOTE()
2785 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Using automatic offset correction: 0x%04X… in exif_process_IFD_in_MAKERNOTE()
2788 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data bad offse… in exif_process_IFD_in_MAKERNOTE()
2800 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_MAKERNOTE()
2805 if (!exif_process_IFD_TAG(ImageInfo, dir_start + 2 + 12 * de, in exif_process_IFD_in_MAKERNOTE()
2810 ImageInfo->motorola_intel = old_motorola_intel; in exif_process_IFD_in_MAKERNOTE()
2813 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Subsection %s done", exif_get_sectionname… in exif_process_IFD_in_MAKERNOTE()
2821 static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, char *offset_base, siz… in exif_process_IFD_TAG() argument
2835 if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) { in exif_process_IFD_TAG()
2836 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "corrupt EXIF heade… in exif_process_IFD_TAG()
2839 ImageInfo->ifd_nesting_level++; in exif_process_IFD_TAG()
2841 tag = php_ifd_get16u(dir_entry, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2842 format = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2843 components = php_ifd_get32u(dir_entry+4, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2847 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG()
2853 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG()
2860 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG()
2867 offset_val = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2879ImageInfo->FileSize || offset_val>ImageInfo->FileSize-byte_count || (ImageInfo->FileType!=IMAGE_FI… in exif_process_IFD_TAG()
2883 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG()
2887 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG()
2905 fpos = php_stream_tell(ImageInfo->infile); in exif_process_IFD_TAG()
2906 php_stream_seek(ImageInfo->infile, displacement+offset_val, SEEK_SET); in exif_process_IFD_TAG()
2907 fgot = php_stream_tell(ImageInfo->infile); in exif_process_IFD_TAG()
2910 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Wrong file pointer: 0x%08X != 0x%08X", f… in exif_process_IFD_TAG()
2913 fgot = php_stream_read(ImageInfo->infile, value_ptr, byte_count); in exif_process_IFD_TAG()
2914 php_stream_seek(ImageInfo->infile, fpos, SEEK_SET); in exif_process_IFD_TAG()
2917 EXIF_ERRLOG_FILEEOF(ImageInfo) in exif_process_IFD_TAG()
2927 ImageInfo->sections_found |= FOUND_ANY_TAG; in exif_process_IFD_TAG()
2929 …dump_data = exif_dump_data(&dump_free, format, components, length, ImageInfo->motorola_intel, valu… in exif_process_IFD_TAG()
2930 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process tag(x%04X=%s,@x%04X + x%04X(=%d))… in exif_process_IFD_TAG()
2937 if (!ImageInfo->Thumbnail.data) { in exif_process_IFD_TAG()
2941ImageInfo->Thumbnail.width = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2946ImageInfo->Thumbnail.height = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel… in exif_process_IFD_TAG()
2952ImageInfo->Thumbnail.offset = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel… in exif_process_IFD_TAG()
2956 …if (ImageInfo->FileType == IMAGE_FILETYPE_TIFF_II || ImageInfo->FileType == IMAGE_FILETYPE_TIFF_MM… in exif_process_IFD_TAG()
2957 ImageInfo->Thumbnail.filetype = ImageInfo->FileType; in exif_process_IFD_TAG()
2960 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_TIFF_MM; in exif_process_IFD_TAG()
2962ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2966 if (ImageInfo->Thumbnail.filetype == IMAGE_FILETYPE_UNKNOWN) { in exif_process_IFD_TAG()
2967 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_JPEG; in exif_process_IFD_TAG()
2968ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2981 ImageInfo->CopyrightPhotographer = estrdup(value_ptr); in exif_process_IFD_TAG()
2982 ImageInfo->CopyrightEditor = estrndup(value_ptr+length+1, byte_count-length-1); in exif_process_IFD_TAG()
2983 …spprintf(&ImageInfo->Copyright, 0, "%s, %s", ImageInfo->CopyrightPhotographer, ImageInfo->Copyrigh… in exif_process_IFD_TAG()
2988 ImageInfo->Copyright = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG()
2994ImageInfo->UserCommentLength = exif_process_user_comment(ImageInfo, &(ImageInfo->UserComment), &(I… in exif_process_IFD_TAG()
3002 …tmp_xp = (xp_field_type*)safe_erealloc(ImageInfo->xp_fields.list, (ImageInfo->xp_fields.count+1), … in exif_process_IFD_TAG()
3003 ImageInfo->sections_found |= FOUND_WINXP; in exif_process_IFD_TAG()
3004 ImageInfo->xp_fields.list = tmp_xp; in exif_process_IFD_TAG()
3005 ImageInfo->xp_fields.count++; in exif_process_IFD_TAG()
3006 …exif_process_unicode(ImageInfo, &(ImageInfo->xp_fields.list[ImageInfo->xp_fields.count-1]), tag, v… in exif_process_IFD_TAG()
3012ImageInfo->ApertureFNumber = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola… in exif_process_IFD_TAG()
3019 if (ImageInfo->ApertureFNumber == 0) { in exif_process_IFD_TAG()
3020 ImageInfo->ApertureFNumber in exif_process_IFD_TAG()
3021 … = (float)exp(exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)*log(2)*0.5); in exif_process_IFD_TAG()
3030 if (ImageInfo->ExposureTime == 0) { in exif_process_IFD_TAG()
3031 ImageInfo->ExposureTime in exif_process_IFD_TAG()
3032 … = (float)(1/exp(exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)*log(2))); in exif_process_IFD_TAG()
3036 ImageInfo->ExposureTime = -1; in exif_process_IFD_TAG()
3040ImageInfo->ExifImageWidth = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
3044ImageInfo->FocalplaneXRes = exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
3050ImageInfo->Distance = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
3054 switch((int)exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)) { in exif_process_IFD_TAG()
3055 case 1: ImageInfo->FocalplaneUnits = 25.4; break; /* inch */ in exif_process_IFD_TAG()
3060 ImageInfo->FocalplaneUnits = 25.4; in exif_process_IFD_TAG()
3063 case 3: ImageInfo->FocalplaneUnits = 10; break; /* centimeter */ in exif_process_IFD_TAG()
3064 case 4: ImageInfo->FocalplaneUnits = 1; break; /* milimeter */ in exif_process_IFD_TAG()
3065 case 5: ImageInfo->FocalplaneUnits = .001; break; /* micrometer */ in exif_process_IFD_TAG()
3074 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Skip SUB IFD"); in exif_process_IFD_TAG()
3079 ImageInfo->make = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG()
3082 ImageInfo->model = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG()
3086 …if (!exif_process_IFD_in_MAKERNOTE(ImageInfo, value_ptr, byte_count, offset_base, IFDlength, displ… in exif_process_IFD_TAG()
3101 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found EXIF"); in exif_process_IFD_TAG()
3103 ImageInfo->sections_found |= FOUND_EXIF; in exif_process_IFD_TAG()
3108 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found GPS"); in exif_process_IFD_TAG()
3110 ImageInfo->sections_found |= FOUND_GPS; in exif_process_IFD_TAG()
3115 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found INTEROPERABILITY"); in exif_process_IFD_TAG()
3117 ImageInfo->sections_found |= FOUND_INTEROP; in exif_process_IFD_TAG()
3121 Subdir_start = offset_base + php_ifd_get32u(value_ptr, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
3123 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD Pointe… in exif_process_IFD_TAG()
3126 …if (!exif_process_IFD_in_JPEG(ImageInfo, Subdir_start, offset_base, IFDlength, displacement, sub_s… in exif_process_IFD_TAG()
3130 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Subsection %s done", exif_get_sectionname… in exif_process_IFD_TAG()
3135 …exif_iif_add_tag(ImageInfo, section_index, exif_get_tagname(tag, tagname, sizeof(tagname), tag_tab… in exif_process_IFD_TAG()
3143 static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, char *offset_base,… in exif_process_IFD_in_JPEG() argument
3150 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s (x%04X(=%d))", exif_get_sectio… in exif_process_IFD_in_JPEG()
3153 ImageInfo->sections_found |= FOUND_IFD0; in exif_process_IFD_in_JPEG()
3156 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size"); in exif_process_IFD_in_JPEG()
3160 NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); in exif_process_IFD_in_JPEG()
3163 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_JPEG()
3168 if (!exif_process_IFD_TAG(ImageInfo, dir_start + 2 + 12 * de, in exif_process_IFD_in_JPEG()
3184 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size"); in exif_process_IFD_in_JPEG()
3187 NextDirOffset = php_ifd_get32u(dir_start+2+12*de, ImageInfo->motorola_intel); in exif_process_IFD_in_JPEG()
3191 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD offset… in exif_process_IFD_in_JPEG()
3196 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Expect next IFD to be thumbnail"); in exif_process_IFD_in_JPEG()
3198 …if (exif_process_IFD_in_JPEG(ImageInfo, offset_base + NextDirOffset, offset_base, IFDlength, displ… in exif_process_IFD_in_JPEG()
3200 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail size: 0x%04X", ImageInfo->Thumb… in exif_process_IFD_in_JPEG()
3202 if (ImageInfo->Thumbnail.filetype != IMAGE_FILETYPE_UNKNOWN in exif_process_IFD_in_JPEG()
3203 && ImageInfo->Thumbnail.size in exif_process_IFD_in_JPEG()
3204 && ImageInfo->Thumbnail.offset in exif_process_IFD_in_JPEG()
3205 && ImageInfo->read_thumbnail in exif_process_IFD_in_JPEG()
3207 exif_thumbnail_extract(ImageInfo, offset_base, IFDlength); in exif_process_IFD_in_JPEG()
3221 static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf, size_t length, siz… in exif_process_TIFF_in_JPEG() argument
3227 ImageInfo->motorola_intel = 0; in exif_process_TIFF_in_JPEG()
3229 ImageInfo->motorola_intel = 1; in exif_process_TIFF_in_JPEG()
3231 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF alignment marker"); in exif_process_TIFF_in_JPEG()
3237 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF start (1)"); in exif_process_TIFF_in_JPEG()
3240 exif_value_2a = php_ifd_get16u(CharBuf+2, ImageInfo->motorola_intel); in exif_process_TIFF_in_JPEG()
3241 offset_of_ifd = php_ifd_get32u(CharBuf+4, ImageInfo->motorola_intel); in exif_process_TIFF_in_JPEG()
3243 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF start (1)"); in exif_process_TIFF_in_JPEG()
3247 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid IFD start"); in exif_process_TIFF_in_JPEG()
3251 ImageInfo->sections_found |= FOUND_IFD0; in exif_process_TIFF_in_JPEG()
3253 …exif_process_IFD_in_JPEG(ImageInfo, CharBuf+offset_of_ifd, CharBuf, length/*-14*/, displacement, S… in exif_process_TIFF_in_JPEG()
3256 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process TIFF in JPEG done"); in exif_process_TIFF_in_JPEG()
3260 if (ImageInfo->FocalplaneXRes != 0) { in exif_process_TIFF_in_JPEG()
3261ImageInfo->CCDWidth = (float)(ImageInfo->ExifImageWidth * ImageInfo->FocalplaneUnits / ImageInfo->… in exif_process_TIFF_in_JPEG()
3270 static void exif_process_APP1(image_info_type *ImageInfo, char *CharBuf, size_t length, size_t disp… in exif_process_APP1() argument
3275 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Incorrect APP1 Exif Identifier Code"); in exif_process_APP1()
3278 exif_process_TIFF_in_JPEG(ImageInfo, CharBuf + 8, length - 8, displacement+8); in exif_process_APP1()
3280 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process APP1/EXIF done"); in exif_process_APP1()
3288 static void exif_process_APP12(image_info_type *ImageInfo, char *buffer, size_t length) in exif_process_APP12() argument
3293 exif_iif_add_tag(ImageInfo, SECTION_APP12, "Company", TAG_NONE, TAG_FMT_STRING, l1, buffer+2); in exif_process_APP12()
3296 exif_iif_add_tag(ImageInfo, SECTION_APP12, "Info", TAG_NONE, TAG_FMT_STRING, l2, buffer+2+l1+1); in exif_process_APP12()
3300 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process section APP12 with l1=%d, l2=%d d… in exif_process_APP12()
3307 static int exif_scan_JPEG_header(image_info_type *ImageInfo) in exif_scan_JPEG_header() argument
3318 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3319 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Needing section %d @ 0x%08X", ImageInfo->… in exif_scan_JPEG_header()
3329 if ((marker = php_stream_getc(ImageInfo->infile)) == EOF) { in exif_scan_JPEG_header()
3330 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3343 …exif_error_docref("exif_read_data#error_mcom" EXIFERR_CC, ImageInfo, E_NOTICE, "Image has corrupt … in exif_scan_JPEG_header()
3348 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3352 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "To many padding bytes"); in exif_scan_JPEG_header()
3357 if ((lh = php_stream_getc(ImageInfo->infile)) == EOF) { in exif_scan_JPEG_header()
3358 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3361 if ((ll = php_stream_getc(ImageInfo->infile)) == EOF) { in exif_scan_JPEG_header()
3362 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3370 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "%s, Section length: 0x%02X%02X", EXIF_ER… in exif_scan_JPEG_header()
3372 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3377 sn = exif_file_sections_add(ImageInfo, marker, itemlen+1, NULL); in exif_scan_JPEG_header()
3378 Data = ImageInfo->file.list[sn].data; in exif_scan_JPEG_header()
3384 …got = php_stream_read(ImageInfo->infile, (char*)(Data+2), itemlen-2); /* Read the whole section. */ in exif_scan_JPEG_header()
3386 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error reading from file: got=x%04X(=%d) … in exif_scan_JPEG_header()
3391 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process section(x%02X=%s) @ x%04X + x%04X… in exif_scan_JPEG_header()
3396 if (ImageInfo->read_all) { in exif_scan_JPEG_header()
3398 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3399 size = ImageInfo->FileSize - fpos; in exif_scan_JPEG_header()
3400 sn = exif_file_sections_add(ImageInfo, M_PSEUDO, size, NULL); in exif_scan_JPEG_header()
3401 Data = ImageInfo->file.list[sn].data; in exif_scan_JPEG_header()
3402 got = php_stream_read(ImageInfo->infile, (char*)Data, size); in exif_scan_JPEG_header()
3404 EXIF_ERRLOG_FILEEOF(ImageInfo) in exif_scan_JPEG_header()
3411 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "No image in jpeg!"); in exif_scan_JPEG_header()
3412 return (ImageInfo->sections_found&(~FOUND_COMPUTED)) ? TRUE : FALSE; in exif_scan_JPEG_header()
3415 exif_process_COM(ImageInfo, (char *)Data, itemlen); in exif_scan_JPEG_header()
3419 if (!(ImageInfo->sections_found&FOUND_IFD0)) { in exif_scan_JPEG_header()
3423 exif_process_APP1(ImageInfo, (char *)Data, itemlen, fpos); in exif_scan_JPEG_header()
3428 exif_process_APP12(ImageInfo, (char *)Data, itemlen); in exif_scan_JPEG_header()
3450 ImageInfo->Width = sof_info.width; in exif_scan_JPEG_header()
3451 ImageInfo->Height = sof_info.height; in exif_scan_JPEG_header()
3453 ImageInfo->IsColor = 1; in exif_scan_JPEG_header()
3455 ImageInfo->IsColor = 0; in exif_scan_JPEG_header()
3467 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Done"); in exif_scan_JPEG_header()
3475 static int exif_scan_thumbnail(image_info_type *ImageInfo) in exif_scan_thumbnail() argument
3477 uchar c, *data = (uchar*)ImageInfo->Thumbnail.data; in exif_scan_thumbnail()
3486 if (!ImageInfo->Thumbnail.width && !ImageInfo->Thumbnail.height) { in exif_scan_thumbnail()
3487 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Thumbnail is not a JPEG image"); in exif_scan_thumbnail()
3493 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3496 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3503 if (pos+3>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3511 if (pos+length>=ImageInfo->Thumbnail.size) { in exif_scan_thumbnail()
3515 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: process section(x%02X=%s) @ x%… in exif_scan_thumbnail()
3533 ImageInfo->Thumbnail.height = sof_info.height; in exif_scan_thumbnail()
3534 ImageInfo->Thumbnail.width = sof_info.width; in exif_scan_thumbnail()
3536 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: size: %d * %d", sof_info.width… in exif_scan_thumbnail()
3542 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Could not compute size of thumbnail"); in exif_scan_thumbnail()
3552 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Could not compute size of thumbnail"); in exif_scan_thumbnail()
3559 static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offset, int section_inde… in exif_process_IFD_in_TIFF() argument
3568 if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) { in exif_process_IFD_in_TIFF()
3572 if (ImageInfo->FileSize >= dir_offset+2) { in exif_process_IFD_in_TIFF()
3573 sn = exif_file_sections_add(ImageInfo, M_PSEUDO, 2, NULL); in exif_process_IFD_in_TIFF()
3575 …f_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF: filesize(x%04X), IFD dir(x%0… in exif_process_IFD_in_TIFF()
3577 …php_stream_seek(ImageInfo->infile, dir_offset, SEEK_SET); /* we do not know the order of sections … in exif_process_IFD_in_TIFF()
3578 php_stream_read(ImageInfo->infile, (char*)ImageInfo->file.list[sn].data, 2); in exif_process_IFD_in_TIFF()
3579 num_entries = php_ifd_get16u(ImageInfo->file.list[sn].data, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3581 if (ImageInfo->FileSize >= dir_offset+dir_size) { in exif_process_IFD_in_TIFF()
3583 …ocref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF: filesize(x%04X), IFD dir(x%04X + x%04… in exif_process_IFD_in_TIFF()
3585 if (exif_file_sections_realloc(ImageInfo, sn, dir_size)) { in exif_process_IFD_in_TIFF()
3588 php_stream_read(ImageInfo->infile, (char*)(ImageInfo->file.list[sn].data+2), dir_size-2); in exif_process_IFD_in_TIFF()
3590 …next_offset = php_ifd_get32u(ImageInfo->file.list[sn].data + dir_size - 4, ImageInfo->motorola_int… in exif_process_IFD_in_TIFF()
3592 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF done, next offset x%04X", … in exif_process_IFD_in_TIFF()
3597 dir_entry = ImageInfo->file.list[sn].data+2+i*12; in exif_process_IFD_in_TIFF()
3598 entry_tag = php_ifd_get16u(dir_entry+0, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3599 entry_type = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3601 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF: tag(0x%04X,%12s): Illegal… in exif_process_IFD_in_TIFF()
3609 …entry_length = php_ifd_get32u(dir_entry+4, ImageInfo->motorola_intel) * php_tiff_bytes_per_format[… in exif_process_IFD_in_TIFF()
3613 entry_value = php_ifd_get16u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3616 entry_value = php_ifd_get16s(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3619 entry_value = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3622 entry_value = php_ifd_get32s(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3628 ImageInfo->Width = entry_value; in exif_process_IFD_in_TIFF()
3632 ImageInfo->Height = entry_value; in exif_process_IFD_in_TIFF()
3639 ImageInfo->IsColor = 0; in exif_process_IFD_in_TIFF()
3646 ImageInfo->IsColor = 1; in exif_process_IFD_in_TIFF()
3652 entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3659 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Resize struct: x%04X + x%04X - x%04X = x%… in exif_process_IFD_in_TIFF()
3664 if (ImageInfo->FileSize >= dir_offset + ImageInfo->file.list[sn].size) { in exif_process_IFD_in_TIFF()
3666 if (dir_offset + ifd_size > ImageInfo->FileSize) { in exif_process_IFD_in_TIFF()
3667 …_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than size of I… in exif_process_IFD_in_TIFF()
3670 if (exif_file_sections_realloc(ImageInfo, sn, ifd_size)) { in exif_process_IFD_in_TIFF()
3675 …xif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF: filesize(x%04X), IFD(x%04X… in exif_process_IFD_in_TIFF()
3677 …php_stream_read(ImageInfo->infile, (char*)(ImageInfo->file.list[sn].data+dir_size), ifd_size-dir_s… in exif_process_IFD_in_TIFF()
3679 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF, done"); in exif_process_IFD_in_TIFF()
3684 dir_entry = ImageInfo->file.list[sn].data+2+i*12; in exif_process_IFD_in_TIFF()
3685 entry_tag = php_ifd_get16u(dir_entry+0, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3686 entry_type = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3695 ImageInfo->sections_found |= FOUND_EXIF; in exif_process_IFD_in_TIFF()
3699 ImageInfo->sections_found |= FOUND_GPS; in exif_process_IFD_in_TIFF()
3703 ImageInfo->sections_found |= FOUND_INTEROP; in exif_process_IFD_in_TIFF()
3707 ImageInfo->sections_found |= FOUND_THUMBNAIL; in exif_process_IFD_in_TIFF()
3711 entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3713 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s @x%04X", exif_get_sectionnam… in exif_process_IFD_in_TIFF()
3715 ImageInfo->ifd_nesting_level++; in exif_process_IFD_in_TIFF()
3716 exif_process_IFD_in_TIFF(ImageInfo, entry_offset, sub_section_index); in exif_process_IFD_in_TIFF()
3718 if (ImageInfo->Thumbnail.filetype != IMAGE_FILETYPE_UNKNOWN in exif_process_IFD_in_TIFF()
3719 && ImageInfo->Thumbnail.size in exif_process_IFD_in_TIFF()
3720 && ImageInfo->Thumbnail.offset in exif_process_IFD_in_TIFF()
3721 && ImageInfo->read_thumbnail in exif_process_IFD_in_TIFF()
3724 …RR_CC, ImageInfo, E_NOTICE, "%s THUMBNAIL @0x%04X + 0x%04X", ImageInfo->Thumbnail.data ? "Ignore" … in exif_process_IFD_in_TIFF()
3726 if (!ImageInfo->Thumbnail.data) { in exif_process_IFD_in_TIFF()
3727 ImageInfo->Thumbnail.data = safe_emalloc(ImageInfo->Thumbnail.size, 1, 0); in exif_process_IFD_in_TIFF()
3728 php_stream_seek(ImageInfo->infile, ImageInfo->Thumbnail.offset, SEEK_SET); in exif_process_IFD_in_TIFF()
3729 … fgot = php_stream_read(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size); in exif_process_IFD_in_TIFF()
3730 if (fgot < ImageInfo->Thumbnail.size) { in exif_process_IFD_in_TIFF()
3731 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_process_IFD_in_TIFF()
3732 efree(ImageInfo->Thumbnail.data); in exif_process_IFD_in_TIFF()
3733 ImageInfo->Thumbnail.data = NULL; in exif_process_IFD_in_TIFF()
3735 exif_thumbnail_build(ImageInfo); in exif_process_IFD_in_TIFF()
3741 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s done", exif_get_sectionname(… in exif_process_IFD_in_TIFF()
3744 if (!exif_process_IFD_TAG(ImageInfo, (char*)dir_entry, in exif_process_IFD_in_TIFF()
3745 (char*)(ImageInfo->file.list[sn].data-dir_offset), in exif_process_IFD_in_TIFF()
3756 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read next IFD (THUMBNAIL) at x%04X", next… in exif_process_IFD_in_TIFF()
3758 ImageInfo->ifd_nesting_level++; in exif_process_IFD_in_TIFF()
3759 exif_process_IFD_in_TIFF(ImageInfo, next_offset, SECTION_THUMBNAIL); in exif_process_IFD_in_TIFF()
3761 …RR_CC, ImageInfo, E_NOTICE, "%s THUMBNAIL @0x%04X + 0x%04X", ImageInfo->Thumbnail.data ? "Ignore" … in exif_process_IFD_in_TIFF()
3763 …if (!ImageInfo->Thumbnail.data && ImageInfo->Thumbnail.offset && ImageInfo->Thumbnail.size && Imag… in exif_process_IFD_in_TIFF()
3764 ImageInfo->Thumbnail.data = safe_emalloc(ImageInfo->Thumbnail.size, 1, 0); in exif_process_IFD_in_TIFF()
3765 php_stream_seek(ImageInfo->infile, ImageInfo->Thumbnail.offset, SEEK_SET); in exif_process_IFD_in_TIFF()
3766 … fgot = php_stream_read(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size); in exif_process_IFD_in_TIFF()
3767 if (fgot < ImageInfo->Thumbnail.size) { in exif_process_IFD_in_TIFF()
3768 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_process_IFD_in_TIFF()
3769 efree(ImageInfo->Thumbnail.data); in exif_process_IFD_in_TIFF()
3770 ImageInfo->Thumbnail.data = NULL; in exif_process_IFD_in_TIFF()
3772 exif_thumbnail_build(ImageInfo); in exif_process_IFD_in_TIFF()
3776 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read next IFD (THUMBNAIL) done"); in exif_process_IFD_in_TIFF()
3781 … EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than size of IFD(x%04X)", in exif_process_IFD_in_TIFF()
3785 …or_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than size of… in exif_process_IFD_in_TIFF()
3789 …or_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than start o… in exif_process_IFD_in_TIFF()
3797 static int exif_scan_FILE_header(image_info_type *ImageInfo) in exif_scan_FILE_header() argument
3802 ImageInfo->FileType = IMAGE_FILETYPE_UNKNOWN; in exif_scan_FILE_header()
3804 if (ImageInfo->FileSize >= 2) { in exif_scan_FILE_header()
3805 php_stream_seek(ImageInfo->infile, 0, SEEK_SET); in exif_scan_FILE_header()
3806 if (php_stream_read(ImageInfo->infile, (char*)file_header, 2) != 2) { in exif_scan_FILE_header()
3810 ImageInfo->FileType = IMAGE_FILETYPE_JPEG; in exif_scan_FILE_header()
3811 if (exif_scan_JPEG_header(ImageInfo)) { in exif_scan_FILE_header()
3814 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid JPEG file"); in exif_scan_FILE_header()
3816 } else if (ImageInfo->FileSize >= 8) { in exif_scan_FILE_header()
3817 if (php_stream_read(ImageInfo->infile, (char*)(file_header+2), 6) != 6) { in exif_scan_FILE_header()
3821 ImageInfo->FileType = IMAGE_FILETYPE_TIFF_II; in exif_scan_FILE_header()
3822 ImageInfo->motorola_intel = 0; in exif_scan_FILE_header()
3824 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "File has TIFF/II format"); in exif_scan_FILE_header()
3826 ImageInfo->sections_found |= FOUND_IFD0; in exif_scan_FILE_header()
3827 if (exif_process_IFD_in_TIFF(ImageInfo, in exif_scan_FILE_header()
3828 php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel), in exif_scan_FILE_header()
3832 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF file"); in exif_scan_FILE_header()
3835 ImageInfo->FileType = IMAGE_FILETYPE_TIFF_MM; in exif_scan_FILE_header()
3836 ImageInfo->motorola_intel = 1; in exif_scan_FILE_header()
3838 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "File has TIFF/MM format"); in exif_scan_FILE_header()
3840 ImageInfo->sections_found |= FOUND_IFD0; in exif_scan_FILE_header()
3841 if (exif_process_IFD_in_TIFF(ImageInfo, in exif_scan_FILE_header()
3842 php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel), in exif_scan_FILE_header()
3846 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF file"); in exif_scan_FILE_header()
3849 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "File not supported"); in exif_scan_FILE_header()
3854 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "File too small (%d)", ImageInfo->FileSiz… in exif_scan_FILE_header()
3863 static int exif_discard_imageinfo(image_info_type *ImageInfo) in exif_discard_imageinfo() argument
3867 EFREE_IF(ImageInfo->FileName); in exif_discard_imageinfo()
3868 EFREE_IF(ImageInfo->UserComment); in exif_discard_imageinfo()
3869 EFREE_IF(ImageInfo->UserCommentEncoding); in exif_discard_imageinfo()
3870 EFREE_IF(ImageInfo->Copyright); in exif_discard_imageinfo()
3871 EFREE_IF(ImageInfo->CopyrightPhotographer); in exif_discard_imageinfo()
3872 EFREE_IF(ImageInfo->CopyrightEditor); in exif_discard_imageinfo()
3873 EFREE_IF(ImageInfo->Thumbnail.data); in exif_discard_imageinfo()
3874 EFREE_IF(ImageInfo->encode_unicode); in exif_discard_imageinfo()
3875 EFREE_IF(ImageInfo->decode_unicode_be); in exif_discard_imageinfo()
3876 EFREE_IF(ImageInfo->decode_unicode_le); in exif_discard_imageinfo()
3877 EFREE_IF(ImageInfo->encode_jis); in exif_discard_imageinfo()
3878 EFREE_IF(ImageInfo->decode_jis_be); in exif_discard_imageinfo()
3879 EFREE_IF(ImageInfo->decode_jis_le); in exif_discard_imageinfo()
3880 EFREE_IF(ImageInfo->make); in exif_discard_imageinfo()
3881 EFREE_IF(ImageInfo->model); in exif_discard_imageinfo()
3882 for (i=0; i<ImageInfo->xp_fields.count; i++) { in exif_discard_imageinfo()
3883 EFREE_IF(ImageInfo->xp_fields.list[i].value); in exif_discard_imageinfo()
3885 EFREE_IF(ImageInfo->xp_fields.list); in exif_discard_imageinfo()
3887 exif_iif_free(ImageInfo, i); in exif_discard_imageinfo()
3889 exif_file_sections_free(ImageInfo); in exif_discard_imageinfo()
3890 memset(ImageInfo, 0, sizeof(*ImageInfo)); in exif_discard_imageinfo()
3897 static int exif_read_file(image_info_type *ImageInfo, char *FileName, int read_thumbnail, int read_… in exif_read_file() argument
3904 memset(ImageInfo, 0, sizeof(*ImageInfo)); in exif_read_file()
3906 ImageInfo->motorola_intel = -1; /* flag as unknown */ in exif_read_file()
3908 ImageInfo->infile = php_stream_open_wrapper(FileName, "rb", STREAM_MUST_SEEK|IGNORE_PATH, NULL); in exif_read_file()
3909 if (!ImageInfo->infile) { in exif_read_file()
3910 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Unable to open file"); in exif_read_file()
3914 if (php_stream_is(ImageInfo->infile, PHP_STREAM_IS_STDIO)) { in exif_read_file()
3917 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Not a file"); in exif_read_file()
3918 php_stream_close(ImageInfo->infile); in exif_read_file()
3923 ImageInfo->FileDateTime = st.st_mtime; in exif_read_file()
3924 ImageInfo->FileSize = st.st_size; in exif_read_file()
3928 if (!ImageInfo->FileSize) { in exif_read_file()
3929 php_stream_seek(ImageInfo->infile, 0, SEEK_END); in exif_read_file()
3930 ImageInfo->FileSize = php_stream_tell(ImageInfo->infile); in exif_read_file()
3931 php_stream_seek(ImageInfo->infile, 0, SEEK_SET); in exif_read_file()
3936 ImageInfo->FileName = estrndup(ZSTR_VAL(base), ZSTR_LEN(base)); in exif_read_file()
3938 ImageInfo->read_thumbnail = read_thumbnail; in exif_read_file()
3939 ImageInfo->read_all = read_all; in exif_read_file()
3940 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_UNKNOWN; in exif_read_file()
3942 ImageInfo->encode_unicode = estrdup(EXIF_G(encode_unicode)); in exif_read_file()
3943 ImageInfo->decode_unicode_be = estrdup(EXIF_G(decode_unicode_be)); in exif_read_file()
3944 ImageInfo->decode_unicode_le = estrdup(EXIF_G(decode_unicode_le)); in exif_read_file()
3945 ImageInfo->encode_jis = estrdup(EXIF_G(encode_jis)); in exif_read_file()
3946 ImageInfo->decode_jis_be = estrdup(EXIF_G(decode_jis_be)); in exif_read_file()
3947 ImageInfo->decode_jis_le = estrdup(EXIF_G(decode_jis_le)); in exif_read_file()
3950 ImageInfo->ifd_nesting_level = 0; in exif_read_file()
3953 ret = exif_scan_FILE_header(ImageInfo); in exif_read_file()
3955 php_stream_close(ImageInfo->infile); in exif_read_file()
3969 image_info_type ImageInfo; in PHP_FUNCTION() local
3976 memset(&ImageInfo, 0, sizeof(ImageInfo)); in PHP_FUNCTION()
4001 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections needed: %s", sections_str[0] ? … in PHP_FUNCTION()
4006 ret = exif_read_file(&ImageInfo, p_name, read_thumbnail, read_all); in PHP_FUNCTION()
4007 sections_str = exif_get_sectionlist(ImageInfo.sections_found); in PHP_FUNCTION()
4011 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections found: %s", sections_str[0] ? s… in PHP_FUNCTION()
4014 ImageInfo.sections_found |= FOUND_COMPUTED|FOUND_FILE;/* do not inform about in debug*/ in PHP_FUNCTION()
4016 if (ret == FALSE || (sections_needed && !(sections_needed&ImageInfo.sections_found))) { in PHP_FUNCTION()
4018 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4026 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section FILE"); in PHP_FUNCTION()
4030 exif_iif_add_str(&ImageInfo, SECTION_FILE, "FileName", ImageInfo.FileName); in PHP_FUNCTION()
4031 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileDateTime", ImageInfo.FileDateTime); in PHP_FUNCTION()
4032 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileSize", ImageInfo.FileSize); in PHP_FUNCTION()
4033 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileType", ImageInfo.FileType); in PHP_FUNCTION()
4034 …exif_iif_add_str(&ImageInfo, SECTION_FILE, "MimeType", (char*)php_image_type_to_mime_type(Ima… in PHP_FUNCTION()
4035 exif_iif_add_str(&ImageInfo, SECTION_FILE, "SectionsFound", sections_str ? sections_str : "NONE"); in PHP_FUNCTION()
4038 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section COMPUTED"); in PHP_FUNCTION()
4041 if (ImageInfo.Width>0 && ImageInfo.Height>0) { in PHP_FUNCTION()
4042 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "html" , "width=\"%d\" height=\"%d\"", ImageInfo.… in PHP_FUNCTION()
4043 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Height", ImageInfo.Height); in PHP_FUNCTION()
4044 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Width", ImageInfo.Width); in PHP_FUNCTION()
4046 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "IsColor", ImageInfo.IsColor); in PHP_FUNCTION()
4047 if (ImageInfo.motorola_intel != -1) { in PHP_FUNCTION()
4048 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "ByteOrderMotorola", ImageInfo.motorola_intel); in PHP_FUNCTION()
4050 if (ImageInfo.FocalLength) { in PHP_FUNCTION()
4051 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocalLength", "%4.1Fmm", ImageInfo.FocalLength); in PHP_FUNCTION()
4052 if(ImageInfo.CCDWidth) { in PHP_FUNCTION()
4053 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "35mmFocalLength", "%dmm", (int)(ImageInfo.FocalLen… in PHP_FUNCTION()
4056 if(ImageInfo.CCDWidth) { in PHP_FUNCTION()
4057 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "CCDWidth", "%dmm", (int)ImageInfo.CCDWidth); in PHP_FUNCTION()
4059 if(ImageInfo.ExposureTime>0) { in PHP_FUNCTION()
4060 if(ImageInfo.ExposureTime <= 0.5) { in PHP_FUNCTION()
4061 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime", "%0.3F s (1/%d)", ImageInfo.Exposur… in PHP_FUNCTION()
4063 … exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime", "%0.3F s", ImageInfo.ExposureTime); in PHP_FUNCTION()
4066 if(ImageInfo.ApertureFNumber) { in PHP_FUNCTION()
4067 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ApertureFNumber", "f/%.1F", ImageInfo.ApertureFNum… in PHP_FUNCTION()
4069 if(ImageInfo.Distance) { in PHP_FUNCTION()
4070 if(ImageInfo.Distance<0) { in PHP_FUNCTION()
4071 exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "FocusDistance", "Infinite"); in PHP_FUNCTION()
4073 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocusDistance", "%0.2Fm", ImageInfo.Distance); in PHP_FUNCTION()
4076 if (ImageInfo.UserComment) { in PHP_FUNCTION()
4077 …exif_iif_add_buffer(&ImageInfo, SECTION_COMPUTED, "UserComment", ImageInfo.UserCommentLength, Imag… in PHP_FUNCTION()
4078 if (ImageInfo.UserCommentEncoding && strlen(ImageInfo.UserCommentEncoding)) { in PHP_FUNCTION()
4079 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "UserCommentEncoding", ImageInfo.UserCommentEncodin… in PHP_FUNCTION()
4083 exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright", ImageInfo.Copyright); in PHP_FUNCTION()
4084 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Photographer", ImageInfo.CopyrightPhotog… in PHP_FUNCTION()
4085 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Editor", ImageInfo.CopyrightEditor… in PHP_FUNCTION()
4087 for (i=0; i<ImageInfo.xp_fields.count; i++) { in PHP_FUNCTION()
4088 …f_add_str(&ImageInfo, SECTION_WINXP, exif_get_tagname(ImageInfo.xp_fields.list[i].tag, NULL, 0, ex… in PHP_FUNCTION()
4090 if (ImageInfo.Thumbnail.size) { in PHP_FUNCTION()
4093 …exif_iif_add_tag(&ImageInfo, SECTION_THUMBNAIL, "THUMBNAIL", TAG_NONE, TAG_FMT_UNDEFINED, ImageInf… in PHP_FUNCTION()
4095 if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4097 exif_scan_thumbnail(&ImageInfo); in PHP_FUNCTION()
4099 …exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.FileType", ImageInfo.Thumbnail.filetype); in PHP_FUNCTION()
4100 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Thumbnail.MimeType", (char*)php_image_type_to_mime… in PHP_FUNCTION()
4102 if (ImageInfo.Thumbnail.width && ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4103 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Height", ImageInfo.Thumbnail.height); in PHP_FUNCTION()
4104 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Width", ImageInfo.Thumbnail.width); in PHP_FUNCTION()
4109 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Adding image infos"); in PHP_FUNCTION()
4112 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FILE ); in PHP_FUNCTION()
4113 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMPUTED ); in PHP_FUNCTION()
4114 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_ANY_TAG ); in PHP_FUNCTION()
4115 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_IFD0 ); in PHP_FUNCTION()
4116 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_THUMBNAIL ); in PHP_FUNCTION()
4117 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMMENT ); in PHP_FUNCTION()
4118 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_EXIF ); in PHP_FUNCTION()
4119 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_GPS ); in PHP_FUNCTION()
4120 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_INTEROP ); in PHP_FUNCTION()
4121 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FPIX ); in PHP_FUNCTION()
4122 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_APP12 ); in PHP_FUNCTION()
4123 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_WINXP ); in PHP_FUNCTION()
4124 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_MAKERNOTE ); in PHP_FUNCTION()
4127 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Discarding info"); in PHP_FUNCTION()
4130 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4146 image_info_type ImageInfo; in PHP_FUNCTION() local
4148 memset(&ImageInfo, 0, sizeof(ImageInfo)); in PHP_FUNCTION()
4158 ret = exif_read_file(&ImageInfo, p_name, 1, 0); in PHP_FUNCTION()
4160 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4165ImageInfo, E_NOTICE, "Thumbnail data %d %d %d, %d x %d", ImageInfo.Thumbnail.data, ImageInfo.Thumb… in PHP_FUNCTION()
4167 if (!ImageInfo.Thumbnail.data || !ImageInfo.Thumbnail.size) { in PHP_FUNCTION()
4168 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4173 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Returning thumbnail(%d)", ImageInfo.Thum… in PHP_FUNCTION()
4176 ZVAL_STRINGL(return_value, ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size); in PHP_FUNCTION()
4178 if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4179 exif_scan_thumbnail(&ImageInfo); in PHP_FUNCTION()
4183 ZVAL_LONG(p_width, ImageInfo.Thumbnail.width); in PHP_FUNCTION()
4184 ZVAL_LONG(p_height, ImageInfo.Thumbnail.height); in PHP_FUNCTION()
4188 ZVAL_LONG(p_imagetype, ImageInfo.Thumbnail.filetype); in PHP_FUNCTION()
4192 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Discarding info"); in PHP_FUNCTION()
4195 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()