Lines Matching refs:ImageInfo
238 #define EXIF_ERRLOG_FILEEOF(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, … argument
239 #define EXIF_ERRLOG_CORRUPT(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, … argument
240 #define EXIF_ERRLOG_THUMBEOF(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, … argument
241 #define EXIF_ERRLOG_FSREALLOC(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, … argument
1992 static void exif_error_docref(const char *docref EXIFERR_DC, image_info_type *ImageInfo, int type, … in exif_error_docref() argument
1996 if (ImageInfo) { in exif_error_docref()
1997 if (++ImageInfo->num_errors > EXIF_MAX_ERRORS) { in exif_error_docref()
1998 if (ImageInfo->num_errors == EXIF_MAX_ERRORS+1) { in exif_error_docref()
2012 php_verror(docref, ImageInfo && ImageInfo->FileName ? ImageInfo->FileName:"", type, buf, args); in exif_error_docref()
2016 php_verror(docref, ImageInfo && ImageInfo->FileName ? ImageInfo->FileName:"", type, format, args); in exif_error_docref()
2099 static int exif_file_sections_add(image_info_type *ImageInfo, int type, size_t size, uchar *data) in exif_file_sections_add() argument
2101 int count = ImageInfo->file.count; in exif_file_sections_add()
2102 if (count == ImageInfo->file.alloc_count) { in exif_file_sections_add()
2103 int new_alloc_count = ImageInfo->file.alloc_count ? ImageInfo->file.alloc_count * 2 : 1; in exif_file_sections_add()
2104 ImageInfo->file.list = safe_erealloc( in exif_file_sections_add()
2105 ImageInfo->file.list, new_alloc_count, sizeof(file_section), 0); in exif_file_sections_add()
2106 ImageInfo->file.alloc_count = new_alloc_count; in exif_file_sections_add()
2109 ImageInfo->file.list[count].type = 0xFFFF; in exif_file_sections_add()
2110 ImageInfo->file.list[count].data = NULL; in exif_file_sections_add()
2111 ImageInfo->file.list[count].size = 0; in exif_file_sections_add()
2112 ImageInfo->file.count = count+1; in exif_file_sections_add()
2118 ImageInfo->file.list[count].type = type; in exif_file_sections_add()
2119 ImageInfo->file.list[count].data = data; in exif_file_sections_add()
2120 ImageInfo->file.list[count].size = size; in exif_file_sections_add()
2128 static int exif_file_sections_realloc(image_info_type *ImageInfo, int section_index, size_t size) in exif_file_sections_realloc() argument
2135 if (section_index >= ImageInfo->file.count) { in exif_file_sections_realloc()
2136 EXIF_ERRLOG_FSREALLOC(ImageInfo) in exif_file_sections_realloc()
2139 tmp = safe_erealloc(ImageInfo->file.list[section_index].data, 1, size, 0); in exif_file_sections_realloc()
2140 ImageInfo->file.list[section_index].data = tmp; in exif_file_sections_realloc()
2141 ImageInfo->file.list[section_index].size = size; in exif_file_sections_realloc()
2149 static bool exif_file_sections_free(image_info_type *ImageInfo) in exif_file_sections_free() argument
2153 if (ImageInfo->file.count) { in exif_file_sections_free()
2154 for (i=0; i<ImageInfo->file.count; i++) { in exif_file_sections_free()
2155 EFREE_IF(ImageInfo->file.list[i].data); in exif_file_sections_free()
2158 EFREE_IF(ImageInfo->file.list); in exif_file_sections_free()
2159 ImageInfo->file.count = 0; in exif_file_sections_free()
2697 static bool exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, const exif_offset…
2698 static bool exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, const exif_offset_inf…
2699 static bool exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offset, int section_ind…
2852 static void exif_thumbnail_build(image_info_type *ImageInfo) { in exif_thumbnail_build() argument
2860 if (!ImageInfo->read_thumbnail || !ImageInfo->Thumbnail.offset || !ImageInfo->Thumbnail.size) { in exif_thumbnail_build()
2864 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: filetype = %d", ImageInfo->Thu… in exif_thumbnail_build()
2866 switch(ImageInfo->Thumbnail.filetype) { in exif_thumbnail_build()
2873 info_list = &ImageInfo->info_list[SECTION_THUMBNAIL]; in exif_thumbnail_build()
2876 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: size of signature + directory(… in exif_thumbnail_build()
2887 new_data = safe_erealloc(ImageInfo->Thumbnail.data, 1, ImageInfo->Thumbnail.size, new_size); in exif_thumbnail_build()
2888 ImageInfo->Thumbnail.data = new_data; in exif_thumbnail_build()
2889 …memmove(ImageInfo->Thumbnail.data + new_move, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size… in exif_thumbnail_build()
2890 ImageInfo->Thumbnail.size += new_size; in exif_thumbnail_build()
2892 if (ImageInfo->motorola_intel) { in exif_thumbnail_build()
2898 php_ifd_set16u(new_data, info_list->count, ImageInfo->motorola_intel); in exif_thumbnail_build()
2904 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: process tag(x%04X=%s): %s%s (%… in exif_thumbnail_build()
2907 php_ifd_set16u(new_data + 0, info_data->tag, ImageInfo->motorola_intel); in exif_thumbnail_build()
2908 php_ifd_set16u(new_data + 2, TAG_FMT_ULONG, ImageInfo->motorola_intel); in exif_thumbnail_build()
2909 php_ifd_set32u(new_data + 4, 1, ImageInfo->motorola_intel); in exif_thumbnail_build()
2910 php_ifd_set32u(new_data + 8, new_move, ImageInfo->motorola_intel); in exif_thumbnail_build()
2912 php_ifd_set16u(new_data + 0, info_data->tag, ImageInfo->motorola_intel); in exif_thumbnail_build()
2913 php_ifd_set16u(new_data + 2, info_data->format, ImageInfo->motorola_intel); in exif_thumbnail_build()
2914 php_ifd_set32u(new_data + 4, info_data->length, ImageInfo->motorola_intel); in exif_thumbnail_build()
2915 value_ptr = exif_ifd_make_value(info_data, ImageInfo->motorola_intel); in exif_thumbnail_build()
2919 php_ifd_set32u(new_data+8, new_value, ImageInfo->motorola_intel); in exif_thumbnail_build()
2921 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: writing with value offset: 0x%… in exif_thumbnail_build()
2923 memmove(ImageInfo->Thumbnail.data+new_value, value_ptr, byte_count); in exif_thumbnail_build()
2932 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: created"); in exif_thumbnail_build()
2941 static void exif_thumbnail_extract(image_info_type *ImageInfo, const exif_offset_info *info) { in exif_thumbnail_extract() argument
2942 if (ImageInfo->Thumbnail.data) { in exif_thumbnail_extract()
2943 …exif_error_docref("exif_read_data#error_mult_thumb" EXIFERR_CC, ImageInfo, E_WARNING, "Multiple po… in exif_thumbnail_extract()
2946 if (!ImageInfo->read_thumbnail) { in exif_thumbnail_extract()
2950 if (ImageInfo->Thumbnail.size >= 65536 in exif_thumbnail_extract()
2951 || ImageInfo->Thumbnail.size <= 0 in exif_thumbnail_extract()
2952 || ImageInfo->Thumbnail.offset <= 0 in exif_thumbnail_extract()
2954 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Illegal thumbnail size/offset"); in exif_thumbnail_extract()
2959 info, ImageInfo->Thumbnail.offset, ImageInfo->Thumbnail.size); in exif_thumbnail_extract()
2961 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_thumbnail_extract()
2964 ImageInfo->Thumbnail.data = estrndup(thumbnail, ImageInfo->Thumbnail.size); in exif_thumbnail_extract()
2965 exif_thumbnail_build(ImageInfo); in exif_thumbnail_extract()
3023 static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoPtr, char **pszEncod… in exif_process_user_comment() argument
3048 } else if (ImageInfo->motorola_intel) { in exif_process_user_comment()
3049 decode = ImageInfo->decode_unicode_be; in exif_process_user_comment()
3051 decode = ImageInfo->decode_unicode_le; in exif_process_user_comment()
3053 to = zend_multibyte_fetch_encoding(ImageInfo->encode_unicode); in exif_process_user_comment()
3076 to = zend_multibyte_fetch_encoding(ImageInfo->encode_jis); in exif_process_user_comment()
3077 …from = zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_jis_be : ImageI… in exif_process_user_comment()
3111 static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char … in exif_process_unicode() argument
3121 zend_multibyte_fetch_encoding(ImageInfo->encode_unicode), in exif_process_unicode()
3122 …zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_unicode_be : ImageInfo… in exif_process_unicode()
3132 static bool exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * value_ptr, int value_l… in exif_process_IFD_in_MAKERNOTE() argument
3144 …FERR_CC, ImageInfo, E_NOTICE, "No maker note data found. Detected maker: %s (length = %d)", ImageI… in exif_process_IFD_in_MAKERNOTE()
3152 if (maker_note->make && (!ImageInfo->make || strcmp(maker_note->make, ImageInfo->make))) in exif_process_IFD_in_MAKERNOTE()
3162 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short… in exif_process_IFD_in_MAKERNOTE()
3169 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s @x%04X + 0x%04X=%d: %s", exif_… in exif_process_IFD_in_MAKERNOTE()
3172 ImageInfo->sections_found |= FOUND_MAKERNOTE; in exif_process_IFD_in_MAKERNOTE()
3174 old_motorola_intel = ImageInfo->motorola_intel; in exif_process_IFD_in_MAKERNOTE()
3177 ImageInfo->motorola_intel = 0; in exif_process_IFD_in_MAKERNOTE()
3180 ImageInfo->motorola_intel = 1; in exif_process_IFD_in_MAKERNOTE()
3187 NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); in exif_process_IFD_in_MAKERNOTE()
3191 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Potentially invalid endianess, trying aga… in exif_process_IFD_in_MAKERNOTE()
3193 ImageInfo->motorola_intel = ImageInfo->motorola_intel == 0 ? 1 : 0; in exif_process_IFD_in_MAKERNOTE()
3194 NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); in exif_process_IFD_in_MAKERNOTE()
3198 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_MAKERNOTE()
3202 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_MAKERNOTE()
3218 if (!exif_process_IFD_TAG(ImageInfo, dir_start + offset, in exif_process_IFD_in_MAKERNOTE()
3223 ImageInfo->motorola_intel = old_motorola_intel; in exif_process_IFD_in_MAKERNOTE()
3226 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Subsection %s done", exif_get_sectionname… in exif_process_IFD_in_MAKERNOTE()
3234 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=…
3242 static bool exif_process_IFD_TAG_impl(image_info_type *ImageInfo, char *dir_entry, const exif_offse… in exif_process_IFD_TAG_impl() argument
3255 tag = php_ifd_get16u(dir_entry, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3256 format = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3257 components = php_ifd_get32u(dir_entry+4, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3261 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG_impl()
3268 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG_impl()
3276 offset_val = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3283 …ImageInfo->FileSize || offset_val>ImageInfo->FileSize-byte_count || (ImageInfo->FileType!=IMAGE_FI… in exif_process_IFD_TAG_impl()
3284 …ImageInfo, E_WARNING, "Process tag(x%04X=%s): Illegal pointer offset(x%04X + x%04X = x%04X > x%04X… in exif_process_IFD_TAG_impl()
3301 fpos = php_stream_tell(ImageInfo->infile); in exif_process_IFD_TAG_impl()
3302 php_stream_seek(ImageInfo->infile, displacement+offset_val, SEEK_SET); in exif_process_IFD_TAG_impl()
3303 fgot = php_stream_tell(ImageInfo->infile); in exif_process_IFD_TAG_impl()
3306 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Wrong file pointer: 0x%08X != 0x%08X", f… in exif_process_IFD_TAG_impl()
3309 fgot = php_stream_read(ImageInfo->infile, value_ptr, byte_count); in exif_process_IFD_TAG_impl()
3310 php_stream_seek(ImageInfo->infile, fpos, SEEK_SET); in exif_process_IFD_TAG_impl()
3313 EXIF_ERRLOG_FILEEOF(ImageInfo) in exif_process_IFD_TAG_impl()
3324 ImageInfo->sections_found |= FOUND_ANY_TAG; in exif_process_IFD_TAG_impl()
3326 dump_data = exif_dump_data(&dump_free, format, components, ImageInfo->motorola_intel, value_ptr); in exif_process_IFD_TAG_impl()
3327 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, in exif_process_IFD_TAG_impl()
3339 if (!ImageInfo->Thumbnail.data) { in exif_process_IFD_TAG_impl()
3344 …ImageInfo->Thumbnail.width = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigne… in exif_process_IFD_TAG_impl()
3349 …ImageInfo->Thumbnail.height = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsign… in exif_process_IFD_TAG_impl()
3355 …ImageInfo->Thumbnail.offset = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsign… in exif_process_IFD_TAG_impl()
3359 …if (ImageInfo->FileType == IMAGE_FILETYPE_TIFF_II || ImageInfo->FileType == IMAGE_FILETYPE_TIFF_MM… in exif_process_IFD_TAG_impl()
3360 ImageInfo->Thumbnail.filetype = ImageInfo->FileType; in exif_process_IFD_TAG_impl()
3363 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_TIFF_MM; in exif_process_IFD_TAG_impl()
3365 …ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned… in exif_process_IFD_TAG_impl()
3369 if (ImageInfo->Thumbnail.filetype == IMAGE_FILETYPE_UNKNOWN) { in exif_process_IFD_TAG_impl()
3370 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_JPEG; in exif_process_IFD_TAG_impl()
3371 …ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned… in exif_process_IFD_TAG_impl()
3384 EFREE_IF(ImageInfo->CopyrightPhotographer); in exif_process_IFD_TAG_impl()
3385 EFREE_IF(ImageInfo->CopyrightEditor); in exif_process_IFD_TAG_impl()
3386 EFREE_IF(ImageInfo->Copyright); in exif_process_IFD_TAG_impl()
3387 ImageInfo->CopyrightPhotographer = estrdup(value_ptr); in exif_process_IFD_TAG_impl()
3388 ImageInfo->CopyrightEditor = estrndup(value_ptr+length+1, byte_count-length-1); in exif_process_IFD_TAG_impl()
3389 …spprintf(&ImageInfo->Copyright, 0, "%s, %s", ImageInfo->CopyrightPhotographer, ImageInfo->Copyrigh… in exif_process_IFD_TAG_impl()
3394 EFREE_IF(ImageInfo->Copyright); in exif_process_IFD_TAG_impl()
3395 ImageInfo->Copyright = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG_impl()
3401 EFREE_IF(ImageInfo->UserComment); in exif_process_IFD_TAG_impl()
3402 ImageInfo->UserComment = NULL; in exif_process_IFD_TAG_impl()
3403 EFREE_IF(ImageInfo->UserCommentEncoding); in exif_process_IFD_TAG_impl()
3404 ImageInfo->UserCommentEncoding = NULL; in exif_process_IFD_TAG_impl()
3405 …ImageInfo->UserCommentLength = exif_process_user_comment(ImageInfo, &(ImageInfo->UserComment), &(I… in exif_process_IFD_TAG_impl()
3413 …tmp_xp = (xp_field_type*)safe_erealloc(ImageInfo->xp_fields.list, (ImageInfo->xp_fields.count+1), … in exif_process_IFD_TAG_impl()
3414 ImageInfo->sections_found |= FOUND_WINXP; in exif_process_IFD_TAG_impl()
3415 ImageInfo->xp_fields.list = tmp_xp; in exif_process_IFD_TAG_impl()
3416 ImageInfo->xp_fields.count++; in exif_process_IFD_TAG_impl()
3417 …exif_process_unicode(ImageInfo, &(ImageInfo->xp_fields.list[ImageInfo->xp_fields.count-1]), tag, v… in exif_process_IFD_TAG_impl()
3424 …ImageInfo->ApertureFNumber = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola… in exif_process_IFD_TAG_impl()
3431 if (ImageInfo->ApertureFNumber == 0) { in exif_process_IFD_TAG_impl()
3433 ImageInfo->ApertureFNumber in exif_process_IFD_TAG_impl()
3434 = expf(exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)*logf(2.0)*0.5); in exif_process_IFD_TAG_impl()
3443 if (ImageInfo->ExposureTime == 0) { in exif_process_IFD_TAG_impl()
3445 ImageInfo->ExposureTime in exif_process_IFD_TAG_impl()
3446 = expf(-exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)*logf(2.0)); in exif_process_IFD_TAG_impl()
3450 ImageInfo->ExposureTime = -1; in exif_process_IFD_TAG_impl()
3455 …ImageInfo->ExifImageWidth = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned… in exif_process_IFD_TAG_impl()
3460 … ImageInfo->FocalplaneXRes = exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3467 …ImageInfo->Distance = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3472 switch (exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel)) { in exif_process_IFD_TAG_impl()
3473 case 1: ImageInfo->FocalplaneUnits = 25.4; break; /* inch */ in exif_process_IFD_TAG_impl()
3478 ImageInfo->FocalplaneUnits = 25.4; in exif_process_IFD_TAG_impl()
3481 case 3: ImageInfo->FocalplaneUnits = 10; break; /* centimeter */ in exif_process_IFD_TAG_impl()
3482 case 4: ImageInfo->FocalplaneUnits = 1; break; /* milimeter */ in exif_process_IFD_TAG_impl()
3483 case 5: ImageInfo->FocalplaneUnits = .001; break; /* micrometer */ in exif_process_IFD_TAG_impl()
3492 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Skip SUB IFD"); in exif_process_IFD_TAG_impl()
3497 EFREE_IF(ImageInfo->make); in exif_process_IFD_TAG_impl()
3498 ImageInfo->make = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG_impl()
3501 EFREE_IF(ImageInfo->model); in exif_process_IFD_TAG_impl()
3502 ImageInfo->model = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG_impl()
3506 if (!exif_process_IFD_in_MAKERNOTE(ImageInfo, value_ptr, byte_count, info, displacement)) { in exif_process_IFD_TAG_impl()
3522 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found EXIF"); in exif_process_IFD_TAG_impl()
3524 ImageInfo->sections_found |= FOUND_EXIF; in exif_process_IFD_TAG_impl()
3529 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found GPS"); in exif_process_IFD_TAG_impl()
3531 ImageInfo->sections_found |= FOUND_GPS; in exif_process_IFD_TAG_impl()
3536 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found INTEROPERABILITY"); in exif_process_IFD_TAG_impl()
3538 ImageInfo->sections_found |= FOUND_INTEROP; in exif_process_IFD_TAG_impl()
3542 offset_val = php_ifd_get32u(value_ptr, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3545 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD Pointe… in exif_process_IFD_TAG_impl()
3549 …if (!exif_process_IFD_in_JPEG(ImageInfo, Subdir_start, info, displacement, sub_section_index, tag)… in exif_process_IFD_TAG_impl()
3554 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Subsection %s done", exif_get_sectionname… in exif_process_IFD_TAG_impl()
3559 …exif_iif_add_tag(ImageInfo, section_index, exif_get_tagname_key(tag, tagname, sizeof(tagname), tag… in exif_process_IFD_TAG_impl()
3565 static bool exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, const exif_offset_inf… in exif_process_IFD_TAG() argument
3569 if (ImageInfo->ifd_count++ > MAX_IFD_TAGS) { in exif_process_IFD_TAG()
3570 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "corrupt EXIF heade… in exif_process_IFD_TAG()
3573 if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) { in exif_process_IFD_TAG()
3574 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "corrupt EXIF heade… in exif_process_IFD_TAG()
3577 ImageInfo->ifd_nesting_level++; in exif_process_IFD_TAG()
3578 …result = exif_process_IFD_TAG_impl(ImageInfo, dir_entry, info, displacement, section_index, ReadNe… in exif_process_IFD_TAG()
3579 ImageInfo->ifd_nesting_level--; in exif_process_IFD_TAG()
3585 static bool exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, const exif_offset… in exif_process_IFD_in_JPEG() argument
3592 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s (x%04X(=%d))", exif_get_sectio… in exif_process_IFD_in_JPEG()
3595 ImageInfo->sections_found |= FOUND_IFD0; in exif_process_IFD_in_JPEG()
3598 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size"); in exif_process_IFD_in_JPEG()
3602 NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); in exif_process_IFD_in_JPEG()
3605 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_JPEG()
3610 if (!exif_process_IFD_TAG(ImageInfo, dir_start + 2 + 12 * de, in exif_process_IFD_in_JPEG()
3626 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size"); in exif_process_IFD_in_JPEG()
3631 NextDirOffset = php_ifd_get32u(dir_start+2+12*de, ImageInfo->motorola_intel); in exif_process_IFD_in_JPEG()
3637 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD offset… in exif_process_IFD_in_JPEG()
3642 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Expect next IFD to be thumbnail"); in exif_process_IFD_in_JPEG()
3644 …if (exif_process_IFD_in_JPEG(ImageInfo, next_dir_start, info, displacement, SECTION_THUMBNAIL, 0))… in exif_process_IFD_in_JPEG()
3646 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail size: 0x%04X", ImageInfo->Thumb… in exif_process_IFD_in_JPEG()
3648 if (ImageInfo->Thumbnail.filetype != IMAGE_FILETYPE_UNKNOWN in exif_process_IFD_in_JPEG()
3649 && ImageInfo->Thumbnail.size in exif_process_IFD_in_JPEG()
3650 && ImageInfo->Thumbnail.offset in exif_process_IFD_in_JPEG()
3651 && ImageInfo->read_thumbnail in exif_process_IFD_in_JPEG()
3653 exif_thumbnail_extract(ImageInfo, info); in exif_process_IFD_in_JPEG()
3667 static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf, size_t length, siz… in exif_process_TIFF_in_JPEG() argument
3673 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker"); in exif_process_TIFF_in_JPEG()
3678 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker"); in exif_process_TIFF_in_JPEG()
3684 ImageInfo->motorola_intel = 0; in exif_process_TIFF_in_JPEG()
3686 ImageInfo->motorola_intel = 1; in exif_process_TIFF_in_JPEG()
3688 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF alignment marker"); in exif_process_TIFF_in_JPEG()
3694 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF start (1)"); in exif_process_TIFF_in_JPEG()
3697 exif_value_2a = php_ifd_get16u(CharBuf+2, ImageInfo->motorola_intel); in exif_process_TIFF_in_JPEG()
3698 offset_of_ifd = php_ifd_get32u(CharBuf+4, ImageInfo->motorola_intel); in exif_process_TIFF_in_JPEG()
3700 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF start (1)"); in exif_process_TIFF_in_JPEG()
3704 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid IFD start"); in exif_process_TIFF_in_JPEG()
3708 ImageInfo->sections_found |= FOUND_IFD0; in exif_process_TIFF_in_JPEG()
3711 exif_process_IFD_in_JPEG(ImageInfo, CharBuf+offset_of_ifd, &info, displacement, SECTION_IFD0, 0); in exif_process_TIFF_in_JPEG()
3714 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process TIFF in JPEG done"); in exif_process_TIFF_in_JPEG()
3718 if (ImageInfo->FocalplaneXRes != 0) { in exif_process_TIFF_in_JPEG()
3719 …ImageInfo->CCDWidth = (float)(ImageInfo->ExifImageWidth * ImageInfo->FocalplaneUnits / ImageInfo->… in exif_process_TIFF_in_JPEG()
3728 static void exif_process_APP1(image_info_type *ImageInfo, char *CharBuf, size_t length, size_t disp… in exif_process_APP1() argument
3733 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Incorrect APP1 Exif Identifier Code"); in exif_process_APP1()
3736 exif_process_TIFF_in_JPEG(ImageInfo, CharBuf + 8, length - 8, displacement+8); in exif_process_APP1()
3738 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process APP1/EXIF done"); in exif_process_APP1()
3746 static void exif_process_APP12(image_info_type *ImageInfo, char *buffer, size_t length) in exif_process_APP12() argument
3751 exif_iif_add_tag(ImageInfo, SECTION_APP12, "Company", TAG_NONE, TAG_FMT_STRING, l1, buffer+2, l1); in exif_process_APP12()
3754 …exif_iif_add_tag(ImageInfo, SECTION_APP12, "Info", TAG_NONE, TAG_FMT_STRING, l2, buffer+2+l1+1, l2… in exif_process_APP12()
3758 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process section APP12 with l1=%d, l2=%d d… in exif_process_APP12()
3765 static bool exif_scan_JPEG_header(image_info_type *ImageInfo) in exif_scan_JPEG_header() argument
3776 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3777 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Needing section %d @ 0x%08X", ImageInfo->… in exif_scan_JPEG_header()
3787 if ((marker = php_stream_getc(ImageInfo->infile)) == EOF) { in exif_scan_JPEG_header()
3788 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3801 …exif_error_docref("exif_read_data#error_mcom" EXIFERR_CC, ImageInfo, E_NOTICE, "Image has corrupt … in exif_scan_JPEG_header()
3806 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3810 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "To many padding bytes"); in exif_scan_JPEG_header()
3815 if ((lh = php_stream_getc(ImageInfo->infile)) == (unsigned int)EOF) { in exif_scan_JPEG_header()
3816 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3819 if ((ll = php_stream_getc(ImageInfo->infile)) == (unsigned int)EOF) { in exif_scan_JPEG_header()
3820 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3828 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "%s, Section length: 0x%02X%02X", EXIF_ER… in exif_scan_JPEG_header()
3830 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3835 sn = exif_file_sections_add(ImageInfo, marker, itemlen, NULL); in exif_scan_JPEG_header()
3836 Data = ImageInfo->file.list[sn].data; in exif_scan_JPEG_header()
3842 …got = php_stream_read(ImageInfo->infile, (char*)(Data+2), itemlen-2); /* Read the whole section. */ in exif_scan_JPEG_header()
3844 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error reading from file: got=x%04X(=%d) … in exif_scan_JPEG_header()
3849 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process section(x%02X=%s) @ x%04X + x%04X… in exif_scan_JPEG_header()
3854 if (ImageInfo->read_all) { in exif_scan_JPEG_header()
3856 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3857 size = ImageInfo->FileSize - fpos; in exif_scan_JPEG_header()
3858 sn = exif_file_sections_add(ImageInfo, M_PSEUDO, size, NULL); in exif_scan_JPEG_header()
3859 Data = ImageInfo->file.list[sn].data; in exif_scan_JPEG_header()
3860 got = php_stream_read(ImageInfo->infile, (char*)Data, size); in exif_scan_JPEG_header()
3862 EXIF_ERRLOG_FILEEOF(ImageInfo) in exif_scan_JPEG_header()
3869 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "No image in jpeg!"); in exif_scan_JPEG_header()
3870 return (ImageInfo->sections_found&(~FOUND_COMPUTED)) ? true : false; in exif_scan_JPEG_header()
3873 exif_process_COM(ImageInfo, (char *)Data, itemlen); in exif_scan_JPEG_header()
3877 if (!(ImageInfo->sections_found&FOUND_IFD0)) { in exif_scan_JPEG_header()
3881 exif_process_APP1(ImageInfo, (char *)Data, itemlen, fpos); in exif_scan_JPEG_header()
3886 exif_process_APP12(ImageInfo, (char *)Data, itemlen); in exif_scan_JPEG_header()
3908 ImageInfo->Width = sof_info.width; in exif_scan_JPEG_header()
3909 ImageInfo->Height = sof_info.height; in exif_scan_JPEG_header()
3911 ImageInfo->IsColor = 1; in exif_scan_JPEG_header()
3913 ImageInfo->IsColor = 0; in exif_scan_JPEG_header()
3925 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Done"); in exif_scan_JPEG_header()
3933 static bool exif_scan_thumbnail(image_info_type *ImageInfo) in exif_scan_thumbnail() argument
3935 uchar c, *data = (uchar*)ImageInfo->Thumbnail.data; in exif_scan_thumbnail()
3940 if (!data || ImageInfo->Thumbnail.size < 4) { in exif_scan_thumbnail()
3944 if (!ImageInfo->Thumbnail.width && !ImageInfo->Thumbnail.height) { in exif_scan_thumbnail()
3945 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Thumbnail is not a JPEG image"); in exif_scan_thumbnail()
3951 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3954 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3961 if (pos+3>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3968 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3971 if (length > ImageInfo->Thumbnail.size || pos >= ImageInfo->Thumbnail.size - length) { in exif_scan_thumbnail()
3975 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: process section(x%02X=%s) @ x%… in exif_scan_thumbnail()
3992 if (length < 8 || ImageInfo->Thumbnail.size - 8 < pos) { in exif_scan_thumbnail()
3997 ImageInfo->Thumbnail.height = sof_info.height; in exif_scan_thumbnail()
3998 ImageInfo->Thumbnail.width = sof_info.width; in exif_scan_thumbnail()
4000 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: size: %d * %d", sof_info.width… in exif_scan_thumbnail()
4006 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Could not compute size of thumbnail"); in exif_scan_thumbnail()
4016 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Could not compute size of thumbnail"); in exif_scan_thumbnail()
4023 static bool exif_process_IFD_in_TIFF_impl(image_info_type *ImageInfo, size_t dir_offset, int sectio… in exif_process_IFD_in_TIFF_impl() argument
4031 if (ImageInfo->FileSize >= 2 && ImageInfo->FileSize - 2 >= dir_offset) { in exif_process_IFD_in_TIFF_impl()
4032 sn = exif_file_sections_add(ImageInfo, M_PSEUDO, 2, NULL); in exif_process_IFD_in_TIFF_impl()
4034 …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_impl()
4036 …php_stream_seek(ImageInfo->infile, dir_offset, SEEK_SET); /* we do not know the order of sections … in exif_process_IFD_in_TIFF_impl()
4037 php_stream_read(ImageInfo->infile, (char*)ImageInfo->file.list[sn].data, 2); in exif_process_IFD_in_TIFF_impl()
4038 num_entries = php_ifd_get16u(ImageInfo->file.list[sn].data, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4040 if (ImageInfo->FileSize >= dir_size && ImageInfo->FileSize - dir_size >= dir_offset) { in exif_process_IFD_in_TIFF_impl()
4042 …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_impl()
4044 if (exif_file_sections_realloc(ImageInfo, sn, dir_size)) { in exif_process_IFD_in_TIFF_impl()
4047 php_stream_read(ImageInfo->infile, (char*)(ImageInfo->file.list[sn].data+2), dir_size-2); in exif_process_IFD_in_TIFF_impl()
4048 …next_offset = php_ifd_get32u(ImageInfo->file.list[sn].data + dir_size - 4, ImageInfo->motorola_int… in exif_process_IFD_in_TIFF_impl()
4050 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF done, next offset x%04X", … in exif_process_IFD_in_TIFF_impl()
4055 dir_entry = ImageInfo->file.list[sn].data+2+i*12; in exif_process_IFD_in_TIFF_impl()
4056 entry_tag = php_ifd_get16u(dir_entry+0, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4057 entry_type = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4059 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF: tag(0x%04X,%12s): Illegal… in exif_process_IFD_in_TIFF_impl()
4067 …entry_length = php_ifd_get32u(dir_entry+4, ImageInfo->motorola_intel) * php_tiff_bytes_per_format[… in exif_process_IFD_in_TIFF_impl()
4071 entry_value = php_ifd_get16u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4074 entry_value = php_ifd_get16s(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4077 entry_value = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4080 entry_value = php_ifd_get32s(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4086 ImageInfo->Width = entry_value; in exif_process_IFD_in_TIFF_impl()
4090 ImageInfo->Height = entry_value; in exif_process_IFD_in_TIFF_impl()
4097 ImageInfo->IsColor = 0; in exif_process_IFD_in_TIFF_impl()
4104 ImageInfo->IsColor = 1; in exif_process_IFD_in_TIFF_impl()
4110 entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4117 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Resize struct: x%04X + x%04X - x%04X = x%… in exif_process_IFD_in_TIFF_impl()
4122 …if (ImageInfo->FileSize >= ImageInfo->file.list[sn].size && ImageInfo->FileSize - ImageInfo->file.… in exif_process_IFD_in_TIFF_impl()
4124 if (ImageInfo->FileSize < ifd_size || dir_offset > ImageInfo->FileSize - ifd_size) { in exif_process_IFD_in_TIFF_impl()
4125 …_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than size of I… in exif_process_IFD_in_TIFF_impl()
4128 if (exif_file_sections_realloc(ImageInfo, sn, ifd_size)) { in exif_process_IFD_in_TIFF_impl()
4133 …xif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF: filesize(x%04X), IFD(x%04X… in exif_process_IFD_in_TIFF_impl()
4135 …php_stream_read(ImageInfo->infile, (char*)(ImageInfo->file.list[sn].data+dir_size), ifd_size-dir_s… in exif_process_IFD_in_TIFF_impl()
4137 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF, done"); in exif_process_IFD_in_TIFF_impl()
4142 dir_entry = ImageInfo->file.list[sn].data+2+i*12; in exif_process_IFD_in_TIFF_impl()
4143 entry_tag = php_ifd_get16u(dir_entry+0, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4144 entry_type = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4153 ImageInfo->sections_found |= FOUND_EXIF; in exif_process_IFD_in_TIFF_impl()
4157 ImageInfo->sections_found |= FOUND_GPS; in exif_process_IFD_in_TIFF_impl()
4161 ImageInfo->sections_found |= FOUND_INTEROP; in exif_process_IFD_in_TIFF_impl()
4165 ImageInfo->sections_found |= FOUND_THUMBNAIL; in exif_process_IFD_in_TIFF_impl()
4169 entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4171 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s @x%04X", exif_get_sectionnam… in exif_process_IFD_in_TIFF_impl()
4173 exif_process_IFD_in_TIFF(ImageInfo, entry_offset, sub_section_index); in exif_process_IFD_in_TIFF_impl()
4175 if (ImageInfo->Thumbnail.filetype != IMAGE_FILETYPE_UNKNOWN in exif_process_IFD_in_TIFF_impl()
4176 && ImageInfo->Thumbnail.size in exif_process_IFD_in_TIFF_impl()
4177 && ImageInfo->Thumbnail.offset in exif_process_IFD_in_TIFF_impl()
4178 && ImageInfo->read_thumbnail in exif_process_IFD_in_TIFF_impl()
4181 …RR_CC, ImageInfo, E_NOTICE, "%s THUMBNAIL @0x%04X + 0x%04X", ImageInfo->Thumbnail.data ? "Ignore" … in exif_process_IFD_in_TIFF_impl()
4183 if (!ImageInfo->Thumbnail.data) { in exif_process_IFD_in_TIFF_impl()
4184 ImageInfo->Thumbnail.data = safe_emalloc(ImageInfo->Thumbnail.size, 1, 0); in exif_process_IFD_in_TIFF_impl()
4185 php_stream_seek(ImageInfo->infile, ImageInfo->Thumbnail.offset, SEEK_SET); in exif_process_IFD_in_TIFF_impl()
4186 … fgot = php_stream_read(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size); in exif_process_IFD_in_TIFF_impl()
4187 if (fgot != ImageInfo->Thumbnail.size) { in exif_process_IFD_in_TIFF_impl()
4188 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_process_IFD_in_TIFF_impl()
4189 efree(ImageInfo->Thumbnail.data); in exif_process_IFD_in_TIFF_impl()
4191 ImageInfo->Thumbnail.data = NULL; in exif_process_IFD_in_TIFF_impl()
4193 exif_thumbnail_build(ImageInfo); in exif_process_IFD_in_TIFF_impl()
4199 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s done", exif_get_sectionname(… in exif_process_IFD_in_TIFF_impl()
4204 (char *) (ImageInfo->file.list[sn].data - dir_offset), in exif_process_IFD_in_TIFF_impl()
4205 (char *) ImageInfo->file.list[sn].data, ifd_size); in exif_process_IFD_in_TIFF_impl()
4206 if (!exif_process_IFD_TAG(ImageInfo, (char*)dir_entry, &info, in exif_process_IFD_in_TIFF_impl()
4217 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read next IFD (THUMBNAIL) at x%04X", next… in exif_process_IFD_in_TIFF_impl()
4219 exif_process_IFD_in_TIFF(ImageInfo, next_offset, SECTION_THUMBNAIL); in exif_process_IFD_in_TIFF_impl()
4221 …RR_CC, ImageInfo, E_NOTICE, "%s THUMBNAIL @0x%04X + 0x%04X", ImageInfo->Thumbnail.data ? "Ignore" … in exif_process_IFD_in_TIFF_impl()
4223 …if (!ImageInfo->Thumbnail.data && ImageInfo->Thumbnail.offset && ImageInfo->Thumbnail.size && Imag… in exif_process_IFD_in_TIFF_impl()
4224 ImageInfo->Thumbnail.data = safe_emalloc(ImageInfo->Thumbnail.size, 1, 0); in exif_process_IFD_in_TIFF_impl()
4225 php_stream_seek(ImageInfo->infile, ImageInfo->Thumbnail.offset, SEEK_SET); in exif_process_IFD_in_TIFF_impl()
4226 … fgot = php_stream_read(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size); in exif_process_IFD_in_TIFF_impl()
4227 if (fgot != ImageInfo->Thumbnail.size) { in exif_process_IFD_in_TIFF_impl()
4228 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_process_IFD_in_TIFF_impl()
4229 efree(ImageInfo->Thumbnail.data); in exif_process_IFD_in_TIFF_impl()
4230 ImageInfo->Thumbnail.data = NULL; in exif_process_IFD_in_TIFF_impl()
4232 exif_thumbnail_build(ImageInfo); in exif_process_IFD_in_TIFF_impl()
4236 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read next IFD (THUMBNAIL) done"); in exif_process_IFD_in_TIFF_impl()
4241 … EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than size of IFD(x%04X)", … in exif_process_IFD_in_TIFF_impl()
4245 …or_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than size of… in exif_process_IFD_in_TIFF_impl()
4249 …or_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error in TIFF: filesize(x%04X) less than start o… in exif_process_IFD_in_TIFF_impl()
4255 static bool exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offset, int section_ind… in exif_process_IFD_in_TIFF() argument
4258 if (ImageInfo->ifd_count++ > MAX_IFD_TAGS) { in exif_process_IFD_in_TIFF()
4261 if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) { in exif_process_IFD_in_TIFF()
4264 ImageInfo->ifd_nesting_level++; in exif_process_IFD_in_TIFF()
4265 result = exif_process_IFD_in_TIFF_impl(ImageInfo, dir_offset, section_index); in exif_process_IFD_in_TIFF()
4266 ImageInfo->ifd_nesting_level--; in exif_process_IFD_in_TIFF()
4272 static bool exif_scan_FILE_header(image_info_type *ImageInfo) in exif_scan_FILE_header() argument
4277 ImageInfo->FileType = IMAGE_FILETYPE_UNKNOWN; in exif_scan_FILE_header()
4279 if (ImageInfo->FileSize >= 2) { in exif_scan_FILE_header()
4280 php_stream_seek(ImageInfo->infile, 0, SEEK_SET); in exif_scan_FILE_header()
4281 if (php_stream_read(ImageInfo->infile, (char*)file_header, 2) != 2) { in exif_scan_FILE_header()
4285 ImageInfo->FileType = IMAGE_FILETYPE_JPEG; in exif_scan_FILE_header()
4286 if (exif_scan_JPEG_header(ImageInfo)) { in exif_scan_FILE_header()
4289 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid JPEG file"); in exif_scan_FILE_header()
4291 } else if (ImageInfo->FileSize >= 8) { in exif_scan_FILE_header()
4292 if (php_stream_read(ImageInfo->infile, (char*)(file_header+2), 6) != 6) { in exif_scan_FILE_header()
4296 ImageInfo->FileType = IMAGE_FILETYPE_TIFF_II; in exif_scan_FILE_header()
4297 ImageInfo->motorola_intel = 0; in exif_scan_FILE_header()
4299 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "File has TIFF/II format"); in exif_scan_FILE_header()
4301 ImageInfo->sections_found |= FOUND_IFD0; in exif_scan_FILE_header()
4302 if (exif_process_IFD_in_TIFF(ImageInfo, in exif_scan_FILE_header()
4303 php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel), in exif_scan_FILE_header()
4307 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF file"); in exif_scan_FILE_header()
4310 ImageInfo->FileType = IMAGE_FILETYPE_TIFF_MM; in exif_scan_FILE_header()
4311 ImageInfo->motorola_intel = 1; in exif_scan_FILE_header()
4313 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "File has TIFF/MM format"); in exif_scan_FILE_header()
4315 ImageInfo->sections_found |= FOUND_IFD0; in exif_scan_FILE_header()
4316 if (exif_process_IFD_in_TIFF(ImageInfo, in exif_scan_FILE_header()
4317 php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel), in exif_scan_FILE_header()
4321 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF file"); in exif_scan_FILE_header()
4324 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "File not supported"); in exif_scan_FILE_header()
4329 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "File too small (%d)", ImageInfo->FileSiz… in exif_scan_FILE_header()
4338 static bool exif_discard_imageinfo(image_info_type *ImageInfo) in exif_discard_imageinfo() argument
4342 EFREE_IF(ImageInfo->FileName); in exif_discard_imageinfo()
4343 EFREE_IF(ImageInfo->UserComment); in exif_discard_imageinfo()
4344 EFREE_IF(ImageInfo->UserCommentEncoding); in exif_discard_imageinfo()
4345 EFREE_IF(ImageInfo->Copyright); in exif_discard_imageinfo()
4346 EFREE_IF(ImageInfo->CopyrightPhotographer); in exif_discard_imageinfo()
4347 EFREE_IF(ImageInfo->CopyrightEditor); in exif_discard_imageinfo()
4348 EFREE_IF(ImageInfo->Thumbnail.data); in exif_discard_imageinfo()
4349 EFREE_IF(ImageInfo->encode_unicode); in exif_discard_imageinfo()
4350 EFREE_IF(ImageInfo->decode_unicode_be); in exif_discard_imageinfo()
4351 EFREE_IF(ImageInfo->decode_unicode_le); in exif_discard_imageinfo()
4352 EFREE_IF(ImageInfo->encode_jis); in exif_discard_imageinfo()
4353 EFREE_IF(ImageInfo->decode_jis_be); in exif_discard_imageinfo()
4354 EFREE_IF(ImageInfo->decode_jis_le); in exif_discard_imageinfo()
4355 EFREE_IF(ImageInfo->make); in exif_discard_imageinfo()
4356 EFREE_IF(ImageInfo->model); in exif_discard_imageinfo()
4357 for (i=0; i<ImageInfo->xp_fields.count; i++) { in exif_discard_imageinfo()
4358 EFREE_IF(ImageInfo->xp_fields.list[i].value); in exif_discard_imageinfo()
4360 EFREE_IF(ImageInfo->xp_fields.list); in exif_discard_imageinfo()
4362 exif_iif_free(ImageInfo, i); in exif_discard_imageinfo()
4364 exif_file_sections_free(ImageInfo); in exif_discard_imageinfo()
4365 memset(ImageInfo, 0, sizeof(*ImageInfo)); in exif_discard_imageinfo()
4371 static bool exif_read_from_impl(image_info_type *ImageInfo, php_stream *stream, int read_thumbnail,… in exif_read_from_impl() argument
4377 memset(ImageInfo, 0, sizeof(*ImageInfo)); in exif_read_from_impl()
4379 ImageInfo->motorola_intel = -1; /* flag as unknown */ in exif_read_from_impl()
4380 ImageInfo->infile = stream; in exif_read_from_impl()
4381 ImageInfo->FileName = NULL; in exif_read_from_impl()
4383 if (php_stream_is(ImageInfo->infile, PHP_STREAM_IS_STDIO)) { in exif_read_from_impl()
4387 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Not a file"); in exif_read_from_impl()
4388 ImageInfo->infile = NULL; in exif_read_from_impl()
4394 ImageInfo->FileName = estrndup(ZSTR_VAL(base), ZSTR_LEN(base)); in exif_read_from_impl()
4399 ImageInfo->FileDateTime = st.st_mtime; in exif_read_from_impl()
4400 ImageInfo->FileSize = st.st_size; in exif_read_from_impl()
4403 if (!ImageInfo->FileSize) { in exif_read_from_impl()
4404 php_stream_seek(ImageInfo->infile, 0, SEEK_END); in exif_read_from_impl()
4405 ImageInfo->FileSize = php_stream_tell(ImageInfo->infile); in exif_read_from_impl()
4406 php_stream_seek(ImageInfo->infile, 0, SEEK_SET); in exif_read_from_impl()
4410 ImageInfo->read_thumbnail = read_thumbnail; in exif_read_from_impl()
4411 ImageInfo->read_all = read_all; in exif_read_from_impl()
4412 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_UNKNOWN; in exif_read_from_impl()
4414 ImageInfo->encode_unicode = estrdup(EXIF_G(encode_unicode)); in exif_read_from_impl()
4415 ImageInfo->decode_unicode_be = estrdup(EXIF_G(decode_unicode_be)); in exif_read_from_impl()
4416 ImageInfo->decode_unicode_le = estrdup(EXIF_G(decode_unicode_le)); in exif_read_from_impl()
4417 ImageInfo->encode_jis = estrdup(EXIF_G(encode_jis)); in exif_read_from_impl()
4418 ImageInfo->decode_jis_be = estrdup(EXIF_G(decode_jis_be)); in exif_read_from_impl()
4419 ImageInfo->decode_jis_le = estrdup(EXIF_G(decode_jis_le)); in exif_read_from_impl()
4422 ImageInfo->ifd_nesting_level = 0; in exif_read_from_impl()
4423 ImageInfo->ifd_count = 0; in exif_read_from_impl()
4424 ImageInfo->num_errors = 0; in exif_read_from_impl()
4427 ret = exif_scan_FILE_header(ImageInfo); in exif_read_from_impl()
4434 static bool exif_read_from_stream(image_info_type *ImageInfo, php_stream *stream, int read_thumbnai… in exif_read_from_stream() argument
4443 ret = exif_read_from_impl(ImageInfo, stream, read_thumbnail, read_all); in exif_read_from_stream()
4454 static bool exif_read_from_file(image_info_type *ImageInfo, char *FileName, int read_thumbnail, int… in exif_read_from_file() argument
4462 memset(&ImageInfo, 0, sizeof(ImageInfo)); in exif_read_from_file()
4464 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Unable to open file"); in exif_read_from_file()
4469 ret = exif_read_from_stream(ImageInfo, stream, read_thumbnail, read_all); in exif_read_from_file()
4485 image_info_type ImageInfo; in PHP_FUNCTION() local
4497 memset(&ImageInfo, 0, sizeof(ImageInfo)); in PHP_FUNCTION()
4522 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections needed: %s", sections_str[0] ? … in PHP_FUNCTION()
4532 ret = exif_read_from_stream(&ImageInfo, p_stream, read_thumbnail, read_all); in PHP_FUNCTION()
4548 ret = exif_read_from_file(&ImageInfo, Z_STRVAL_P(stream), read_thumbnail, read_all); in PHP_FUNCTION()
4551 sections_str = exif_get_sectionlist(ImageInfo.sections_found); in PHP_FUNCTION()
4555 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections found: %s", sections_str[0] ? s… in PHP_FUNCTION()
4559 ImageInfo.sections_found |= FOUND_COMPUTED|FOUND_FILE;/* do not inform about in debug*/ in PHP_FUNCTION()
4561 if (ret == false || (sections_needed && !(sections_needed&ImageInfo.sections_found))) { in PHP_FUNCTION()
4563 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4571 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section FILE"); in PHP_FUNCTION()
4575 exif_iif_add_str(&ImageInfo, SECTION_FILE, "FileName", ImageInfo.FileName); in PHP_FUNCTION()
4576 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileDateTime", ImageInfo.FileDateTime); in PHP_FUNCTION()
4577 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileSize", ImageInfo.FileSize); in PHP_FUNCTION()
4578 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileType", ImageInfo.FileType); in PHP_FUNCTION()
4579 …exif_iif_add_str(&ImageInfo, SECTION_FILE, "MimeType", (char*)php_image_type_to_mime_type(Ima… in PHP_FUNCTION()
4580 exif_iif_add_str(&ImageInfo, SECTION_FILE, "SectionsFound", sections_str ? sections_str : "NONE"); in PHP_FUNCTION()
4583 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section COMPUTED"); in PHP_FUNCTION()
4586 if (ImageInfo.Width>0 && ImageInfo.Height>0) { in PHP_FUNCTION()
4587 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "html" , "width=\"%d\" height=\"%d\"", ImageInfo.… in PHP_FUNCTION()
4588 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Height", ImageInfo.Height); in PHP_FUNCTION()
4589 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Width", ImageInfo.Width); in PHP_FUNCTION()
4591 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "IsColor", ImageInfo.IsColor); in PHP_FUNCTION()
4592 if (ImageInfo.motorola_intel != -1) { in PHP_FUNCTION()
4593 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "ByteOrderMotorola", ImageInfo.motorola_intel); in PHP_FUNCTION()
4595 if (ImageInfo.FocalLength) { in PHP_FUNCTION()
4596 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocalLength", "%4.1Fmm", ImageInfo.FocalLength); in PHP_FUNCTION()
4597 if(ImageInfo.CCDWidth) { in PHP_FUNCTION()
4598 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "35mmFocalLength", "%dmm", (int)(ImageInfo.FocalLen… in PHP_FUNCTION()
4601 if(ImageInfo.CCDWidth) { in PHP_FUNCTION()
4602 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "CCDWidth", "%dmm", (int)ImageInfo.CCDWidth); in PHP_FUNCTION()
4604 if(ImageInfo.ExposureTime>0) { in PHP_FUNCTION()
4605 float recip_exposure_time = 0.5f + 1.0f/ImageInfo.ExposureTime; in PHP_FUNCTION()
4606 if (ImageInfo.ExposureTime <= 0.5 && recip_exposure_time < (float)INT_MAX) { in PHP_FUNCTION()
4607 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime", "%0.3F s (1/%d)", ImageInfo.Exposur… in PHP_FUNCTION()
4609 … exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime", "%0.3F s", ImageInfo.ExposureTime); in PHP_FUNCTION()
4612 if(ImageInfo.ApertureFNumber) { in PHP_FUNCTION()
4613 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ApertureFNumber", "f/%.1F", ImageInfo.ApertureFNum… in PHP_FUNCTION()
4615 if(ImageInfo.Distance) { in PHP_FUNCTION()
4616 if(ImageInfo.Distance<0) { in PHP_FUNCTION()
4617 exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "FocusDistance", "Infinite"); in PHP_FUNCTION()
4619 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocusDistance", "%0.2Fm", ImageInfo.Distance); in PHP_FUNCTION()
4622 if (ImageInfo.UserComment) { in PHP_FUNCTION()
4623 …exif_iif_add_buffer(&ImageInfo, SECTION_COMPUTED, "UserComment", ImageInfo.UserCommentLength, Imag… in PHP_FUNCTION()
4624 if (ImageInfo.UserCommentEncoding && strlen(ImageInfo.UserCommentEncoding)) { in PHP_FUNCTION()
4625 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "UserCommentEncoding", ImageInfo.UserCommentEncodin… in PHP_FUNCTION()
4629 exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright", ImageInfo.Copyright); in PHP_FUNCTION()
4630 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Photographer", ImageInfo.CopyrightPhotog… in PHP_FUNCTION()
4631 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Editor", ImageInfo.CopyrightEditor… in PHP_FUNCTION()
4633 for (i=0; i<ImageInfo.xp_fields.count; i++) { in PHP_FUNCTION()
4634 …iif_add_str(&ImageInfo, SECTION_WINXP, exif_get_tagname_debug(ImageInfo.xp_fields.list[i].tag, exi… in PHP_FUNCTION()
4636 if (ImageInfo.Thumbnail.size) { in PHP_FUNCTION()
4639 …_add_tag(&ImageInfo, SECTION_THUMBNAIL, "THUMBNAIL", TAG_NONE, TAG_FMT_UNDEFINED, ImageInfo.Thumbn… in PHP_FUNCTION()
4641 if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4643 exif_scan_thumbnail(&ImageInfo); in PHP_FUNCTION()
4645 …exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.FileType", ImageInfo.Thumbnail.filetype); in PHP_FUNCTION()
4646 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Thumbnail.MimeType", (char*)php_image_type_to_mime… in PHP_FUNCTION()
4648 if (ImageInfo.Thumbnail.width && ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4649 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Height", ImageInfo.Thumbnail.height); in PHP_FUNCTION()
4650 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Width", ImageInfo.Thumbnail.width); in PHP_FUNCTION()
4655 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Adding image infos"); in PHP_FUNCTION()
4658 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FILE ); in PHP_FUNCTION()
4659 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMPUTED ); in PHP_FUNCTION()
4660 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_ANY_TAG ); in PHP_FUNCTION()
4661 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_IFD0 ); in PHP_FUNCTION()
4662 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_THUMBNAIL ); in PHP_FUNCTION()
4663 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMMENT ); in PHP_FUNCTION()
4664 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_EXIF ); in PHP_FUNCTION()
4665 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_GPS ); in PHP_FUNCTION()
4666 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_INTEROP ); in PHP_FUNCTION()
4667 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FPIX ); in PHP_FUNCTION()
4668 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_APP12 ); in PHP_FUNCTION()
4669 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_WINXP ); in PHP_FUNCTION()
4670 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_MAKERNOTE ); in PHP_FUNCTION()
4673 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Discarding info"); in PHP_FUNCTION()
4676 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4689 image_info_type ImageInfo; in PHP_FUNCTION() local
4702 memset(&ImageInfo, 0, sizeof(ImageInfo)); in PHP_FUNCTION()
4709 ret = exif_read_from_stream(&ImageInfo, p_stream, 1, 0); in PHP_FUNCTION()
4725 ret = exif_read_from_file(&ImageInfo, Z_STRVAL_P(stream), 1, 0); in PHP_FUNCTION()
4729 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4734 …ImageInfo, E_NOTICE, "Thumbnail data %d %d %d, %d x %d", ImageInfo.Thumbnail.data, ImageInfo.Thumb… in PHP_FUNCTION()
4736 if (!ImageInfo.Thumbnail.data || !ImageInfo.Thumbnail.size) { in PHP_FUNCTION()
4737 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4742 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Returning thumbnail(%d)", ImageInfo.Thum… in PHP_FUNCTION()
4745 ZVAL_STRINGL(return_value, ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size); in PHP_FUNCTION()
4747 if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4748 if (!exif_scan_thumbnail(&ImageInfo)) { in PHP_FUNCTION()
4749 ImageInfo.Thumbnail.width = ImageInfo.Thumbnail.height = 0; in PHP_FUNCTION()
4752 ZEND_TRY_ASSIGN_REF_LONG(z_width, ImageInfo.Thumbnail.width); in PHP_FUNCTION()
4753 ZEND_TRY_ASSIGN_REF_LONG(z_height, ImageInfo.Thumbnail.height); in PHP_FUNCTION()
4756 ZEND_TRY_ASSIGN_REF_LONG(z_imagetype, ImageInfo.Thumbnail.filetype); in PHP_FUNCTION()
4760 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Discarding info"); in PHP_FUNCTION()
4763 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()