--- parser3/src/classes/image.C 2017/05/16 14:42:07 1.162 +++ parser3/src/classes/image.C 2017/05/16 22:39:19 1.163 @@ -24,8 +24,9 @@ #include "pa_vimage.h" #include "pa_vdate.h" #include "pa_table.h" +#include "pa_charsets.h" -volatile const char * IDENT_IMAGE_C="$Id: image.C,v 1.162 2017/05/16 14:42:07 moko Exp $"; +volatile const char * IDENT_IMAGE_C="$Id: image.C,v 1.163 2017/05/16 22:39:19 moko Exp $"; // defines @@ -375,6 +376,7 @@ struct Measure_info { ushort height; Value** exif; Value** xmp; + Charset* xmp_charset; }; #endif @@ -602,11 +604,13 @@ static Value* parse_exif(Measure_reader& return vhash; } -static Value* parse_xmp(Measure_reader& reader, ushort xmp_length) { +static Value* parse_xmp(Measure_reader& reader, ushort xmp_length, Measure_info &info) { const char* buf; if(reader.read(buf, xmp_length)1) + if(HashStringValue* options=params.as_hash(1, "methods options")) { + int valid_options=0; + for(HashStringValue::Iterator i(*options); i; i.next() ){ + String::Body key=i.key(); + Value* value=i.value(); + if(key == "exif") { + if(r.process(*value).as_bool()) + info.exif=&exif; + valid_options++; + } + if(key == "xmp") { + if(r.process(*value).as_bool()) + info.xmp=&xmp; + valid_options++; + } + if(key == "xmp-charset") { + info.xmp_charset=&pa_charsets.get(value->as_string()); + valid_options++; + } + } + if(valid_options!=options->count()) + throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); + } const String* file_name; @@ -1219,7 +1248,8 @@ static void _pixel(Request& r, MethodPar MImage::MImage(): Methoded("image") { // ^image:measure[DATA] - add_native_method("measure", Method::CT_DYNAMIC, _measure, 1, 1); + // ^image:measure[DATA; $.exif(false) $.xmp(false) $.xmp-charset[UTF-8] ] + add_native_method("measure", Method::CT_DYNAMIC, _measure, 1, 2); // ^image.html[] // ^image.html[hash]