Lines Matching refs:ImageInfo

257 #define EXIF_ERRLOG_FILEEOF(ImageInfo)    exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, …  argument
258 #define EXIF_ERRLOG_CORRUPT(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, … argument
259 #define EXIF_ERRLOG_THUMBEOF(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, … argument
260 #define EXIF_ERRLOG_FSREALLOC(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, … argument
2015 static void exif_error_docref(const char *docref EXIFERR_DC, image_info_type *ImageInfo, int type, … in exif_error_docref() argument
2019 if (ImageInfo) { in exif_error_docref()
2020 if (++ImageInfo->num_errors > EXIF_MAX_ERRORS) { in exif_error_docref()
2021 if (ImageInfo->num_errors == EXIF_MAX_ERRORS+1) { in exif_error_docref()
2035 php_verror(docref, ImageInfo && ImageInfo->FileName ? ImageInfo->FileName:"", type, buf, args); in exif_error_docref()
2039 php_verror(docref, ImageInfo && ImageInfo->FileName ? ImageInfo->FileName:"", type, format, args); in exif_error_docref()
2122 static int exif_file_sections_add(image_info_type *ImageInfo, int type, size_t size, uchar *data) in exif_file_sections_add() argument
2124 int count = ImageInfo->file.count; in exif_file_sections_add()
2125 if (count == ImageInfo->file.alloc_count) { in exif_file_sections_add()
2126 int new_alloc_count = ImageInfo->file.alloc_count ? ImageInfo->file.alloc_count * 2 : 1; in exif_file_sections_add()
2127 ImageInfo->file.list = safe_erealloc( in exif_file_sections_add()
2128 ImageInfo->file.list, new_alloc_count, sizeof(file_section), 0); in exif_file_sections_add()
2129 ImageInfo->file.alloc_count = new_alloc_count; in exif_file_sections_add()
2132 ImageInfo->file.list[count].type = 0xFFFF; in exif_file_sections_add()
2133 ImageInfo->file.list[count].data = NULL; in exif_file_sections_add()
2134 ImageInfo->file.list[count].size = 0; in exif_file_sections_add()
2135 ImageInfo->file.count = count+1; in exif_file_sections_add()
2141 ImageInfo->file.list[count].type = type; in exif_file_sections_add()
2142 ImageInfo->file.list[count].data = data; in exif_file_sections_add()
2143 ImageInfo->file.list[count].size = size; in exif_file_sections_add()
2151 static int exif_file_sections_realloc(image_info_type *ImageInfo, int section_index, size_t size) in exif_file_sections_realloc() argument
2158 if (section_index >= ImageInfo->file.count) { in exif_file_sections_realloc()
2159 EXIF_ERRLOG_FSREALLOC(ImageInfo) in exif_file_sections_realloc()
2162 tmp = safe_erealloc(ImageInfo->file.list[section_index].data, 1, size, 0); in exif_file_sections_realloc()
2163 ImageInfo->file.list[section_index].data = tmp; in exif_file_sections_realloc()
2164 ImageInfo->file.list[section_index].size = size; in exif_file_sections_realloc()
2172 static bool exif_file_sections_free(image_info_type *ImageInfo) in exif_file_sections_free() argument
2176 if (ImageInfo->file.count) { in exif_file_sections_free()
2177 for (i=0; i<ImageInfo->file.count; i++) { in exif_file_sections_free()
2178 EFREE_IF(ImageInfo->file.list[i].data); in exif_file_sections_free()
2181 EFREE_IF(ImageInfo->file.list); in exif_file_sections_free()
2182 ImageInfo->file.count = 0; in exif_file_sections_free()
2725 static bool exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, const exif_offset…
2726 static bool exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, const exif_offset_inf…
2727 static bool exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offset, int section_ind…
2880 static void exif_thumbnail_build(image_info_type *ImageInfo) { in exif_thumbnail_build() argument
2888 if (!ImageInfo->read_thumbnail || !ImageInfo->Thumbnail.offset || !ImageInfo->Thumbnail.size) { in exif_thumbnail_build()
2892 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: filetype = %d", ImageInfo->Thu… in exif_thumbnail_build()
2894 switch(ImageInfo->Thumbnail.filetype) { in exif_thumbnail_build()
2901 info_list = &ImageInfo->info_list[SECTION_THUMBNAIL]; in exif_thumbnail_build()
2904 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: size of signature + directory(… in exif_thumbnail_build()
2915 new_data = safe_erealloc(ImageInfo->Thumbnail.data, 1, ImageInfo->Thumbnail.size, new_size); in exif_thumbnail_build()
2916 ImageInfo->Thumbnail.data = new_data; in exif_thumbnail_build()
2917 …memmove(ImageInfo->Thumbnail.data + new_move, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size… in exif_thumbnail_build()
2918 ImageInfo->Thumbnail.size += new_size; in exif_thumbnail_build()
2920 if (ImageInfo->motorola_intel) { in exif_thumbnail_build()
2926 php_ifd_set16u(new_data, info_list->count, ImageInfo->motorola_intel); in exif_thumbnail_build()
2932 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: process tag(x%04X=%s): %s%s (%… in exif_thumbnail_build()
2935 php_ifd_set16u(new_data + 0, info_data->tag, ImageInfo->motorola_intel); in exif_thumbnail_build()
2936 php_ifd_set16u(new_data + 2, TAG_FMT_ULONG, ImageInfo->motorola_intel); in exif_thumbnail_build()
2937 php_ifd_set32u(new_data + 4, 1, ImageInfo->motorola_intel); in exif_thumbnail_build()
2938 php_ifd_set32u(new_data + 8, new_move, ImageInfo->motorola_intel); in exif_thumbnail_build()
2940 php_ifd_set16u(new_data + 0, info_data->tag, ImageInfo->motorola_intel); in exif_thumbnail_build()
2941 php_ifd_set16u(new_data + 2, info_data->format, ImageInfo->motorola_intel); in exif_thumbnail_build()
2942 php_ifd_set32u(new_data + 4, info_data->length, ImageInfo->motorola_intel); in exif_thumbnail_build()
2943 value_ptr = exif_ifd_make_value(info_data, ImageInfo->motorola_intel); in exif_thumbnail_build()
2947 php_ifd_set32u(new_data+8, new_value, ImageInfo->motorola_intel); in exif_thumbnail_build()
2949 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: writing with value offset: 0x%… in exif_thumbnail_build()
2951 memmove(ImageInfo->Thumbnail.data+new_value, value_ptr, byte_count); in exif_thumbnail_build()
2960 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: created"); in exif_thumbnail_build()
2969 static void exif_thumbnail_extract(image_info_type *ImageInfo, const exif_offset_info *info) { in exif_thumbnail_extract() argument
2970 if (ImageInfo->Thumbnail.data) { in exif_thumbnail_extract()
2971 …exif_error_docref("exif_read_data#error_mult_thumb" EXIFERR_CC, ImageInfo, E_WARNING, "Multiple po… in exif_thumbnail_extract()
2974 if (!ImageInfo->read_thumbnail) { in exif_thumbnail_extract()
2978 if (ImageInfo->Thumbnail.size >= 65536 in exif_thumbnail_extract()
2979 || ImageInfo->Thumbnail.size <= 0 in exif_thumbnail_extract()
2980 || ImageInfo->Thumbnail.offset <= 0 in exif_thumbnail_extract()
2982 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Illegal thumbnail size/offset"); in exif_thumbnail_extract()
2987 info, ImageInfo->Thumbnail.offset, ImageInfo->Thumbnail.size); in exif_thumbnail_extract()
2989 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_thumbnail_extract()
2992 ImageInfo->Thumbnail.data = estrndup(thumbnail, ImageInfo->Thumbnail.size); in exif_thumbnail_extract()
2993 exif_thumbnail_build(ImageInfo); in exif_thumbnail_extract()
3051 static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoPtr, char **pszEncod… in exif_process_user_comment() argument
3076 } else if (ImageInfo->motorola_intel) { in exif_process_user_comment()
3077 decode = ImageInfo->decode_unicode_be; in exif_process_user_comment()
3079 decode = ImageInfo->decode_unicode_le; in exif_process_user_comment()
3081 to = zend_multibyte_fetch_encoding(ImageInfo->encode_unicode); in exif_process_user_comment()
3104 to = zend_multibyte_fetch_encoding(ImageInfo->encode_jis); in exif_process_user_comment()
3105 …from = zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_jis_be : ImageI… in exif_process_user_comment()
3139 static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char … in exif_process_unicode() argument
3149 zend_multibyte_fetch_encoding(ImageInfo->encode_unicode), in exif_process_unicode()
3150 …zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_unicode_be : ImageInfo in exif_process_unicode()
3160 static bool exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * value_ptr, int value_l… in exif_process_IFD_in_MAKERNOTE() argument
3172 …FERR_CC, ImageInfo, E_NOTICE, "No maker note data found. Detected maker: %s (length = %d)", ImageI… in exif_process_IFD_in_MAKERNOTE()
3180 if (maker_note->make && (!ImageInfo->make || strcmp(maker_note->make, ImageInfo->make))) in exif_process_IFD_in_MAKERNOTE()
3190 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short… in exif_process_IFD_in_MAKERNOTE()
3203 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s @0x%04X + 0x%04X=%d: %s", exif… in exif_process_IFD_in_MAKERNOTE()
3206 ImageInfo->sections_found |= FOUND_MAKERNOTE; in exif_process_IFD_in_MAKERNOTE()
3208 old_motorola_intel = ImageInfo->motorola_intel; in exif_process_IFD_in_MAKERNOTE()
3211 ImageInfo->motorola_intel = 0; in exif_process_IFD_in_MAKERNOTE()
3214 ImageInfo->motorola_intel = 1; in exif_process_IFD_in_MAKERNOTE()
3221 NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); in exif_process_IFD_in_MAKERNOTE()
3225 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Potentially invalid endianess, trying aga… in exif_process_IFD_in_MAKERNOTE()
3227 ImageInfo->motorola_intel = ImageInfo->motorola_intel == 0 ? 1 : 0; in exif_process_IFD_in_MAKERNOTE()
3228 NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); in exif_process_IFD_in_MAKERNOTE()
3232 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_MAKERNOTE()
3236 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_MAKERNOTE()
3252 if (!exif_process_IFD_TAG(ImageInfo, dir_start + offset, in exif_process_IFD_in_MAKERNOTE()
3257 ImageInfo->motorola_intel = old_motorola_intel; in exif_process_IFD_in_MAKERNOTE()
3260 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Subsection %s done", exif_get_sectionname… in exif_process_IFD_in_MAKERNOTE()
3268 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=…
3276 static bool exif_process_IFD_TAG_impl(image_info_type *ImageInfo, char *dir_entry, const exif_offse… in exif_process_IFD_TAG_impl() argument
3289 tag = php_ifd_get16u(dir_entry, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3290 format = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3291 components = php_ifd_get32u(dir_entry+4, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3295 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG_impl()
3302 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=… in exif_process_IFD_TAG_impl()
3310 offset_val = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3317ImageInfo->FileSize || offset_val>ImageInfo->FileSize-byte_count || (ImageInfo->FileType!=IMAGE_FI… in exif_process_IFD_TAG_impl()
3318ImageInfo, E_WARNING, "Process tag(x%04X=%s): Illegal pointer offset(x%04X + x%04X = x%04X > x%04X… in exif_process_IFD_TAG_impl()
3335 fpos = php_stream_tell(ImageInfo->infile); in exif_process_IFD_TAG_impl()
3336 php_stream_seek(ImageInfo->infile, displacement+offset_val, SEEK_SET); in exif_process_IFD_TAG_impl()
3337 fgot = php_stream_tell(ImageInfo->infile); in exif_process_IFD_TAG_impl()
3340 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Wrong file pointer: 0x%08X != 0x%08X", f… in exif_process_IFD_TAG_impl()
3343 fgot = exif_read_from_stream_file_looped(ImageInfo->infile, value_ptr, byte_count); in exif_process_IFD_TAG_impl()
3344 php_stream_seek(ImageInfo->infile, fpos, SEEK_SET); in exif_process_IFD_TAG_impl()
3347 EXIF_ERRLOG_FILEEOF(ImageInfo) in exif_process_IFD_TAG_impl()
3358 ImageInfo->sections_found |= FOUND_ANY_TAG; in exif_process_IFD_TAG_impl()
3360 dump_data = exif_dump_data(&dump_free, format, components, ImageInfo->motorola_intel, value_ptr); in exif_process_IFD_TAG_impl()
3361 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, in exif_process_IFD_TAG_impl()
3373 if (!ImageInfo->Thumbnail.data) { in exif_process_IFD_TAG_impl()
3378ImageInfo->Thumbnail.width = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigne… in exif_process_IFD_TAG_impl()
3383ImageInfo->Thumbnail.height = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsign… in exif_process_IFD_TAG_impl()
3389ImageInfo->Thumbnail.offset = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsign… in exif_process_IFD_TAG_impl()
3393 …if (ImageInfo->FileType == IMAGE_FILETYPE_TIFF_II || ImageInfo->FileType == IMAGE_FILETYPE_TIFF_MM… in exif_process_IFD_TAG_impl()
3394 ImageInfo->Thumbnail.filetype = ImageInfo->FileType; in exif_process_IFD_TAG_impl()
3397 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_TIFF_MM; in exif_process_IFD_TAG_impl()
3399ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned… in exif_process_IFD_TAG_impl()
3403 if (ImageInfo->Thumbnail.filetype == IMAGE_FILETYPE_UNKNOWN) { in exif_process_IFD_TAG_impl()
3404 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_JPEG; in exif_process_IFD_TAG_impl()
3405ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned… in exif_process_IFD_TAG_impl()
3418 EFREE_IF(ImageInfo->CopyrightPhotographer); in exif_process_IFD_TAG_impl()
3419 EFREE_IF(ImageInfo->CopyrightEditor); in exif_process_IFD_TAG_impl()
3420 EFREE_IF(ImageInfo->Copyright); in exif_process_IFD_TAG_impl()
3421 ImageInfo->CopyrightPhotographer = estrdup(value_ptr); in exif_process_IFD_TAG_impl()
3422 ImageInfo->CopyrightEditor = estrndup(value_ptr+length+1, byte_count-length-1); in exif_process_IFD_TAG_impl()
3423 …spprintf(&ImageInfo->Copyright, 0, "%s, %s", ImageInfo->CopyrightPhotographer, ImageInfo->Copyrigh… in exif_process_IFD_TAG_impl()
3428 EFREE_IF(ImageInfo->Copyright); in exif_process_IFD_TAG_impl()
3429 ImageInfo->Copyright = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG_impl()
3435 EFREE_IF(ImageInfo->UserComment); in exif_process_IFD_TAG_impl()
3436 ImageInfo->UserComment = NULL; in exif_process_IFD_TAG_impl()
3437 EFREE_IF(ImageInfo->UserCommentEncoding); in exif_process_IFD_TAG_impl()
3438 ImageInfo->UserCommentEncoding = NULL; in exif_process_IFD_TAG_impl()
3439ImageInfo->UserCommentLength = exif_process_user_comment(ImageInfo, &(ImageInfo->UserComment), &(I… in exif_process_IFD_TAG_impl()
3447 …tmp_xp = (xp_field_type*)safe_erealloc(ImageInfo->xp_fields.list, (ImageInfo->xp_fields.count+1), … in exif_process_IFD_TAG_impl()
3448 ImageInfo->sections_found |= FOUND_WINXP; in exif_process_IFD_TAG_impl()
3449 ImageInfo->xp_fields.list = tmp_xp; in exif_process_IFD_TAG_impl()
3450 ImageInfo->xp_fields.count++; in exif_process_IFD_TAG_impl()
3451 …exif_process_unicode(ImageInfo, &(ImageInfo->xp_fields.list[ImageInfo->xp_fields.count-1]), tag, v… in exif_process_IFD_TAG_impl()
3458ImageInfo->ApertureFNumber = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola… in exif_process_IFD_TAG_impl()
3465 if (ImageInfo->ApertureFNumber == 0) { in exif_process_IFD_TAG_impl()
3467 ImageInfo->ApertureFNumber in exif_process_IFD_TAG_impl()
3468 = expf(exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)*logf(2.0)*0.5); in exif_process_IFD_TAG_impl()
3477 if (ImageInfo->ExposureTime == 0) { in exif_process_IFD_TAG_impl()
3479 ImageInfo->ExposureTime in exif_process_IFD_TAG_impl()
3480 = expf(-exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel)*logf(2.0)); in exif_process_IFD_TAG_impl()
3484 ImageInfo->ExposureTime = -1; in exif_process_IFD_TAG_impl()
3489ImageInfo->ExifImageWidth = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned… in exif_process_IFD_TAG_impl()
3494ImageInfo->FocalplaneXRes = exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3501ImageInfo->Distance = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3506 switch (exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel)) { in exif_process_IFD_TAG_impl()
3507 case 1: ImageInfo->FocalplaneUnits = 25.4; break; /* inch */ in exif_process_IFD_TAG_impl()
3512 ImageInfo->FocalplaneUnits = 25.4; in exif_process_IFD_TAG_impl()
3515 case 3: ImageInfo->FocalplaneUnits = 10; break; /* centimeter */ in exif_process_IFD_TAG_impl()
3516 case 4: ImageInfo->FocalplaneUnits = 1; break; /* milimeter */ in exif_process_IFD_TAG_impl()
3517 case 5: ImageInfo->FocalplaneUnits = .001; break; /* micrometer */ in exif_process_IFD_TAG_impl()
3526 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Skip SUB IFD"); in exif_process_IFD_TAG_impl()
3531 EFREE_IF(ImageInfo->make); in exif_process_IFD_TAG_impl()
3532 ImageInfo->make = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG_impl()
3535 EFREE_IF(ImageInfo->model); in exif_process_IFD_TAG_impl()
3536 ImageInfo->model = estrndup(value_ptr, byte_count); in exif_process_IFD_TAG_impl()
3540 if (!exif_process_IFD_in_MAKERNOTE(ImageInfo, value_ptr, byte_count, info, displacement)) { in exif_process_IFD_TAG_impl()
3556 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found EXIF"); in exif_process_IFD_TAG_impl()
3558 ImageInfo->sections_found |= FOUND_EXIF; in exif_process_IFD_TAG_impl()
3563 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found GPS"); in exif_process_IFD_TAG_impl()
3565 ImageInfo->sections_found |= FOUND_GPS; in exif_process_IFD_TAG_impl()
3570 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Found INTEROPERABILITY"); in exif_process_IFD_TAG_impl()
3572 ImageInfo->sections_found |= FOUND_INTEROP; in exif_process_IFD_TAG_impl()
3576 offset_val = php_ifd_get32u(value_ptr, ImageInfo->motorola_intel); in exif_process_IFD_TAG_impl()
3579 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD Pointe… in exif_process_IFD_TAG_impl()
3583 …if (!exif_process_IFD_in_JPEG(ImageInfo, Subdir_start, info, displacement, sub_section_index, tag)… in exif_process_IFD_TAG_impl()
3588 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Subsection %s done", exif_get_sectionname… in exif_process_IFD_TAG_impl()
3593 …exif_iif_add_tag(ImageInfo, section_index, exif_get_tagname_key(tag, tagname, sizeof(tagname), tag… in exif_process_IFD_TAG_impl()
3599 static bool exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, const exif_offset_inf… in exif_process_IFD_TAG() argument
3603 if (ImageInfo->ifd_count++ > MAX_IFD_TAGS) { in exif_process_IFD_TAG()
3604 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "corrupt EXIF heade… in exif_process_IFD_TAG()
3607 if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) { in exif_process_IFD_TAG()
3608 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "corrupt EXIF heade… in exif_process_IFD_TAG()
3611 ImageInfo->ifd_nesting_level++; in exif_process_IFD_TAG()
3612 …result = exif_process_IFD_TAG_impl(ImageInfo, dir_entry, info, displacement, section_index, ReadNe… in exif_process_IFD_TAG()
3613 ImageInfo->ifd_nesting_level--; in exif_process_IFD_TAG()
3619 static bool exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, const exif_offset… in exif_process_IFD_in_JPEG() argument
3626 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s (x%04X(=%d))", exif_get_sectio… in exif_process_IFD_in_JPEG()
3629 ImageInfo->sections_found |= FOUND_IFD0; in exif_process_IFD_in_JPEG()
3632 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size"); in exif_process_IFD_in_JPEG()
3636 NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); in exif_process_IFD_in_JPEG()
3639 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: … in exif_process_IFD_in_JPEG()
3644 if (!exif_process_IFD_TAG(ImageInfo, dir_start + 2 + 12 * de, in exif_process_IFD_in_JPEG()
3660 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size"); in exif_process_IFD_in_JPEG()
3665 NextDirOffset = php_ifd_get32u(dir_start+2+12*de, ImageInfo->motorola_intel); in exif_process_IFD_in_JPEG()
3671 …exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD offset… in exif_process_IFD_in_JPEG()
3676 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Expect next IFD to be thumbnail"); in exif_process_IFD_in_JPEG()
3678 …if (exif_process_IFD_in_JPEG(ImageInfo, next_dir_start, info, displacement, SECTION_THUMBNAIL, 0))… in exif_process_IFD_in_JPEG()
3680 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail size: 0x%04X", ImageInfo->Thumb… in exif_process_IFD_in_JPEG()
3682 if (ImageInfo->Thumbnail.filetype != IMAGE_FILETYPE_UNKNOWN in exif_process_IFD_in_JPEG()
3683 && ImageInfo->Thumbnail.size in exif_process_IFD_in_JPEG()
3684 && ImageInfo->Thumbnail.offset in exif_process_IFD_in_JPEG()
3685 && ImageInfo->read_thumbnail in exif_process_IFD_in_JPEG()
3687 exif_thumbnail_extract(ImageInfo, info); in exif_process_IFD_in_JPEG()
3701 static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf, size_t length, siz… in exif_process_TIFF_in_JPEG() argument
3707 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker"); in exif_process_TIFF_in_JPEG()
3712 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker"); in exif_process_TIFF_in_JPEG()
3718 ImageInfo->motorola_intel = 0; in exif_process_TIFF_in_JPEG()
3720 ImageInfo->motorola_intel = 1; in exif_process_TIFF_in_JPEG()
3722 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF alignment marker"); in exif_process_TIFF_in_JPEG()
3728 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF start (1)"); in exif_process_TIFF_in_JPEG()
3731 exif_value_2a = php_ifd_get16u(CharBuf+2, ImageInfo->motorola_intel); in exif_process_TIFF_in_JPEG()
3732 offset_of_ifd = php_ifd_get32u(CharBuf+4, ImageInfo->motorola_intel); in exif_process_TIFF_in_JPEG()
3734 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF start (1)"); in exif_process_TIFF_in_JPEG()
3738 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid IFD start"); in exif_process_TIFF_in_JPEG()
3742 ImageInfo->sections_found |= FOUND_IFD0; in exif_process_TIFF_in_JPEG()
3745 exif_process_IFD_in_JPEG(ImageInfo, CharBuf+offset_of_ifd, &info, displacement, SECTION_IFD0, 0); in exif_process_TIFF_in_JPEG()
3748 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process TIFF in JPEG done"); in exif_process_TIFF_in_JPEG()
3752 if (ImageInfo->FocalplaneXRes != 0) { in exif_process_TIFF_in_JPEG()
3753ImageInfo->CCDWidth = (float)(ImageInfo->ExifImageWidth * ImageInfo->FocalplaneUnits / ImageInfo->… in exif_process_TIFF_in_JPEG()
3762 static void exif_process_APP1(image_info_type *ImageInfo, char *CharBuf, size_t length, size_t disp… in exif_process_APP1() argument
3767 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Incorrect APP1 Exif Identifier Code"); in exif_process_APP1()
3770 exif_process_TIFF_in_JPEG(ImageInfo, CharBuf + 8, length - 8, displacement+8); in exif_process_APP1()
3772 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process APP1/EXIF done"); in exif_process_APP1()
3780 static void exif_process_APP12(image_info_type *ImageInfo, char *buffer, size_t length) in exif_process_APP12() argument
3785 exif_iif_add_tag(ImageInfo, SECTION_APP12, "Company", TAG_NONE, TAG_FMT_STRING, l1, buffer+2, l1); in exif_process_APP12()
3788 …exif_iif_add_tag(ImageInfo, SECTION_APP12, "Info", TAG_NONE, TAG_FMT_STRING, l2, buffer+2+l1+1, l2… in exif_process_APP12()
3792 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process section APP12 with l1=%d, l2=%d d… in exif_process_APP12()
3799 static bool exif_scan_JPEG_header(image_info_type *ImageInfo) in exif_scan_JPEG_header() argument
3810 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3811 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Needing section %d @ 0x%08X", ImageInfo->… in exif_scan_JPEG_header()
3821 if ((marker = php_stream_getc(ImageInfo->infile)) == EOF) { in exif_scan_JPEG_header()
3822 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3835 …exif_error_docref("exif_read_data#error_mcom" EXIFERR_CC, ImageInfo, E_NOTICE, "Image has corrupt … in exif_scan_JPEG_header()
3840 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3844 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "To many padding bytes"); in exif_scan_JPEG_header()
3849 if ((lh = php_stream_getc(ImageInfo->infile)) == (unsigned int)EOF) { in exif_scan_JPEG_header()
3850 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3853 if ((ll = php_stream_getc(ImageInfo->infile)) == (unsigned int)EOF) { in exif_scan_JPEG_header()
3854 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3862 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "%s, Section length: 0x%02X%02X", EXIF_ER… in exif_scan_JPEG_header()
3864 EXIF_ERRLOG_CORRUPT(ImageInfo) in exif_scan_JPEG_header()
3869 sn = exif_file_sections_add(ImageInfo, marker, itemlen, NULL); in exif_scan_JPEG_header()
3870 Data = ImageInfo->file.list[sn].data; in exif_scan_JPEG_header()
3876 …got = exif_read_from_stream_file_looped(ImageInfo->infile, (char*)(Data+2), itemlen-2); /* Read th… in exif_scan_JPEG_header()
3878 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Error reading from file: got=x%04X(=%d) … in exif_scan_JPEG_header()
3883 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process section(x%02X=%s) @ x%04X + x%04X… in exif_scan_JPEG_header()
3888 if (ImageInfo->read_all) { in exif_scan_JPEG_header()
3890 fpos = php_stream_tell(ImageInfo->infile); in exif_scan_JPEG_header()
3891 size = ImageInfo->FileSize - fpos; in exif_scan_JPEG_header()
3892 sn = exif_file_sections_add(ImageInfo, M_PSEUDO, size, NULL); in exif_scan_JPEG_header()
3893 Data = ImageInfo->file.list[sn].data; in exif_scan_JPEG_header()
3894 got = exif_read_from_stream_file_looped(ImageInfo->infile, (char*)Data, size); in exif_scan_JPEG_header()
3896 EXIF_ERRLOG_FILEEOF(ImageInfo) in exif_scan_JPEG_header()
3903 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "No image in jpeg!"); in exif_scan_JPEG_header()
3904 return (ImageInfo->sections_found&(~FOUND_COMPUTED)) ? true : false; in exif_scan_JPEG_header()
3907 exif_process_COM(ImageInfo, (char *)Data, itemlen); in exif_scan_JPEG_header()
3911 if (!(ImageInfo->sections_found&FOUND_IFD0)) { in exif_scan_JPEG_header()
3915 exif_process_APP1(ImageInfo, (char *)Data, itemlen, fpos); in exif_scan_JPEG_header()
3920 exif_process_APP12(ImageInfo, (char *)Data, itemlen); in exif_scan_JPEG_header()
3942 ImageInfo->Width = sof_info.width; in exif_scan_JPEG_header()
3943 ImageInfo->Height = sof_info.height; in exif_scan_JPEG_header()
3945 ImageInfo->IsColor = 1; in exif_scan_JPEG_header()
3947 ImageInfo->IsColor = 0; in exif_scan_JPEG_header()
3959 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Done"); in exif_scan_JPEG_header()
3967 static bool exif_scan_thumbnail(image_info_type *ImageInfo) in exif_scan_thumbnail() argument
3969 uchar c, *data = (uchar*)ImageInfo->Thumbnail.data; in exif_scan_thumbnail()
3974 if (!data || ImageInfo->Thumbnail.size < 4) { in exif_scan_thumbnail()
3978 if (!ImageInfo->Thumbnail.width && !ImageInfo->Thumbnail.height) { in exif_scan_thumbnail()
3979 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Thumbnail is not a JPEG image"); in exif_scan_thumbnail()
3985 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3988 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
3995 if (pos+3>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
4002 if (pos>=ImageInfo->Thumbnail.size) in exif_scan_thumbnail()
4005 if (length > ImageInfo->Thumbnail.size || pos >= ImageInfo->Thumbnail.size - length) { in exif_scan_thumbnail()
4009 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: process section(x%02X=%s) @ x%… in exif_scan_thumbnail()
4026 if (length < 8 || ImageInfo->Thumbnail.size - 8 < pos) { in exif_scan_thumbnail()
4031 ImageInfo->Thumbnail.height = sof_info.height; in exif_scan_thumbnail()
4032 ImageInfo->Thumbnail.width = sof_info.width; in exif_scan_thumbnail()
4034 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: size: %d * %d", sof_info.width… in exif_scan_thumbnail()
4040 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Could not compute size of thumbnail"); in exif_scan_thumbnail()
4050 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Could not compute size of thumbnail"); in exif_scan_thumbnail()
4057 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
4065 if (ImageInfo->FileSize >= 2 && ImageInfo->FileSize - 2 >= dir_offset) { in exif_process_IFD_in_TIFF_impl()
4066 sn = exif_file_sections_add(ImageInfo, M_PSEUDO, 2, NULL); in exif_process_IFD_in_TIFF_impl()
4068 …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()
4070 …php_stream_seek(ImageInfo->infile, dir_offset, SEEK_SET); /* we do not know the order of sections … in exif_process_IFD_in_TIFF_impl()
4071 …if (UNEXPECTED(exif_read_from_stream_file_looped(ImageInfo->infile, (char*)ImageInfo->file.list[sn… in exif_process_IFD_in_TIFF_impl()
4074 num_entries = php_ifd_get16u(ImageInfo->file.list[sn].data, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4076 if (ImageInfo->FileSize >= dir_size && ImageInfo->FileSize - dir_size >= dir_offset) { in exif_process_IFD_in_TIFF_impl()
4078 …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()
4080 if (exif_file_sections_realloc(ImageInfo, sn, dir_size)) { in exif_process_IFD_in_TIFF_impl()
4083 …if (UNEXPECTED(exif_read_from_stream_file_looped(ImageInfo->infile, (char*)(ImageInfo->file.list[s… in exif_process_IFD_in_TIFF_impl()
4086 …next_offset = php_ifd_get32u(ImageInfo->file.list[sn].data + dir_size - 4, ImageInfo->motorola_int… in exif_process_IFD_in_TIFF_impl()
4088 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF done, next offset x%04X", … in exif_process_IFD_in_TIFF_impl()
4093 dir_entry = ImageInfo->file.list[sn].data+2+i*12; in exif_process_IFD_in_TIFF_impl()
4094 entry_tag = php_ifd_get16u(dir_entry+0, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4095 entry_type = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4097 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF: tag(0x%04X,%12s): Illegal… in exif_process_IFD_in_TIFF_impl()
4105 …entry_length = php_ifd_get32u(dir_entry+4, ImageInfo->motorola_intel) * php_tiff_bytes_per_format[… in exif_process_IFD_in_TIFF_impl()
4109 entry_value = php_ifd_get16u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4112 entry_value = php_ifd_get16s(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4115 entry_value = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4118 entry_value = php_ifd_get32s(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4124 ImageInfo->Width = entry_value; in exif_process_IFD_in_TIFF_impl()
4128 ImageInfo->Height = entry_value; in exif_process_IFD_in_TIFF_impl()
4135 ImageInfo->IsColor = 0; in exif_process_IFD_in_TIFF_impl()
4142 ImageInfo->IsColor = 1; in exif_process_IFD_in_TIFF_impl()
4148 entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4155 …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()
4160 …if (ImageInfo->FileSize >= ImageInfo->file.list[sn].size && ImageInfo->FileSize - ImageInfo->file.… in exif_process_IFD_in_TIFF_impl()
4162 if (ImageInfo->FileSize < ifd_size || dir_offset > ImageInfo->FileSize - ifd_size) { in exif_process_IFD_in_TIFF_impl()
4163 …_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()
4166 if (exif_file_sections_realloc(ImageInfo, sn, ifd_size)) { in exif_process_IFD_in_TIFF_impl()
4171 …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()
4173 …exif_read_from_stream_file_looped(ImageInfo->infile, (char*)(ImageInfo->file.list[sn].data+dir_siz… in exif_process_IFD_in_TIFF_impl()
4175 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read from TIFF, done"); in exif_process_IFD_in_TIFF_impl()
4180 dir_entry = ImageInfo->file.list[sn].data+2+i*12; in exif_process_IFD_in_TIFF_impl()
4181 entry_tag = php_ifd_get16u(dir_entry+0, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4182 entry_type = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4191 ImageInfo->sections_found |= FOUND_EXIF; in exif_process_IFD_in_TIFF_impl()
4195 ImageInfo->sections_found |= FOUND_GPS; in exif_process_IFD_in_TIFF_impl()
4199 ImageInfo->sections_found |= FOUND_INTEROP; in exif_process_IFD_in_TIFF_impl()
4203 ImageInfo->sections_found |= FOUND_THUMBNAIL; in exif_process_IFD_in_TIFF_impl()
4207 entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); in exif_process_IFD_in_TIFF_impl()
4209 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s @0x%04X", exif_get_sectionna… in exif_process_IFD_in_TIFF_impl()
4211 exif_process_IFD_in_TIFF(ImageInfo, entry_offset, sub_section_index); in exif_process_IFD_in_TIFF_impl()
4213 if (ImageInfo->Thumbnail.filetype != IMAGE_FILETYPE_UNKNOWN in exif_process_IFD_in_TIFF_impl()
4214 && ImageInfo->Thumbnail.size in exif_process_IFD_in_TIFF_impl()
4215 && ImageInfo->Thumbnail.offset in exif_process_IFD_in_TIFF_impl()
4216 && ImageInfo->read_thumbnail in exif_process_IFD_in_TIFF_impl()
4219 …RR_CC, ImageInfo, E_NOTICE, "%s THUMBNAIL @0x%04X + 0x%04X", ImageInfo->Thumbnail.data ? "Ignore" … in exif_process_IFD_in_TIFF_impl()
4221 if (!ImageInfo->Thumbnail.data) { in exif_process_IFD_in_TIFF_impl()
4222 ImageInfo->Thumbnail.data = safe_emalloc(ImageInfo->Thumbnail.size, 1, 0); in exif_process_IFD_in_TIFF_impl()
4223 php_stream_seek(ImageInfo->infile, ImageInfo->Thumbnail.offset, SEEK_SET); in exif_process_IFD_in_TIFF_impl()
4224 …fgot = exif_read_from_stream_file_looped(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->… in exif_process_IFD_in_TIFF_impl()
4225 if (fgot != ImageInfo->Thumbnail.size) { in exif_process_IFD_in_TIFF_impl()
4226 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_process_IFD_in_TIFF_impl()
4227 efree(ImageInfo->Thumbnail.data); in exif_process_IFD_in_TIFF_impl()
4229 ImageInfo->Thumbnail.data = NULL; in exif_process_IFD_in_TIFF_impl()
4231 exif_thumbnail_build(ImageInfo); in exif_process_IFD_in_TIFF_impl()
4237 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s done", exif_get_sectionname(… in exif_process_IFD_in_TIFF_impl()
4242 (char *) (ImageInfo->file.list[sn].data - dir_offset), in exif_process_IFD_in_TIFF_impl()
4243 (char *) ImageInfo->file.list[sn].data, ifd_size); in exif_process_IFD_in_TIFF_impl()
4244 if (!exif_process_IFD_TAG(ImageInfo, (char*)dir_entry, &info, in exif_process_IFD_in_TIFF_impl()
4255 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read next IFD (THUMBNAIL) at x%04X", next… in exif_process_IFD_in_TIFF_impl()
4257 exif_process_IFD_in_TIFF(ImageInfo, next_offset, SECTION_THUMBNAIL); in exif_process_IFD_in_TIFF_impl()
4259 …RR_CC, ImageInfo, E_NOTICE, "%s THUMBNAIL @0x%04X + 0x%04X", ImageInfo->Thumbnail.data ? "Ignore" … in exif_process_IFD_in_TIFF_impl()
4261 …if (!ImageInfo->Thumbnail.data && ImageInfo->Thumbnail.offset && ImageInfo->Thumbnail.size && Imag… in exif_process_IFD_in_TIFF_impl()
4262 ImageInfo->Thumbnail.data = safe_emalloc(ImageInfo->Thumbnail.size, 1, 0); in exif_process_IFD_in_TIFF_impl()
4263 php_stream_seek(ImageInfo->infile, ImageInfo->Thumbnail.offset, SEEK_SET); in exif_process_IFD_in_TIFF_impl()
4264 …fgot = exif_read_from_stream_file_looped(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->… in exif_process_IFD_in_TIFF_impl()
4265 if (fgot != ImageInfo->Thumbnail.size) { in exif_process_IFD_in_TIFF_impl()
4266 EXIF_ERRLOG_THUMBEOF(ImageInfo) in exif_process_IFD_in_TIFF_impl()
4267 efree(ImageInfo->Thumbnail.data); in exif_process_IFD_in_TIFF_impl()
4268 ImageInfo->Thumbnail.data = NULL; in exif_process_IFD_in_TIFF_impl()
4270 exif_thumbnail_build(ImageInfo); in exif_process_IFD_in_TIFF_impl()
4274 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read next IFD (THUMBNAIL) done"); in exif_process_IFD_in_TIFF_impl()
4279 … 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()
4283 …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()
4287 …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()
4293 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
4296 if (ImageInfo->ifd_count++ > MAX_IFD_TAGS) { in exif_process_IFD_in_TIFF()
4299 if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) { in exif_process_IFD_in_TIFF()
4302 ImageInfo->ifd_nesting_level++; in exif_process_IFD_in_TIFF()
4303 result = exif_process_IFD_in_TIFF_impl(ImageInfo, dir_offset, section_index); in exif_process_IFD_in_TIFF()
4304 ImageInfo->ifd_nesting_level--; in exif_process_IFD_in_TIFF()
4310 static bool exif_scan_FILE_header(image_info_type *ImageInfo) in exif_scan_FILE_header() argument
4315 ImageInfo->FileType = IMAGE_FILETYPE_UNKNOWN; in exif_scan_FILE_header()
4317 if (ImageInfo->FileSize >= 2) { in exif_scan_FILE_header()
4318 php_stream_seek(ImageInfo->infile, 0, SEEK_SET); in exif_scan_FILE_header()
4319 if (exif_read_from_stream_file_looped(ImageInfo->infile, (char*)file_header, 2) != 2) { in exif_scan_FILE_header()
4323 ImageInfo->FileType = IMAGE_FILETYPE_JPEG; in exif_scan_FILE_header()
4324 if (exif_scan_JPEG_header(ImageInfo)) { in exif_scan_FILE_header()
4327 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid JPEG file"); in exif_scan_FILE_header()
4329 } else if (ImageInfo->FileSize >= 8) { in exif_scan_FILE_header()
4330 if (exif_read_from_stream_file_looped(ImageInfo->infile, (char*)(file_header+2), 6) != 6) { in exif_scan_FILE_header()
4334 ImageInfo->FileType = IMAGE_FILETYPE_TIFF_II; in exif_scan_FILE_header()
4335 ImageInfo->motorola_intel = 0; in exif_scan_FILE_header()
4337 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "File has TIFF/II format"); in exif_scan_FILE_header()
4339 ImageInfo->sections_found |= FOUND_IFD0; in exif_scan_FILE_header()
4340 if (exif_process_IFD_in_TIFF(ImageInfo, in exif_scan_FILE_header()
4341 php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel), in exif_scan_FILE_header()
4345 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF file"); in exif_scan_FILE_header()
4348 ImageInfo->FileType = IMAGE_FILETYPE_TIFF_MM; in exif_scan_FILE_header()
4349 ImageInfo->motorola_intel = 1; in exif_scan_FILE_header()
4351 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "File has TIFF/MM format"); in exif_scan_FILE_header()
4353 ImageInfo->sections_found |= FOUND_IFD0; in exif_scan_FILE_header()
4354 if (exif_process_IFD_in_TIFF(ImageInfo, in exif_scan_FILE_header()
4355 php_ifd_get32u(file_header + 4, ImageInfo->motorola_intel), in exif_scan_FILE_header()
4359 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Invalid TIFF file"); in exif_scan_FILE_header()
4362 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "File not supported"); in exif_scan_FILE_header()
4367 …exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "File too small (%d)", ImageInfo->FileSiz… in exif_scan_FILE_header()
4376 static bool exif_discard_imageinfo(image_info_type *ImageInfo) in exif_discard_imageinfo() argument
4380 EFREE_IF(ImageInfo->FileName); in exif_discard_imageinfo()
4381 EFREE_IF(ImageInfo->UserComment); in exif_discard_imageinfo()
4382 EFREE_IF(ImageInfo->UserCommentEncoding); in exif_discard_imageinfo()
4383 EFREE_IF(ImageInfo->Copyright); in exif_discard_imageinfo()
4384 EFREE_IF(ImageInfo->CopyrightPhotographer); in exif_discard_imageinfo()
4385 EFREE_IF(ImageInfo->CopyrightEditor); in exif_discard_imageinfo()
4386 EFREE_IF(ImageInfo->Thumbnail.data); in exif_discard_imageinfo()
4387 EFREE_IF(ImageInfo->encode_unicode); in exif_discard_imageinfo()
4388 EFREE_IF(ImageInfo->decode_unicode_be); in exif_discard_imageinfo()
4389 EFREE_IF(ImageInfo->decode_unicode_le); in exif_discard_imageinfo()
4390 EFREE_IF(ImageInfo->encode_jis); in exif_discard_imageinfo()
4391 EFREE_IF(ImageInfo->decode_jis_be); in exif_discard_imageinfo()
4392 EFREE_IF(ImageInfo->decode_jis_le); in exif_discard_imageinfo()
4393 EFREE_IF(ImageInfo->make); in exif_discard_imageinfo()
4394 EFREE_IF(ImageInfo->model); in exif_discard_imageinfo()
4395 for (i=0; i<ImageInfo->xp_fields.count; i++) { in exif_discard_imageinfo()
4396 EFREE_IF(ImageInfo->xp_fields.list[i].value); in exif_discard_imageinfo()
4398 EFREE_IF(ImageInfo->xp_fields.list); in exif_discard_imageinfo()
4400 exif_iif_free(ImageInfo, i); in exif_discard_imageinfo()
4402 exif_file_sections_free(ImageInfo); in exif_discard_imageinfo()
4403 memset(ImageInfo, 0, sizeof(*ImageInfo)); in exif_discard_imageinfo()
4409 static bool exif_read_from_impl(image_info_type *ImageInfo, php_stream *stream, int read_thumbnail,… in exif_read_from_impl() argument
4415 memset(ImageInfo, 0, sizeof(*ImageInfo)); in exif_read_from_impl()
4417 ImageInfo->motorola_intel = -1; /* flag as unknown */ in exif_read_from_impl()
4418 ImageInfo->infile = stream; in exif_read_from_impl()
4419 ImageInfo->FileName = NULL; in exif_read_from_impl()
4421 if (php_stream_is(ImageInfo->infile, PHP_STREAM_IS_STDIO)) { in exif_read_from_impl()
4425 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Not a file"); in exif_read_from_impl()
4426 ImageInfo->infile = NULL; in exif_read_from_impl()
4432 ImageInfo->FileName = estrndup(ZSTR_VAL(base), ZSTR_LEN(base)); in exif_read_from_impl()
4437 ImageInfo->FileDateTime = st.st_mtime; in exif_read_from_impl()
4438 ImageInfo->FileSize = st.st_size; in exif_read_from_impl()
4441 if (!ImageInfo->FileSize) { in exif_read_from_impl()
4442 php_stream_seek(ImageInfo->infile, 0, SEEK_END); in exif_read_from_impl()
4443 ImageInfo->FileSize = php_stream_tell(ImageInfo->infile); in exif_read_from_impl()
4444 php_stream_seek(ImageInfo->infile, 0, SEEK_SET); in exif_read_from_impl()
4448 ImageInfo->read_thumbnail = read_thumbnail; in exif_read_from_impl()
4449 ImageInfo->read_all = read_all; in exif_read_from_impl()
4450 ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_UNKNOWN; in exif_read_from_impl()
4452 ImageInfo->encode_unicode = estrdup(EXIF_G(encode_unicode)); in exif_read_from_impl()
4453 ImageInfo->decode_unicode_be = estrdup(EXIF_G(decode_unicode_be)); in exif_read_from_impl()
4454 ImageInfo->decode_unicode_le = estrdup(EXIF_G(decode_unicode_le)); in exif_read_from_impl()
4455 ImageInfo->encode_jis = estrdup(EXIF_G(encode_jis)); in exif_read_from_impl()
4456 ImageInfo->decode_jis_be = estrdup(EXIF_G(decode_jis_be)); in exif_read_from_impl()
4457 ImageInfo->decode_jis_le = estrdup(EXIF_G(decode_jis_le)); in exif_read_from_impl()
4460 ImageInfo->ifd_nesting_level = 0; in exif_read_from_impl()
4461 ImageInfo->ifd_count = 0; in exif_read_from_impl()
4462 ImageInfo->num_errors = 0; in exif_read_from_impl()
4465 ret = exif_scan_FILE_header(ImageInfo); in exif_read_from_impl()
4472 static bool exif_read_from_stream(image_info_type *ImageInfo, php_stream *stream, int read_thumbnai… in exif_read_from_stream() argument
4481 ret = exif_read_from_impl(ImageInfo, stream, read_thumbnail, read_all); in exif_read_from_stream()
4492 static bool exif_read_from_file(image_info_type *ImageInfo, char *FileName, int read_thumbnail, int… in exif_read_from_file() argument
4500 memset(&ImageInfo, 0, sizeof(ImageInfo)); in exif_read_from_file()
4502 exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Unable to open file"); in exif_read_from_file()
4507 ret = exif_read_from_stream(ImageInfo, stream, read_thumbnail, read_all); in exif_read_from_file()
4523 image_info_type ImageInfo; in PHP_FUNCTION() local
4535 memset(&ImageInfo, 0, sizeof(ImageInfo)); in PHP_FUNCTION()
4560 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections needed: %s", sections_str[0] ? … in PHP_FUNCTION()
4570 ret = exif_read_from_stream(&ImageInfo, p_stream, read_thumbnail, read_all); in PHP_FUNCTION()
4586 ret = exif_read_from_file(&ImageInfo, Z_STRVAL_P(stream), read_thumbnail, read_all); in PHP_FUNCTION()
4589 sections_str = exif_get_sectionlist(ImageInfo.sections_found); in PHP_FUNCTION()
4593 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections found: %s", sections_str[0] ? s… in PHP_FUNCTION()
4597 ImageInfo.sections_found |= FOUND_COMPUTED|FOUND_FILE;/* do not inform about in debug*/ in PHP_FUNCTION()
4599 if (ret == false || (sections_needed && !(sections_needed&ImageInfo.sections_found))) { in PHP_FUNCTION()
4601 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4609 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section FILE"); in PHP_FUNCTION()
4613 exif_iif_add_str(&ImageInfo, SECTION_FILE, "FileName", ImageInfo.FileName); in PHP_FUNCTION()
4614 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileDateTime", ImageInfo.FileDateTime); in PHP_FUNCTION()
4615 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileSize", ImageInfo.FileSize); in PHP_FUNCTION()
4616 exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileType", ImageInfo.FileType); in PHP_FUNCTION()
4617 …exif_iif_add_str(&ImageInfo, SECTION_FILE, "MimeType", (char*)php_image_type_to_mime_type(Ima… in PHP_FUNCTION()
4618 exif_iif_add_str(&ImageInfo, SECTION_FILE, "SectionsFound", sections_str ? sections_str : "NONE"); in PHP_FUNCTION()
4621 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section COMPUTED"); in PHP_FUNCTION()
4624 if (ImageInfo.Width>0 && ImageInfo.Height>0) { in PHP_FUNCTION()
4625 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "html" , "width=\"%d\" height=\"%d\"", ImageInfo.… in PHP_FUNCTION()
4626 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Height", ImageInfo.Height); in PHP_FUNCTION()
4627 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Width", ImageInfo.Width); in PHP_FUNCTION()
4629 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "IsColor", ImageInfo.IsColor); in PHP_FUNCTION()
4630 if (ImageInfo.motorola_intel != -1) { in PHP_FUNCTION()
4631 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "ByteOrderMotorola", ImageInfo.motorola_intel); in PHP_FUNCTION()
4633 if (ImageInfo.FocalLength) { in PHP_FUNCTION()
4634 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocalLength", "%4.1Fmm", ImageInfo.FocalLength); in PHP_FUNCTION()
4635 if(ImageInfo.CCDWidth) { in PHP_FUNCTION()
4636 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "35mmFocalLength", "%dmm", (int)(ImageInfo.FocalLen… in PHP_FUNCTION()
4639 if(ImageInfo.CCDWidth) { in PHP_FUNCTION()
4640 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "CCDWidth", "%dmm", (int)ImageInfo.CCDWidth); in PHP_FUNCTION()
4642 if(ImageInfo.ExposureTime>0) { in PHP_FUNCTION()
4643 float recip_exposure_time = 0.5f + 1.0f/ImageInfo.ExposureTime; in PHP_FUNCTION()
4644 if (ImageInfo.ExposureTime <= 0.5 && recip_exposure_time < (float)INT_MAX) { in PHP_FUNCTION()
4645 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime", "%0.3F s (1/%d)", ImageInfo.Exposur… in PHP_FUNCTION()
4647 … exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime", "%0.3F s", ImageInfo.ExposureTime); in PHP_FUNCTION()
4650 if(ImageInfo.ApertureFNumber) { in PHP_FUNCTION()
4651 …exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ApertureFNumber", "f/%.1F", ImageInfo.ApertureFNum… in PHP_FUNCTION()
4653 if(ImageInfo.Distance) { in PHP_FUNCTION()
4654 if(ImageInfo.Distance<0) { in PHP_FUNCTION()
4655 exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "FocusDistance", "Infinite"); in PHP_FUNCTION()
4657 exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocusDistance", "%0.2Fm", ImageInfo.Distance); in PHP_FUNCTION()
4660 if (ImageInfo.UserComment) { in PHP_FUNCTION()
4661 …exif_iif_add_buffer(&ImageInfo, SECTION_COMPUTED, "UserComment", ImageInfo.UserCommentLength, Imag… in PHP_FUNCTION()
4662 if (ImageInfo.UserCommentEncoding && strlen(ImageInfo.UserCommentEncoding)) { in PHP_FUNCTION()
4663 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "UserCommentEncoding", ImageInfo.UserCommentEncodin… in PHP_FUNCTION()
4667 exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright", ImageInfo.Copyright); in PHP_FUNCTION()
4668 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Photographer", ImageInfo.CopyrightPhotog… in PHP_FUNCTION()
4669 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Editor", ImageInfo.CopyrightEditor… in PHP_FUNCTION()
4671 for (i=0; i<ImageInfo.xp_fields.count; i++) { in PHP_FUNCTION()
4672 …iif_add_str(&ImageInfo, SECTION_WINXP, exif_get_tagname_debug(ImageInfo.xp_fields.list[i].tag, exi… in PHP_FUNCTION()
4674 if (ImageInfo.Thumbnail.size) { in PHP_FUNCTION()
4677 …_add_tag(&ImageInfo, SECTION_THUMBNAIL, "THUMBNAIL", TAG_NONE, TAG_FMT_UNDEFINED, ImageInfo.Thumbn… in PHP_FUNCTION()
4679 if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4681 exif_scan_thumbnail(&ImageInfo); in PHP_FUNCTION()
4683 …exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.FileType", ImageInfo.Thumbnail.filetype); in PHP_FUNCTION()
4684 …exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Thumbnail.MimeType", (char*)php_image_type_to_mime… in PHP_FUNCTION()
4686 if (ImageInfo.Thumbnail.width && ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4687 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Height", ImageInfo.Thumbnail.height); in PHP_FUNCTION()
4688 exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Width", ImageInfo.Thumbnail.width); in PHP_FUNCTION()
4693 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Adding image infos"); in PHP_FUNCTION()
4696 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FILE ); in PHP_FUNCTION()
4697 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMPUTED ); in PHP_FUNCTION()
4698 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_ANY_TAG ); in PHP_FUNCTION()
4699 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_IFD0 ); in PHP_FUNCTION()
4700 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_THUMBNAIL ); in PHP_FUNCTION()
4701 add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMMENT ); in PHP_FUNCTION()
4702 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_EXIF ); in PHP_FUNCTION()
4703 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_GPS ); in PHP_FUNCTION()
4704 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_INTEROP ); in PHP_FUNCTION()
4705 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FPIX ); in PHP_FUNCTION()
4706 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_APP12 ); in PHP_FUNCTION()
4707 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_WINXP ); in PHP_FUNCTION()
4708 add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_MAKERNOTE ); in PHP_FUNCTION()
4711 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Discarding info"); in PHP_FUNCTION()
4714 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4727 image_info_type ImageInfo; in PHP_FUNCTION() local
4740 memset(&ImageInfo, 0, sizeof(ImageInfo)); in PHP_FUNCTION()
4747 ret = exif_read_from_stream(&ImageInfo, p_stream, 1, 0); in PHP_FUNCTION()
4763 ret = exif_read_from_file(&ImageInfo, Z_STRVAL_P(stream), 1, 0); in PHP_FUNCTION()
4767 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4772ImageInfo, E_NOTICE, "Thumbnail data %d %d %d, %d x %d", ImageInfo.Thumbnail.data, ImageInfo.Thumb… in PHP_FUNCTION()
4774 if (!ImageInfo.Thumbnail.data || !ImageInfo.Thumbnail.size) { in PHP_FUNCTION()
4775 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()
4780 …exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Returning thumbnail(%d)", ImageInfo.Thum… in PHP_FUNCTION()
4783 ZVAL_STRINGL(return_value, ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size); in PHP_FUNCTION()
4785 if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) { in PHP_FUNCTION()
4786 if (!exif_scan_thumbnail(&ImageInfo)) { in PHP_FUNCTION()
4787 ImageInfo.Thumbnail.width = ImageInfo.Thumbnail.height = 0; in PHP_FUNCTION()
4790 ZEND_TRY_ASSIGN_REF_LONG(z_width, ImageInfo.Thumbnail.width); in PHP_FUNCTION()
4791 ZEND_TRY_ASSIGN_REF_LONG(z_height, ImageInfo.Thumbnail.height); in PHP_FUNCTION()
4794 ZEND_TRY_ASSIGN_REF_LONG(z_imagetype, ImageInfo.Thumbnail.filetype); in PHP_FUNCTION()
4798 exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Discarding info"); in PHP_FUNCTION()
4801 exif_discard_imageinfo(&ImageInfo); in PHP_FUNCTION()