Re: cvs: php4(PHP_4_2_0) /ext/exif exif.c /ext/exif/tests 003.phpt test3.jpg

From: Date: Mon, 08 Apr 2002 06:49:38 +0000
Subject: Re: cvs: php4(PHP_4_2_0) /ext/exif exif.c /ext/exif/tests 003.phpt test3.jpg
References: 1  Groups: php.qa 
Request: Send a blank email to php-qa+get-4938@lists.php.net to get a copy of this message
Hello, I suggest you read this again: http://news.php.net/article.php?group=php.qa&article=4412 (And if I sound pissed, I am) Derick On Mon, 8 Apr 2002, Marcus Börger wrote: > At 22:41 07.04.2002, you wrote: > >Hello, > > > >what are we doing here? > > That was the last thing not working in ext/exif as of 4.2. > What it changes is the possibility to give back unicode > strings to the user. So the user can use ext/mbstring to > handle them. It took me many deep thoughts to find a > solution, so it took a long time to have it working. As i > thought it would be better to have the extension working > i committed it. > > marcus > > > >Derick > > > >On Sun, 7 Apr 2002, Marcus Börger wrote: > > > > > helly Sun Apr 7 15:45:37 2002 EDT > > > > > > Added files: (Branch: PHP_4_2_0) > > > /php4/ext/exif/tests 003.phpt test3.jpg > > > > > > Modified files: > > > /php4/ext/exif exif.c > > > Log: > > > -found userland solution to fix UNICODE comments (see tests/003.phpt) > > > #solution from HEAD would mean new functionality > > > #so this fix makes it work without adding new functionality > > > > > > Index: php4/ext/exif/exif.c > > > diff -u php4/ext/exif/exif.c:1.52.2.5 php4/ext/exif/exif.c:1.52.2.6 > > > --- php4/ext/exif/exif.c:1.52.2.5 Thu Apr 4 15:42:47 2002 > > > +++ php4/ext/exif/exif.c Sun Apr 7 15:45:36 2002 > > > @@ -17,7 +17,7 @@ > > > > > +----------------------------------------------------------------------+ > > > */ > > > > > > -/* $Id: exif.c,v 1.52.2.5 2002/04/04 20:42:47 helly Exp $ */ > > > +/* $Id: exif.c,v 1.52.2.6 2002/04/07 19:45:36 helly Exp $ */ > > > > > > /* ToDos > > > * > > > @@ -720,6 +720,7 @@ > > > int motorola_intel; /* 1 Motorola; 0 Intel */ > > > > > > char *UserComment; > > > + int UserCommentLength; > > > char UserCommentEncoding[12]; > > > > > > char *Thumbnail; > > > @@ -767,7 +768,7 @@ > > > > > > case TAG_FMT_STRING: > > > if ( value) { > > > - length = php_strnlen(value,length); > > > + /*length = php_strnlen(value,length); > > would disable UNICODE comments*/ > > > info_value->length = length; > > > info_value->value.s = estrndup(value,length); > > > } else { > > > @@ -917,7 +918,7 @@ > > > void add_assoc_image_info( pval *value, int sub_array, image_info_type > > *image_info, int section_index) > > > { > > > char buffer[64], *val, *name, uname[64]; > > > - int idx=0, unknown=0; > > > + int idx=0, unknown=0, len; > > > image_info_value *info_value; > > > > > > if ( image_info->info_list[section_index].count) > > > @@ -959,11 +960,16 @@ > > > break; > > > > > > case TAG_FMT_STRING: > > > - if ( !(val = > > info_value->value.s)) val = ""; > > > + if ( !(val = info_value->value.s)) { > > > + val = ""; > > > + len = 0; > > > + } else { > > > + len = info_value->length; > > > + } > > > if (section_index==SECTION_COMMENT) { > > > - add_index_string(tmpi, > > idx++, val, 1); > > > + add_index_stringl(tmpi, > > idx++, val, len, 1); > > > } else { > > > - add_assoc_string(tmpi, > > name, val, 1); > > > + add_assoc_stringl(tmpi, > > name, val, len , 1); > > > } > > > break; > > > > > > @@ -1065,7 +1071,7 @@ > > > */ > > > static void exif_process_COM (image_info_type *image_info, uchar > > *value, int length) > > > { > > > - exif_add_image_info( image_info, SECTION_COMMENT, "Comment", > > TAG_COMPUTED_VALUE, TAG_FMT_STRING, length-2, value+2); > > > + exif_add_image_info( image_info, SECTION_COMMENT, "Comment", > > TAG_COMPUTED_VALUE, TAG_FMT_STRING, php_strnlen(value+2, length-2), value+2); > > > } > > > /* }}} */ > > > > > > @@ -1254,7 +1260,7 @@ > > > * Process UserComment in IFD. */ > > > static int exif_process_user_comment(char **pszInfoPtr,char > > *szEncoding,char *szValuePtr,int ByteCount) > > > { > > > - int a; > > > + int a, size; > > > > > > *szEncoding = '\0'; > > > /* Copy the comment */ > > > @@ -1264,7 +1270,8 @@ > > > strcpy( szEncoding, szValuePtr); > > > szValuePtr = szValuePtr+8; > > > ByteCount -= 8; > > > - return exif_process_string_raw(pszInfoPtr, > > szValuePtr, ByteCount); > > > + size = exif_process_string_raw(pszInfoPtr, > > szValuePtr, ByteCount); > > > + return size ? size-1 : 0; > > > } > > > if ( !memcmp(szValuePtr, "ASCII\0\0\0", 8)) { > > > strcpy( szEncoding, szValuePtr); > > > @@ -1283,7 +1290,8 @@ > > > if (a) for (a=ByteCount-1;a && szValuePtr[a]==' ';a--) > > (szValuePtr)[a] = '\0'; > > > > > > /* normal text without encoding */ > > > - return exif_process_string(pszInfoPtr, szValuePtr, ByteCount); > > > + size = exif_process_string(pszInfoPtr, szValuePtr, ByteCount); > > > + return size ? size-1 : 0; > > > } > > > /* }}} */ > > > > > > @@ -1429,7 +1437,7 @@ > > > break; > > > > > > case TAG_USERCOMMENT: > > > > > - > > > > exif_process_user_comment(&(ImageInfo->UserComment),ImageInfo->UserCommentEncoding,value_ptr,byte_count); > > > + ImageInfo->UserCommentLength = > > > > exif_process_user_comment(&(ImageInfo->UserComment),ImageInfo->UserCommentEncoding,value_ptr,byte_count); > > > break; > > > > > > /* this is only a comment if type is string! */ > > > @@ -1544,6 +1552,9 @@ > > > /* correctly would be to set components as length > > > * but we are ignoring length for those types where it is not the > > same as byte_count > > > */ > > > + if (format==TAG_FMT_STRING) { > > > + byte_count = php_strnlen(value_ptr,byte_count); > > > + } > > > exif_add_image_info( ImageInfo, section_index, > > exif_get_tagname(tag,tagname), tag, format, byte_count, value_ptr); > > > if ( outside) efree( outside); > > > } > > > @@ -2266,7 +2277,7 @@ > > > exif_add_image_info( &ImageInfo, SECTION_COMPUTED, > > "FocusDistance", TAG_NONE, TAG_FMT_STRING, strlen(tmp), tmp); > > > } > > > if (ImageInfo.UserComment) { > > > - exif_add_image_info( &ImageInfo, SECTION_COMPUTED, > > "UserComment", TAG_NONE, TAG_FMT_STRING, strlen(ImageInfo.UserComment), > > ImageInfo.UserComment); > > > + exif_add_image_info( &ImageInfo, SECTION_COMPUTED, > > "UserComment", TAG_NONE, TAG_FMT_STRING, ImageInfo.UserCommentLength, > > ImageInfo.UserComment); > > > if ( (len=strlen(ImageInfo.UserCommentEncoding))) { > > > exif_add_image_info( &ImageInfo, > > SECTION_COMPUTED, "UserCommentEncoding", TAG_NONE, TAG_FMT_STRING, len, > > ImageInfo.UserCommentEncoding); > > > } > > > > > > Index: php4/ext/exif/tests/003.phpt > > > +++ php4/ext/exif/tests/003.phpt > > > --TEST-- > > > Check for exif_read_data > > > --SKIPIF-- > > > <?php if (!extension_loaded("exif")) print "skip";?> > > > --POST-- > > > --GET-- > > > --FILE-- > > > <?php > > > /* > > > test1.jpg is a 1*1 image that does not contain any Exif/Comment > > information > > > test2.jpg is the same image but contains Exif/Comment information and a > > > copy of test1.jpg as a thumbnail. > > > test3.jpg is the same as test2.jpg but with a UNICODE USerComment: > > &Auml;&Ouml;&&Uuml;&szlig;&auml;&ouml;&uuml; > > > */ > > > $image = > > > exif_read_data('./ext/exif/tests/test3.jpg','',true,false); > > > $accept = ''; > > > foreach($image as $idx=>$section) { > > > $accept .= $section; > > > foreach($section as $name=>$value) { > > > if ( $idx!='FILE' || $name!='FileDateTime') { > > > $accept .= substr($name,0,2); > > > $accept .= $value; > > > } > > > } > > > } > > > echo $accept; > > > ?> > > > --EXPECT-- > > > ArrayFitest3.jpgFi1237Fi2SeANY_TAG, IFD0, THUMBNAIL, > > COMMENTArrayhtwidth="1" > > height="1"He1Wi1Is1UsÄÖÜßäöüUsUNICODECoPhoto (c) > > M.Boerger, Edited by M.Boerger.CoPhoto (c) M.BoergerCoEdited by > > M.Boerger.ArrayCoPhoto (c) M.BoergerUsUNICODEArrayJP134JP523Array0Comment > > #1.1Comment #2.2Comment #3end > > > > > > > > > -- > > > PHP CVS Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > >----------------------------------------------------------------------- > > Did I help you? Consider a gift: > > > > http://www.amazon.co.uk/exec/obidos/registry/SLCB276UZU8B > >----------------------------------------------------------------------- > > PHP: Scripting the Web - derick@php.net > > All your branches are belong to me! > > SRM: Script Running Machine - www.vl-srm.net > >----------------------------------------------------------------------- > ----------------------------------------------------------------------- Did I help you? Consider a gift: http://www.amazon.co.uk/exec/obidos/registry/SLCB276UZU8B ----------------------------------------------------------------------- PHP: Scripting the Web - derick@php.net All your branches are belong to me! SRM: Script Running Machine - www.vl-srm.net -----------------------------------------------------------------------

« previous php.qa (#4938) next »