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()
2287 static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, char *offset_base,…
2288 static int exif_process_IFD_TAG( image_info_type *ImageInfo, char *dir_entry, char *offset_base,…
2443 static void exif_thumbnail_build(image_info_type *ImageInfo) { in exif_thumbnail_build() argument
2454 if (!ImageInfo->read_thumbnail || !ImageInfo->Thumbnail.offset || !ImageInfo->Thumbnail.size) { in exif_thumbnail_build()
2458 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: filetype = %d", ImageInfo->Thu… in exif_thumbnail_build()
2460 switch(ImageInfo->Thumbnail.filetype) { in exif_thumbnail_build()
2467 info_list = &ImageInfo->info_list[SECTION_THUMBNAIL]; in exif_thumbnail_build()
2470 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: size of signature + directory(… in exif_thumbnail_build()
2481 new_data = safe_erealloc(ImageInfo->Thumbnail.data, 1, ImageInfo->Thumbnail.size, new_size); in exif_thumbnail_build()
2482 ImageInfo->Thumbnail.data = new_data; in exif_thumbnail_build()
2483 …memmove(ImageInfo->Thumbnail.data + new_move, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size… in exif_thumbnail_build()
2484 ImageInfo->Thumbnail.size += new_size; in exif_thumbnail_build()
2486 if (ImageInfo->motorola_intel) { in exif_thumbnail_build()
2492 php_ifd_set16u(new_data, info_list->count, ImageInfo->motorola_intel); in exif_thumbnail_build()
2498 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: process tag(x%04X=%s): %s%s (%… in exif_thumbnail_build()
2501 php_ifd_set16u(new_data + 0, info_data->tag, ImageInfo->motorola_intel); in exif_thumbnail_build()
2502 php_ifd_set16u(new_data + 2, TAG_FMT_ULONG, ImageInfo->motorola_intel); in exif_thumbnail_build()
2503 php_ifd_set32u(new_data + 4, 1, ImageInfo->motorola_intel); in exif_thumbnail_build()
2504 php_ifd_set32u(new_data + 8, new_move, ImageInfo->motorola_intel); in exif_thumbnail_build()
2506 php_ifd_set16u(new_data + 0, info_data->tag, ImageInfo->motorola_intel); in exif_thumbnail_build()
2507 php_ifd_set16u(new_data + 2, info_data->format, ImageInfo->motorola_intel); in exif_thumbnail_build()
2508 php_ifd_set32u(new_data + 4, info_data->length, ImageInfo->motorola_intel); in exif_thumbnail_build()
2509 value_ptr = exif_ifd_make_value(info_data, ImageInfo->motorola_intel); in exif_thumbnail_build()
2513 php_ifd_set32u(new_data+8, new_value, ImageInfo->motorola_intel); in exif_thumbnail_build()
2515 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: writing with value offset: 0x%… in exif_thumbnail_build()
2517 memmove(ImageInfo->Thumbnail.data+new_value, value_ptr, byte_count); in exif_thumbnail_build()
2526 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: created"); in exif_thumbnail_build()
2535 static void exif_thumbnail_extract(image_info_type *ImageInfo, char *offset, size_t length) { in exif_thumbnail_extract() argument
2536 if (ImageInfo->Thumbnail.data) { in exif_thumbnail_extract()
2537 …exif_error_docref("exif_read_data#error_mult_thumb" EXIFERR_CC, ImageInfo, E_WARNING, "Multiple po… in exif_thumbnail_extract()
2540 if (!ImageInfo->read_thumbnail) { in exif_thumbnail_extract()
2544 if (ImageInfo->Thumbnail.size >= 65536 in exif_thumbnail_extract()
2545 || ImageInfo->Thumbnail.size <= 0 in exif_thumbnail_extract()
2546 || ImageInfo->Thumbnail.offset <= 0 in exif_thumbnail_extract()
2548 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Illegal thumbnail size/offset"); in exif_thumbnail_extract()
2552 if (ImageInfo->Thumbnail.size > length in exif_thumbnail_extract()
2553 || (ImageInfo->Thumbnail.offset + ImageInfo->Thumbnail.size) > length in exif_thumbnail_extract()
2554 || ImageInfo->Thumbnail.offset > length - ImageInfo->Thumbnail.size in exif_thumbnail_extract()
2556 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_thumbnail_extract()
2559ImageInfo->Thumbnail.data = estrndup(offset + ImageInfo->Thumbnail.offset, ImageInfo->Thumbnail.si… in exif_thumbnail_extract()
2560 exif_thumbnail_build(ImageInfo); in exif_thumbnail_extract()
2618 static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoPtr, char **pszEncod… in exif_process_user_comment() argument
2643 } else if (ImageInfo->motorola_intel) { in exif_process_user_comment()
2644 decode = ImageInfo->decode_unicode_be; in exif_process_user_comment()
2646 decode = ImageInfo->decode_unicode_le; in exif_process_user_comment()
2648 to = zend_multibyte_fetch_encoding(ImageInfo->encode_unicode); in exif_process_user_comment()
2671 to = zend_multibyte_fetch_encoding(ImageInfo->encode_jis); in exif_process_user_comment()
2672 …from = zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_jis_be : ImageI… in exif_process_user_comment()
2706 static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char … in exif_process_unicode() argument
2716 zend_multibyte_fetch_encoding(ImageInfo->encode_unicode), in exif_process_unicode()
2717 …zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_unicode_be : ImageInfo in exif_process_unicode()
2727 static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * value_ptr, int value_le… in exif_process_IFD_in_MAKERNOTE() argument
2739 …(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "No maker note data found. Detected maker: %s (length = %d)… in exif_process_IFD_in_MAKERNOTE()
2748 if (maker_note->make && (!ImageInfo->make || strcmp(maker_note->make, ImageInfo->make))) in exif_process_IFD_in_MAKERNOTE()
2750 if (maker_note->model && (!ImageInfo->model || strcmp(maker_note->model, ImageInfo->model))) in exif_process_IFD_in_MAKERNOTE()
2759 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short… in exif_process_IFD_in_MAKERNOTE()
2766 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s @x%04X + 0x%04X=%d: %s", exif_… in exif_process_IFD_in_MAKERNOTE()
2769 ImageInfo->sections_found |= FOUND_MAKERNOTE; in exif_process_IFD_in_MAKERNOTE()
2771 old_motorola_intel = ImageInfo->motorola_intel; in exif_process_IFD_in_MAKERNOTE()
2774 ImageInfo->motorola_intel = 0; in exif_process_IFD_in_MAKERNOTE()
2777 ImageInfo->motorola_intel = 1; in exif_process_IFD_in_MAKERNOTE()
2784 NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); in exif_process_IFD_in_MAKERNOTE()
2794 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short… in exif_process_IFD_in_MAKERNOTE()
2797 offset_diff = 2 + NumDirEntries*12 + 4 - php_ifd_get32u(dir_start+10, ImageInfo->motorola_intel); in exif_process_IFD_in_MAKERNOTE()
2799 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Using automatic offset correction: 0x%04X… in exif_process_IFD_in_MAKERNOTE()
2802 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data bad offse… in exif_process_IFD_in_MAKERNOTE()
2815 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_MAKERNOTE()
2819 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_MAKERNOTE()
2824 if (!exif_process_IFD_TAG(ImageInfo, dir_start + 2 + 12 * de, in exif_process_IFD_in_MAKERNOTE()
2829 ImageInfo->motorola_intel = old_motorola_intel; in exif_process_IFD_in_MAKERNOTE()
2832 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Subsection %s done", exif_get_sectionname… in exif_process_IFD_in_MAKERNOTE()
2840 static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, char *offset_base, siz… in exif_process_IFD_TAG() argument
2854 if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) { in exif_process_IFD_TAG()
2855 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "corrupt EXIF heade… in exif_process_IFD_TAG()
2858 ImageInfo->ifd_nesting_level++; in exif_process_IFD_TAG()
2860 tag = php_ifd_get16u(dir_entry, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2861 format = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2862 components = php_ifd_get32u(dir_entry+4, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2866 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG()
2872 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG()
2879 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG()
2886 offset_val = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2898ImageInfo->FileSize || offset_val>ImageInfo->FileSize-byte_count || (ImageInfo->FileType!=IMAGE_FI… in exif_process_IFD_TAG()
2902 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG()
2906 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG()
2924 fpos = php_stream_tell(ImageInfo->infile); in exif_process_IFD_TAG()
2925 php_stream_seek(ImageInfo->infile, displacement+offset_val, SEEK_SET); in exif_process_IFD_TAG()
2926 fgot = php_stream_tell(ImageInfo->infile); in exif_process_IFD_TAG()
2929 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Wrong file pointer: 0x%08X != 0x%08X", f… in exif_process_IFD_TAG()
2932 fgot = php_stream_read(ImageInfo->infile, value_ptr, byte_count); in exif_process_IFD_TAG()
2933 php_stream_seek(ImageInfo->infile, fpos, SEEK_SET); in exif_process_IFD_TAG()
2936 EXIF_ERRLOG_FILEEOF(ImageInfo) in exif_process_IFD_TAG()
2946 ImageInfo->sections_found |= FOUND_ANY_TAG; in exif_process_IFD_TAG()
2948 …dump_data = exif_dump_data(&dump_free, format, components, length, ImageInfo->motorola_intel, valu… in exif_process_IFD_TAG()
2949 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process tag(x%04X=%s,@x%04X + x%04X(=%d))… in exif_process_IFD_TAG()
2956 if (!ImageInfo->Thumbnail.data) { in exif_process_IFD_TAG()
2960ImageInfo->Thumbnail.width = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2965ImageInfo->Thumbnail.height = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel… in exif_process_IFD_TAG()
2971ImageInfo->Thumbnail.offset = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel… in exif_process_IFD_TAG()
2975 …if (ImageInfo->FileType == IMAGE_FILETYPE_TIFF_II || ImageInfo->FileType == IMAGE_FILETYPE_TIFF_MM… in exif_process_IFD_TAG()
2976 ImageInfo->Thumbnail.filetype = ImageInfo->FileType; in exif_process_IFD_TAG()
2979 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_TIFF_MM; in exif_process_IFD_TAG()
2981ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
2985 if (ImageInfo->Thumbnail.filetype == IMAGE_FILETYPE_UNKNOWN) { in exif_process_IFD_TAG()
2986 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_JPEG; in exif_process_IFD_TAG()
2987ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
3000 ImageInfo->CopyrightPhotographer = estrdup(value_ptr); in exif_process_IFD_TAG()
3001 ImageInfo->CopyrightEditor = estrndup(value_ptr+length+1, byte_count-length-1); in exif_process_IFD_TAG()
3002 …spprintf(&ImageInfo->Copyright, 0, "%s, %s", ImageInfo->CopyrightPhotographer, ImageInfo->Copyrigh… in exif_process_IFD_TAG()
3007 ImageInfo->Copyright = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG()
3013ImageInfo->UserCommentLength = exif_process_user_comment(ImageInfo, &(ImageInfo->UserComment), &(I… in exif_process_IFD_TAG()
3021 …tmp_xp = (xp_field_type*)safe_erealloc(ImageInfo->xp_fields.list, (ImageInfo->xp_fields.count+1), … in exif_process_IFD_TAG()
3022 ImageInfo->sections_found |= FOUND_WINXP; in exif_process_IFD_TAG()
3023 ImageInfo->xp_fields.list = tmp_xp; in exif_process_IFD_TAG()
3024 ImageInfo->xp_fields.count++; in exif_process_IFD_TAG()
3025 …exif_process_unicode(ImageInfo, &(ImageInfo->xp_fields.list[ImageInfo->xp_fields.count-1]), tag, v… in exif_process_IFD_TAG()
3031ImageInfo->ApertureFNumber = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola… in exif_process_IFD_TAG()
3038 if (ImageInfo->ApertureFNumber == 0) { in exif_process_IFD_TAG()
3039 ImageInfo->ApertureFNumber in exif_process_IFD_TAG()
3040 … = (float)exp(exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)*log(2)*0.5); in exif_process_IFD_TAG()
3049 if (ImageInfo->ExposureTime == 0) { in exif_process_IFD_TAG()
3050 ImageInfo->ExposureTime in exif_process_IFD_TAG()
3051 … = (float)(1/exp(exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)*log(2))); in exif_process_IFD_TAG()
3055 ImageInfo->ExposureTime = -1; in exif_process_IFD_TAG()
3059ImageInfo->ExifImageWidth = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
3063ImageInfo->FocalplaneXRes = exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
3069ImageInfo->Distance = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
3073 switch((int)exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)) { in exif_process_IFD_TAG()
3074 case 1: ImageInfo->FocalplaneUnits = 25.4; break; /* inch */ in exif_process_IFD_TAG()
3079 ImageInfo->FocalplaneUnits = 25.4; in exif_process_IFD_TAG()
3082 case 3: ImageInfo->FocalplaneUnits = 10; break; /* centimeter */ in exif_process_IFD_TAG()
3083 case 4: ImageInfo->FocalplaneUnits = 1; break; /* milimeter */ in exif_process_IFD_TAG()
3084 case 5: ImageInfo->FocalplaneUnits = .001; break; /* micrometer */ in exif_process_IFD_TAG()
3093 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Skip SUB IFD"); in exif_process_IFD_TAG()
3098 ImageInfo->make = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG()
3101 ImageInfo->model = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG()
3105 …if (!exif_process_IFD_in_MAKERNOTE(ImageInfo, value_ptr, byte_count, offset_base, IFDlength, displ… in exif_process_IFD_TAG()
3120 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found EXIF"); in exif_process_IFD_TAG()
3122 ImageInfo->sections_found |= FOUND_EXIF; in exif_process_IFD_TAG()
3127 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found GPS"); in exif_process_IFD_TAG()
3129 ImageInfo->sections_found |= FOUND_GPS; in exif_process_IFD_TAG()
3134 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found INTEROPERABILITY"); in exif_process_IFD_TAG()
3136 ImageInfo->sections_found |= FOUND_INTEROP; in exif_process_IFD_TAG()
3140 Subdir_start = offset_base + php_ifd_get32u(value_ptr, ImageInfo->motorola_intel); in exif_process_IFD_TAG()
3142 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD Pointe… in exif_process_IFD_TAG()
3145 …if (!exif_process_IFD_in_JPEG(ImageInfo, Subdir_start, offset_base, IFDlength, displacement, sub_s… in exif_process_IFD_TAG()
3149 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Subsection %s done", exif_get_sectionname… in exif_process_IFD_TAG()
3154 …exif_iif_add_tag(ImageInfo, section_index, exif_get_tagname(tag, tagname, sizeof(tagname), tag_tab… in exif_process_IFD_TAG()
3162 static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, char *offset_base,… in exif_process_IFD_in_JPEG() argument
3169 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s (x%04X(=%d))", exif_get_sectio… in exif_process_IFD_in_JPEG()
3172 ImageInfo->sections_found |= FOUND_IFD0; in exif_process_IFD_in_JPEG()
3175 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size"); in exif_process_IFD_in_JPEG()
3179 NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); in exif_process_IFD_in_JPEG()
3182 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_JPEG()
3187 if (!exif_process_IFD_TAG(ImageInfo, dir_start + 2 + 12 * de, in exif_process_IFD_in_JPEG()
3203 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size"); in exif_process_IFD_in_JPEG()
3206 NextDirOffset = php_ifd_get32u(dir_start+2+12*de, ImageInfo->motorola_intel); in exif_process_IFD_in_JPEG()
3210 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD offset… in exif_process_IFD_in_JPEG()
3215 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Expect next IFD to be thumbnail"); in exif_process_IFD_in_JPEG()
3217 …if (exif_process_IFD_in_JPEG(ImageInfo, offset_base + NextDirOffset, offset_base, IFDlength, displ… in exif_process_IFD_in_JPEG()
3219 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail size: 0x%04X", ImageInfo->Thumb… in exif_process_IFD_in_JPEG()
3221 if (ImageInfo->Thumbnail.filetype != IMAGE_FILETYPE_UNKNOWN in exif_process_IFD_in_JPEG()
3222 && ImageInfo->Thumbnail.size in exif_process_IFD_in_JPEG()
3223 && ImageInfo->Thumbnail.offset in exif_process_IFD_in_JPEG()
3224 && ImageInfo->read_thumbnail in exif_process_IFD_in_JPEG()
3226 exif_thumbnail_extract(ImageInfo, offset_base, IFDlength); in exif_process_IFD_in_JPEG()
3240 static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf, size_t length, siz… in exif_process_TIFF_in_JPEG() argument
3246 ImageInfo->motorola_intel = 0; in exif_process_TIFF_in_JPEG()
3248 ImageInfo->motorola_intel = 1; in exif_process_TIFF_in_JPEG()
3250 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF alignment marker"); in exif_process_TIFF_in_JPEG()
3256 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF start (1)"); in exif_process_TIFF_in_JPEG()
3259 exif_value_2a = php_ifd_get16u(CharBuf+2, ImageInfo->motorola_intel); in exif_process_TIFF_in_JPEG()
3260 offset_of_ifd = php_ifd_get32u(CharBuf+4, ImageInfo->motorola_intel); in exif_process_TIFF_in_JPEG()
3262 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF start (1)"); in exif_process_TIFF_in_JPEG()
3266 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid IFD start"); in exif_process_TIFF_in_JPEG()
3270 ImageInfo->sections_found |= FOUND_IFD0; in exif_process_TIFF_in_JPEG()
3272 …exif_process_IFD_in_JPEG(ImageInfo, CharBuf+offset_of_ifd, CharBuf, length/*-14*/, displacement, S… in exif_process_TIFF_in_JPEG()
3275 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process TIFF in JPEG done"); in exif_process_TIFF_in_JPEG()
3279 if (ImageInfo->FocalplaneXRes != 0) { in exif_process_TIFF_in_JPEG()
3280ImageInfo->CCDWidth = (float)(ImageInfo->ExifImageWidth * ImageInfo->FocalplaneUnits / ImageInfo->… in exif_process_TIFF_in_JPEG()
3289 static void exif_process_APP1(image_info_type *ImageInfo, char *CharBuf, size_t length, size_t disp… in exif_process_APP1() argument
3294 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Incorrect APP1 Exif Identifier Code"); in exif_process_APP1()
3297 exif_process_TIFF_in_JPEG(ImageInfo, CharBuf + 8, length - 8, displacement+8); in exif_process_APP1()
3299 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process APP1/EXIF done"); in exif_process_APP1()
3307 static void exif_process_APP12(image_info_type *ImageInfo, char *buffer, size_t length) in exif_process_APP12() argument
3312 exif_iif_add_tag(ImageInfo, SECTION_APP12, "Company", TAG_NONE, TAG_FMT_STRING, l1, buffer+2, l1); in exif_process_APP12()
3315 …exif_iif_add_tag(ImageInfo, SECTION_APP12, "Info", TAG_NONE, TAG_FMT_STRING, l2, buffer+2+l1+1, l2… in exif_process_APP12()
3319 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process section APP12 with l1=%d, l2=%d d… in exif_process_APP12()
3326 static int exif_scan_JPEG_header(image_info_type *ImageInfo) in exif_scan_JPEG_header() argument
3337 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3338 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Needing section %d @ 0x%08X", ImageInfo->… in exif_scan_JPEG_header()
3348 if ((marker = php_stream_getc(ImageInfo->infile)) == EOF) { in exif_scan_JPEG_header()
3349 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3362 …exif_error_docref("exif_read_data#error_mcom" EXIFERR_CC, ImageInfo, E_NOTICE, "Image has corrupt … in exif_scan_JPEG_header()
3367 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3371 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "To many padding bytes"); in exif_scan_JPEG_header()
3376 if ((lh = php_stream_getc(ImageInfo->infile)) == (unsigned int)EOF) { in exif_scan_JPEG_header()
3377 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3380 if ((ll = php_stream_getc(ImageInfo->infile)) == (unsigned int)EOF) { in exif_scan_JPEG_header()
3381 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3389 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "%s, Section length: 0x%02X%02X", EXIF_ER… in exif_scan_JPEG_header()
3391 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3396 sn = exif_file_sections_add(ImageInfo, marker, itemlen+1, NULL); in exif_scan_JPEG_header()
3397 Data = ImageInfo->file.list[sn].data; in exif_scan_JPEG_header()
3403 …got = php_stream_read(ImageInfo->infile, (char*)(Data+2), itemlen-2); /* Read the whole section. */ in exif_scan_JPEG_header()
3405 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error reading from file: got=x%04X(=%d) … in exif_scan_JPEG_header()
3410 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process section(x%02X=%s) @ x%04X + x%04X… in exif_scan_JPEG_header()
3415 if (ImageInfo->read_all) { in exif_scan_JPEG_header()
3417 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3418 size = ImageInfo->FileSize - fpos; in exif_scan_JPEG_header()
3419 sn = exif_file_sections_add(ImageInfo, M_PSEUDO, size, NULL); in exif_scan_JPEG_header()
3420 Data = ImageInfo->file.list[sn].data; in exif_scan_JPEG_header()
3421 got = php_stream_read(ImageInfo->infile, (char*)Data, size); in exif_scan_JPEG_header()
3423 EXIF_ERRLOG_FILEEOF(ImageInfo) in exif_scan_JPEG_header()
3430 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "No image in jpeg!"); in exif_scan_JPEG_header()
3431 return (ImageInfo->sections_found&(~FOUND_COMPUTED)) ? TRUE : FALSE; in exif_scan_JPEG_header()
3434 exif_process_COM(ImageInfo, (char *)Data, itemlen); in exif_scan_JPEG_header()
3438 if (!(ImageInfo->sections_found&FOUND_IFD0)) { in exif_scan_JPEG_header()
3442 exif_process_APP1(ImageInfo, (char *)Data, itemlen, fpos); in exif_scan_JPEG_header()
3447 exif_process_APP12(ImageInfo, (char *)Data, itemlen); in exif_scan_JPEG_header()
3469 ImageInfo->Width = sof_info.width; in exif_scan_JPEG_header()
3470 ImageInfo->Height = sof_info.height; in exif_scan_JPEG_header()
3472 ImageInfo->IsColor = 1; in exif_scan_JPEG_header()
3474 ImageInfo->IsColor = 0; in exif_scan_JPEG_header()
3486 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Done"); in exif_scan_JPEG_header()
3494 static int exif_scan_thumbnail(image_info_type *ImageInfo) in exif_scan_thumbnail() argument
3496 uchar c, *data = (uchar*)ImageInfo->Thumbnail.data; in exif_scan_thumbnail()
3501 if (!data || ImageInfo->Thumbnail.size < 4) { in exif_scan_thumbnail()
3505 if (!ImageInfo->Thumbnail.width && !ImageInfo->Thumbnail.height) { in exif_scan_thumbnail()
3506 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Thumbnail is not a JPEG image"); in exif_scan_thumbnail()
3512 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3515 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3522 if (pos+3>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3529 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3532 if (length > ImageInfo->Thumbnail.size || pos >= ImageInfo->Thumbnail.size - length) { in exif_scan_thumbnail()
3536 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: process section(x%02X=%s) @ x%… in exif_scan_thumbnail()
3553 if (length < 8 || ImageInfo->Thumbnail.size - 8 < pos) { in exif_scan_thumbnail()
3558 ImageInfo->Thumbnail.height = sof_info.height; in exif_scan_thumbnail()
3559 ImageInfo->Thumbnail.width = sof_info.width; in exif_scan_thumbnail()
3561 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: size: %d * %d", sof_info.width… in exif_scan_thumbnail()
3567 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Could not compute size of thumbnail"); in exif_scan_thumbnail()
3577 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Could not compute size of thumbnail"); in exif_scan_thumbnail()
3584 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
3593 if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) { in exif_process_IFD_in_TIFF()
3597 if (ImageInfo->FileSize >= 2 && ImageInfo->FileSize - 2 >= dir_offset) { in exif_process_IFD_in_TIFF()
3598 sn = exif_file_sections_add(ImageInfo, M_PSEUDO, 2, NULL); in exif_process_IFD_in_TIFF()
3600 …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()
3602 …php_stream_seek(ImageInfo->infile, dir_offset, SEEK_SET); /* we do not know the order of sections … in exif_process_IFD_in_TIFF()
3603 php_stream_read(ImageInfo->infile, (char*)ImageInfo->file.list[sn].data, 2); in exif_process_IFD_in_TIFF()
3604 num_entries = php_ifd_get16u(ImageInfo->file.list[sn].data, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3606 if (ImageInfo->FileSize >= dir_size && ImageInfo->FileSize - dir_size >= dir_offset) { in exif_process_IFD_in_TIFF()
3608 …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()
3610 if (exif_file_sections_realloc(ImageInfo, sn, dir_size)) { in exif_process_IFD_in_TIFF()
3613 php_stream_read(ImageInfo->infile, (char*)(ImageInfo->file.list[sn].data+2), dir_size-2); in exif_process_IFD_in_TIFF()
3615 …next_offset = php_ifd_get32u(ImageInfo->file.list[sn].data + dir_size - 4, ImageInfo->motorola_int… in exif_process_IFD_in_TIFF()
3617 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF done, next offset x%04X", … in exif_process_IFD_in_TIFF()
3622 dir_entry = ImageInfo->file.list[sn].data+2+i*12; in exif_process_IFD_in_TIFF()
3623 entry_tag = php_ifd_get16u(dir_entry+0, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3624 entry_type = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3626 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF: tag(0x%04X,%12s): Illegal… in exif_process_IFD_in_TIFF()
3634 …entry_length = php_ifd_get32u(dir_entry+4, ImageInfo->motorola_intel) * php_tiff_bytes_per_format[… in exif_process_IFD_in_TIFF()
3638 entry_value = php_ifd_get16u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3641 entry_value = php_ifd_get16s(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3644 entry_value = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3647 entry_value = php_ifd_get32s(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3653 ImageInfo->Width = entry_value; in exif_process_IFD_in_TIFF()
3657 ImageInfo->Height = entry_value; in exif_process_IFD_in_TIFF()
3664 ImageInfo->IsColor = 0; in exif_process_IFD_in_TIFF()
3671 ImageInfo->IsColor = 1; in exif_process_IFD_in_TIFF()
3677 entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3684 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Resize struct: x%04X + x%04X - x%04X = x%… in exif_process_IFD_in_TIFF()
3689 …if (ImageInfo->FileSize >= ImageInfo->file.list[sn].size && ImageInfo->FileSize - ImageInfo->file.… in exif_process_IFD_in_TIFF()
3691 if (ImageInfo->FileSize < ifd_size || dir_offset > ImageInfo->FileSize - ifd_size) { in exif_process_IFD_in_TIFF()
3692 …_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than size of I… in exif_process_IFD_in_TIFF()
3695 if (exif_file_sections_realloc(ImageInfo, sn, ifd_size)) { in exif_process_IFD_in_TIFF()
3700 …xif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF: filesize(x%04X), IFD(x%04X… in exif_process_IFD_in_TIFF()
3702 …php_stream_read(ImageInfo->infile, (char*)(ImageInfo->file.list[sn].data+dir_size), ifd_size-dir_s… in exif_process_IFD_in_TIFF()
3704 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF, done"); in exif_process_IFD_in_TIFF()
3709 dir_entry = ImageInfo->file.list[sn].data+2+i*12; in exif_process_IFD_in_TIFF()
3710 entry_tag = php_ifd_get16u(dir_entry+0, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3711 entry_type = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3720 ImageInfo->sections_found |= FOUND_EXIF; in exif_process_IFD_in_TIFF()
3724 ImageInfo->sections_found |= FOUND_GPS; in exif_process_IFD_in_TIFF()
3728 ImageInfo->sections_found |= FOUND_INTEROP; in exif_process_IFD_in_TIFF()
3732 ImageInfo->sections_found |= FOUND_THUMBNAIL; in exif_process_IFD_in_TIFF()
3736 entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF()
3738 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s @x%04X", exif_get_sectionnam… in exif_process_IFD_in_TIFF()
3740 ImageInfo->ifd_nesting_level++; in exif_process_IFD_in_TIFF()
3741 exif_process_IFD_in_TIFF(ImageInfo, entry_offset, sub_section_index); in exif_process_IFD_in_TIFF()
3743 if (ImageInfo->Thumbnail.filetype != IMAGE_FILETYPE_UNKNOWN in exif_process_IFD_in_TIFF()
3744 && ImageInfo->Thumbnail.size in exif_process_IFD_in_TIFF()
3745 && ImageInfo->Thumbnail.offset in exif_process_IFD_in_TIFF()
3746 && ImageInfo->read_thumbnail in exif_process_IFD_in_TIFF()
3749 …RR_CC, ImageInfo, E_NOTICE, "%s THUMBNAIL @0x%04X + 0x%04X", ImageInfo->Thumbnail.data ? "Ignore" … in exif_process_IFD_in_TIFF()
3751 if (!ImageInfo->Thumbnail.data) { in exif_process_IFD_in_TIFF()
3752 ImageInfo->Thumbnail.data = safe_emalloc(ImageInfo->Thumbnail.size, 1, 0); in exif_process_IFD_in_TIFF()
3753 php_stream_seek(ImageInfo->infile, ImageInfo->Thumbnail.offset, SEEK_SET); in exif_process_IFD_in_TIFF()
3754 … fgot = php_stream_read(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size); in exif_process_IFD_in_TIFF()
3755 if (fgot < ImageInfo->Thumbnail.size) { in exif_process_IFD_in_TIFF()
3756 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_process_IFD_in_TIFF()
3757 efree(ImageInfo->Thumbnail.data); in exif_process_IFD_in_TIFF()
3758 ImageInfo->Thumbnail.data = NULL; in exif_process_IFD_in_TIFF()
3760 exif_thumbnail_build(ImageInfo); in exif_process_IFD_in_TIFF()
3766 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s done", exif_get_sectionname(… in exif_process_IFD_in_TIFF()
3769 if (!exif_process_IFD_TAG(ImageInfo, (char*)dir_entry, in exif_process_IFD_in_TIFF()
3770 (char*)(ImageInfo->file.list[sn].data-dir_offset), in exif_process_IFD_in_TIFF()
3781 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read next IFD (THUMBNAIL) at x%04X", next… in exif_process_IFD_in_TIFF()
3783 ImageInfo->ifd_nesting_level++; in exif_process_IFD_in_TIFF()
3784 exif_process_IFD_in_TIFF(ImageInfo, next_offset, SECTION_THUMBNAIL); in exif_process_IFD_in_TIFF()
3786 …RR_CC, ImageInfo, E_NOTICE, "%s THUMBNAIL @0x%04X + 0x%04X", ImageInfo->Thumbnail.data ? "Ignore" … in exif_process_IFD_in_TIFF()
3788 …if (!ImageInfo->Thumbnail.data && ImageInfo->Thumbnail.offset && ImageInfo->Thumbnail.size && Imag… in exif_process_IFD_in_TIFF()
3789 ImageInfo->Thumbnail.data = safe_emalloc(ImageInfo->Thumbnail.size, 1, 0); in exif_process_IFD_in_TIFF()
3790 php_stream_seek(ImageInfo->infile, ImageInfo->Thumbnail.offset, SEEK_SET); in exif_process_IFD_in_TIFF()
3791 … fgot = php_stream_read(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size); in exif_process_IFD_in_TIFF()
3792 if (fgot < ImageInfo->Thumbnail.size) { in exif_process_IFD_in_TIFF()
3793 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_process_IFD_in_TIFF()
3794 efree(ImageInfo->Thumbnail.data); in exif_process_IFD_in_TIFF()
3795 ImageInfo->Thumbnail.data = NULL; in exif_process_IFD_in_TIFF()
3797 exif_thumbnail_build(ImageInfo); in exif_process_IFD_in_TIFF()
3801 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read next IFD (THUMBNAIL) done"); in exif_process_IFD_in_TIFF()
3806 … EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than size of IFD(x%04X)", in exif_process_IFD_in_TIFF()
3810 …or_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than size of… in exif_process_IFD_in_TIFF()
3814 …or_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than start o… in exif_process_IFD_in_TIFF()
3822 static int exif_scan_FILE_header(image_info_type *ImageInfo) in exif_scan_FILE_header() argument
3827 ImageInfo->FileType = IMAGE_FILETYPE_UNKNOWN; in exif_scan_FILE_header()
3829 if (ImageInfo->FileSize >= 2) { in exif_scan_FILE_header()
3830 php_stream_seek(ImageInfo->infile, 0, SEEK_SET); in exif_scan_FILE_header()
3831 if (php_stream_read(ImageInfo->infile, (char*)file_header, 2) != 2) { in exif_scan_FILE_header()
3835 ImageInfo->FileType = IMAGE_FILETYPE_JPEG; in exif_scan_FILE_header()
3836 if (exif_scan_JPEG_header(ImageInfo)) { in exif_scan_FILE_header()
3839 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid JPEG file"); in exif_scan_FILE_header()
3841 } else if (ImageInfo->FileSize >= 8) { in exif_scan_FILE_header()
3842 if (php_stream_read(ImageInfo->infile, (char*)(file_header+2), 6) != 6) { in exif_scan_FILE_header()
3846 ImageInfo->FileType = IMAGE_FILETYPE_TIFF_II; in exif_scan_FILE_header()
3847 ImageInfo->motorola_intel = 0; in exif_scan_FILE_header()
3849 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "File has TIFF/II format"); in exif_scan_FILE_header()
3851 ImageInfo->sections_found |= FOUND_IFD0; in exif_scan_FILE_header()
3852 if (exif_process_IFD_in_TIFF(ImageInfo, in exif_scan_FILE_header()
3853 php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel), in exif_scan_FILE_header()
3857 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF file"); in exif_scan_FILE_header()
3860 ImageInfo->FileType = IMAGE_FILETYPE_TIFF_MM; in exif_scan_FILE_header()
3861 ImageInfo->motorola_intel = 1; in exif_scan_FILE_header()
3863 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "File has TIFF/MM format"); in exif_scan_FILE_header()
3865 ImageInfo->sections_found |= FOUND_IFD0; in exif_scan_FILE_header()
3866 if (exif_process_IFD_in_TIFF(ImageInfo, in exif_scan_FILE_header()
3867 php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel), in exif_scan_FILE_header()
3871 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF file"); in exif_scan_FILE_header()
3874 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "File not supported"); in exif_scan_FILE_header()
3879 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "File too small (%d)", ImageInfo->FileSiz… in exif_scan_FILE_header()
3888 static int exif_discard_imageinfo(image_info_type *ImageInfo) in exif_discard_imageinfo() argument
3892 EFREE_IF(ImageInfo->FileName); in exif_discard_imageinfo()
3893 EFREE_IF(ImageInfo->UserComment); in exif_discard_imageinfo()
3894 EFREE_IF(ImageInfo->UserCommentEncoding); in exif_discard_imageinfo()
3895 EFREE_IF(ImageInfo->Copyright); in exif_discard_imageinfo()
3896 EFREE_IF(ImageInfo->CopyrightPhotographer); in exif_discard_imageinfo()
3897 EFREE_IF(ImageInfo->CopyrightEditor); in exif_discard_imageinfo()
3898 EFREE_IF(ImageInfo->Thumbnail.data); in exif_discard_imageinfo()
3899 EFREE_IF(ImageInfo->encode_unicode); in exif_discard_imageinfo()
3900 EFREE_IF(ImageInfo->decode_unicode_be); in exif_discard_imageinfo()
3901 EFREE_IF(ImageInfo->decode_unicode_le); in exif_discard_imageinfo()
3902 EFREE_IF(ImageInfo->encode_jis); in exif_discard_imageinfo()
3903 EFREE_IF(ImageInfo->decode_jis_be); in exif_discard_imageinfo()
3904 EFREE_IF(ImageInfo->decode_jis_le); in exif_discard_imageinfo()
3905 EFREE_IF(ImageInfo->make); in exif_discard_imageinfo()
3906 EFREE_IF(ImageInfo->model); in exif_discard_imageinfo()
3907 for (i=0; i<ImageInfo->xp_fields.count; i++) { in exif_discard_imageinfo()
3908 EFREE_IF(ImageInfo->xp_fields.list[i].value); in exif_discard_imageinfo()
3910 EFREE_IF(ImageInfo->xp_fields.list); in exif_discard_imageinfo()
3912 exif_iif_free(ImageInfo, i); in exif_discard_imageinfo()
3914 exif_file_sections_free(ImageInfo); in exif_discard_imageinfo()
3915 memset(ImageInfo, 0, sizeof(*ImageInfo)); in exif_discard_imageinfo()
3922 static int exif_read_file(image_info_type *ImageInfo, char *FileName, int read_thumbnail, int read_… in exif_read_file() argument
3929 memset(ImageInfo, 0, sizeof(*ImageInfo)); in exif_read_file()
3931 ImageInfo->motorola_intel = -1; /* flag as unknown */ in exif_read_file()
3933 ImageInfo->infile = php_stream_open_wrapper(FileName, "rb", STREAM_MUST_SEEK|IGNORE_PATH, NULL); in exif_read_file()
3934 if (!ImageInfo->infile) { in exif_read_file()
3935 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Unable to open file"); in exif_read_file()
3939 if (php_stream_is(ImageInfo->infile, PHP_STREAM_IS_STDIO)) { in exif_read_file()
3942 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Not a file"); in exif_read_file()
3943 php_stream_close(ImageInfo->infile); in exif_read_file()
3948 ImageInfo->FileDateTime = st.st_mtime; in exif_read_file()
3949 ImageInfo->FileSize = st.st_size; in exif_read_file()
3953 if (!ImageInfo->FileSize) { in exif_read_file()
3954 php_stream_seek(ImageInfo->infile, 0, SEEK_END); in exif_read_file()
3955 ImageInfo->FileSize = php_stream_tell(ImageInfo->infile); in exif_read_file()
3956 php_stream_seek(ImageInfo->infile, 0, SEEK_SET); in exif_read_file()
3961 ImageInfo->FileName = estrndup(ZSTR_VAL(base), ZSTR_LEN(base)); in exif_read_file()
3963 ImageInfo->read_thumbnail = read_thumbnail; in exif_read_file()
3964 ImageInfo->read_all = read_all; in exif_read_file()
3965 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_UNKNOWN; in exif_read_file()
3967 ImageInfo->encode_unicode = estrdup(EXIF_G(encode_unicode)); in exif_read_file()
3968 ImageInfo->decode_unicode_be = estrdup(EXIF_G(decode_unicode_be)); in exif_read_file()
3969 ImageInfo->decode_unicode_le = estrdup(EXIF_G(decode_unicode_le)); in exif_read_file()
3970 ImageInfo->encode_jis = estrdup(EXIF_G(encode_jis)); in exif_read_file()
3971 ImageInfo->decode_jis_be = estrdup(EXIF_G(decode_jis_be)); in exif_read_file()
3972 ImageInfo->decode_jis_le = estrdup(EXIF_G(decode_jis_le)); in exif_read_file()
3975 ImageInfo->ifd_nesting_level = 0; in exif_read_file()
3978 ret = exif_scan_FILE_header(ImageInfo); in exif_read_file()
3980 php_stream_close(ImageInfo->infile); in exif_read_file()
3994 image_info_type ImageInfo; in PHP_FUNCTION() local
4001 memset(&ImageInfo, 0, sizeof(ImageInfo)); in PHP_FUNCTION()
4026 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections needed: %s", sections_str[0] ? … in PHP_FUNCTION()
4031 ret = exif_read_file(&ImageInfo, p_name, read_thumbnail, read_all); in PHP_FUNCTION()
4032 sections_str = exif_get_sectionlist(ImageInfo.sections_found); in PHP_FUNCTION()
4036 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections found: %s", sections_str[0] ? s… in PHP_FUNCTION()
4039 ImageInfo.sections_found |= FOUND_COMPUTED|FOUND_FILE;/* do not inform about in debug*/ in PHP_FUNCTION()
4041 if (ret == FALSE || (sections_needed && !(sections_needed&ImageInfo.sections_found))) { in PHP_FUNCTION()
4043 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4051 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section FILE"); in PHP_FUNCTION()
4055 exif_iif_add_str(&ImageInfo, SECTION_FILE, "FileName", ImageInfo.FileName); in PHP_FUNCTION()
4056 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileDateTime", ImageInfo.FileDateTime); in PHP_FUNCTION()
4057 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileSize", ImageInfo.FileSize); in PHP_FUNCTION()
4058 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileType", ImageInfo.FileType); in PHP_FUNCTION()
4059 …exif_iif_add_str(&ImageInfo, SECTION_FILE, "MimeType", (char*)php_image_type_to_mime_type(Ima… in PHP_FUNCTION()
4060 exif_iif_add_str(&ImageInfo, SECTION_FILE, "SectionsFound", sections_str ? sections_str : "NONE"); in PHP_FUNCTION()
4063 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section COMPUTED"); in PHP_FUNCTION()
4066 if (ImageInfo.Width>0 && ImageInfo.Height>0) { in PHP_FUNCTION()
4067 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "html" , "width=\"%d\" height=\"%d\"", ImageInfo.… in PHP_FUNCTION()
4068 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Height", ImageInfo.Height); in PHP_FUNCTION()
4069 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Width", ImageInfo.Width); in PHP_FUNCTION()
4071 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "IsColor", ImageInfo.IsColor); in PHP_FUNCTION()
4072 if (ImageInfo.motorola_intel != -1) { in PHP_FUNCTION()
4073 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "ByteOrderMotorola", ImageInfo.motorola_intel); in PHP_FUNCTION()
4075 if (ImageInfo.FocalLength) { in PHP_FUNCTION()
4076 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocalLength", "%4.1Fmm", ImageInfo.FocalLength); in PHP_FUNCTION()
4077 if(ImageInfo.CCDWidth) { in PHP_FUNCTION()
4078 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "35mmFocalLength", "%dmm", (int)(ImageInfo.FocalLen… in PHP_FUNCTION()
4081 if(ImageInfo.CCDWidth) { in PHP_FUNCTION()
4082 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "CCDWidth", "%dmm", (int)ImageInfo.CCDWidth); in PHP_FUNCTION()
4084 if(ImageInfo.ExposureTime>0) { in PHP_FUNCTION()
4085 if(ImageInfo.ExposureTime <= 0.5) { in PHP_FUNCTION()
4086 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime", "%0.3F s (1/%d)", ImageInfo.Exposur… in PHP_FUNCTION()
4088 … exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime", "%0.3F s", ImageInfo.ExposureTime); in PHP_FUNCTION()
4091 if(ImageInfo.ApertureFNumber) { in PHP_FUNCTION()
4092 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ApertureFNumber", "f/%.1F", ImageInfo.ApertureFNum… in PHP_FUNCTION()
4094 if(ImageInfo.Distance) { in PHP_FUNCTION()
4095 if(ImageInfo.Distance<0) { in PHP_FUNCTION()
4096 exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "FocusDistance", "Infinite"); in PHP_FUNCTION()
4098 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocusDistance", "%0.2Fm", ImageInfo.Distance); in PHP_FUNCTION()
4101 if (ImageInfo.UserComment) { in PHP_FUNCTION()
4102 …exif_iif_add_buffer(&ImageInfo, SECTION_COMPUTED, "UserComment", ImageInfo.UserCommentLength, Imag… in PHP_FUNCTION()
4103 if (ImageInfo.UserCommentEncoding && strlen(ImageInfo.UserCommentEncoding)) { in PHP_FUNCTION()
4104 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "UserCommentEncoding", ImageInfo.UserCommentEncodin… in PHP_FUNCTION()
4108 exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright", ImageInfo.Copyright); in PHP_FUNCTION()
4109 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Photographer", ImageInfo.CopyrightPhotog… in PHP_FUNCTION()
4110 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Editor", ImageInfo.CopyrightEditor… in PHP_FUNCTION()
4112 for (i=0; i<ImageInfo.xp_fields.count; i++) { in PHP_FUNCTION()
4113 …f_add_str(&ImageInfo, SECTION_WINXP, exif_get_tagname(ImageInfo.xp_fields.list[i].tag, NULL, 0, ex… in PHP_FUNCTION()
4115 if (ImageInfo.Thumbnail.size) { in PHP_FUNCTION()
4118 …_add_tag(&ImageInfo, SECTION_THUMBNAIL, "THUMBNAIL", TAG_NONE, TAG_FMT_UNDEFINED, ImageInfo.Thumbn… in PHP_FUNCTION()
4120 if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4122 exif_scan_thumbnail(&ImageInfo); in PHP_FUNCTION()
4124 …exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.FileType", ImageInfo.Thumbnail.filetype); in PHP_FUNCTION()
4125 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Thumbnail.MimeType", (char*)php_image_type_to_mime… in PHP_FUNCTION()
4127 if (ImageInfo.Thumbnail.width && ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4128 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Height", ImageInfo.Thumbnail.height); in PHP_FUNCTION()
4129 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Width", ImageInfo.Thumbnail.width); in PHP_FUNCTION()
4134 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Adding image infos"); in PHP_FUNCTION()
4137 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FILE ); in PHP_FUNCTION()
4138 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMPUTED ); in PHP_FUNCTION()
4139 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_ANY_TAG ); in PHP_FUNCTION()
4140 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_IFD0 ); in PHP_FUNCTION()
4141 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_THUMBNAIL ); in PHP_FUNCTION()
4142 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMMENT ); in PHP_FUNCTION()
4143 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_EXIF ); in PHP_FUNCTION()
4144 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_GPS ); in PHP_FUNCTION()
4145 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_INTEROP ); in PHP_FUNCTION()
4146 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FPIX ); in PHP_FUNCTION()
4147 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_APP12 ); in PHP_FUNCTION()
4148 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_WINXP ); in PHP_FUNCTION()
4149 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_MAKERNOTE ); in PHP_FUNCTION()
4152 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Discarding info"); in PHP_FUNCTION()
4155 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4171 image_info_type ImageInfo; in PHP_FUNCTION() local
4173 memset(&ImageInfo, 0, sizeof(ImageInfo)); in PHP_FUNCTION()
4183 ret = exif_read_file(&ImageInfo, p_name, 1, 0); in PHP_FUNCTION()
4185 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4190ImageInfo, E_NOTICE, "Thumbnail data %d %d %d, %d x %d", ImageInfo.Thumbnail.data, ImageInfo.Thumb… in PHP_FUNCTION()
4192 if (!ImageInfo.Thumbnail.data || !ImageInfo.Thumbnail.size) { in PHP_FUNCTION()
4193 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4198 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Returning thumbnail(%d)", ImageInfo.Thum… in PHP_FUNCTION()
4201 ZVAL_STRINGL(return_value, ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size); in PHP_FUNCTION()
4203 if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4204 if (!exif_scan_thumbnail(&ImageInfo)) { in PHP_FUNCTION()
4205 ImageInfo.Thumbnail.width = ImageInfo.Thumbnail.height = 0; in PHP_FUNCTION()
4210 ZVAL_LONG(p_width, ImageInfo.Thumbnail.width); in PHP_FUNCTION()
4211 ZVAL_LONG(p_height, ImageInfo.Thumbnail.height); in PHP_FUNCTION()
4215 ZVAL_LONG(p_imagetype, ImageInfo.Thumbnail.filetype); in PHP_FUNCTION()
4219 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Discarding info"); in PHP_FUNCTION()
4222 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()