CVS update: php3/functions

From: Date: Thu, 15 Oct 1998 13:28:14 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-1847@lists.php.net to get a copy of this message
Date: Thursday October 15, 1998 @ 9:28 Author: thies Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv15959 Modified Files: image.c Log Message: took out the iptc-reader again. (expect a real module soon;-) right now GetImageSize returns some extended image info in the optional 2nd parameter this is currently only implemented for JPEG images and will return the APP0 - APP15 markers (if available) in an assoc array. Index: php3/functions/image.c diff -c php3/functions/image.c:1.37 php3/functions/image.c:1.38 *** php3/functions/image.c:1.37 Fri Oct 9 13:57:26 1998 --- php3/functions/image.c Thu Oct 15 09:28:13 1998 *************** *** 26,32 **** | Authors: Rasmus Lerdorf | +----------------------------------------------------------------------+ */ ! /* $Id: image.c,v 1.37 1998/10/09 17:57:26 thies Exp $ */ /* * Based on Daniel Schmitt's imageinfo.c which carried the following * Copyright notice. --- 26,32 ---- | Authors: Rasmus Lerdorf | +----------------------------------------------------------------------+ */ ! /* $Id: image.c,v 1.38 1998/10/15 13:28:13 thies Exp $ */ /* * Based on Daniel Schmitt's imageinfo.c which carried the following * Copyright notice. *************** *** 185,202 **** return (unsigned int) c; } ! static void php3_read_iptc(FILE *fp,pval *info) ! /* read IPTC-info */ { unsigned short length; - unsigned char *buffer; - unsigned char key[ 16 ]; - pval values; - pval *element; ! unsigned char recnum, dataset; ! int inx, len, cnt; length = php3_read2(fp); length -= 2; /* length includes itself */ --- 185,205 ---- return (unsigned int) c; } ! static void php3_skip_variable(FILE *fp) ! /* skip over a variable-length block; assumes proper length marker */ { unsigned short length; ! length = php3_read2(fp); ! length -= 2; /* length includes itself */ ! fseek(fp, (long) length, SEEK_CUR); /* skip the header */ ! } ! static void php3_read_APP(FILE *fp,unsigned int marker,pval *info) ! { ! unsigned short length; ! unsigned char *buffer; ! unsigned char markername[ 16 ]; length = php3_read2(fp); length -= 2; /* length includes itself */ *************** *** 206,272 **** if (fread(buffer,length,1,fp) != 1) { return; } - - pval_destructor(info _INLINE_TLS); - if (array_init(info) == FAILURE) { - return; - } ! inx = 0; ! cnt = 0; ! while (inx < length) { ! if (buffer[ inx++ ] != 0x1c) { /* skip all junk */ ! continue; ! } ! ! if ((inx + 4) >= length) ! break; - dataset = buffer[ inx++ ]; - recnum = buffer[ inx++ ]; - len = (((unsigned short) buffer[ inx ])<<8) | (unsigned short)buffer[ inx+1 ]; - inx += 2; - - if (buffer[ inx ] == 0) - continue; - - sprintf(key,"%d#%03d",(unsigned int) dataset,(unsigned int) recnum); - - if ((inx + len) >= length) - break; - - if (_php3_hash_find(info->value.ht,key,strlen(key) + 1,(void **) &element) == FAILURE) { - if (array_init(&values) == FAILURE) { - return; - } - - _php3_hash_update(info->value.ht, key, strlen(key)+1, (void *) &values, sizeof(pval), (void **) &element); - } - - add_next_index_stringl(element,buffer+inx,len,1); - - inx += len; - } - efree(buffer); } - static void php3_skip_variable(FILE *fp) - /* skip over a variable-length block; assumes proper length marker */ - { - unsigned short length; - - length = php3_read2(fp); - length -= 2; /* length includes itself */ - fseek(fp, (long) length, SEEK_CUR); /* skip the header */ - } - static struct gfxinfo *php3_handle_jpeg(FILE *fp,pval *info) /* main loop to parse JPEG structure */ { struct gfxinfo *result = NULL; - int info_found = 0; unsigned int marker; unsigned short in_width, in_height; --- 209,226 ---- if (fread(buffer,length,1,fp) != 1) { return; } ! sprintf(markername,"APP%d",marker - M_APP0); ! add_assoc_stringl(info,markername,buffer,length,1); efree(buffer); } static struct gfxinfo *php3_handle_jpeg(FILE *fp,pval *info) /* main loop to parse JPEG structure */ { struct gfxinfo *result = NULL; unsigned int marker; unsigned short in_width, in_height; *************** *** 298,327 **** result->width = (unsigned int) in_width; result->height = (unsigned int) in_height; } break; case M_APP13: ! if (info && ! info_found) { ! php3_read_iptc(fp,info); ! info_found = 1; ! } else { ! php3_skip_variable(fp); } break; case M_SOS: case M_EOI: ! return NULL; /* we're about to hit image data, or are at EOF. Error. */ break; default: php3_skip_variable(fp); /* anything else isn't interesting */ break; } - - if ((result && (! info)) || (result && info && info_found)) - return result; } return NULL; --- 252,293 ---- result->width = (unsigned int) in_width; result->height = (unsigned int) in_height; + + if (! info) /* if we don't want an extanded info -> return */ + return result; } break; + case M_APP0: + case M_APP1: + case M_APP2: + case M_APP3: + case M_APP4: + case M_APP5: + case M_APP6: + case M_APP7: + case M_APP8: + case M_APP9: + case M_APP10: + case M_APP11: + case M_APP12: case M_APP13: ! case M_APP14: ! case M_APP15: ! if (info) { ! php3_read_APP(fp,marker,info); /* read all the app markes... */ } break; case M_SOS: case M_EOI: ! return result; /* we're about to hit image data, or are at EOF. stop processing. */ break; default: php3_skip_variable(fp); /* anything else isn't interesting */ break; } } return NULL; *************** *** 354,359 **** --- 320,331 ---- php3_error(E_WARNING, "Array to be filled with values must be passed by reference."); RETURN_FALSE; } + + pval_destructor(info _INLINE_TLS); + if (array_init(info) == FAILURE) { + return; + } + convert_to_string(arg1); break; -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1847) next »