42 public static function parse( $rawData ) {
43 $parsed = iptcparse( $rawData );
45 if ( !is_array( $parsed ) ) {
51 if ( isset( $parsed[
'1#090'] ) && isset( $parsed[
'1#090'][0] ) ) {
59 unset( $parsed[
'1#090'] );
62 foreach ( $parsed as $tag => $val ) {
63 if ( isset( $val[0] ) && trim( $val[0] ) ==
'' ) {
64 wfDebugLog(
'iptc',
"IPTC tag $tag had only whitespace as its value." );
69 $data[
'ImageDescription'] = self::convIPTC( $val, $c );
72 $data[
'Copyright'] = self::convIPTC( $val, $c );
82 $bylines = self::convIPTC( $val, $c );
83 if ( isset( $parsed[
'2#085'] ) ) {
84 $titles = self::convIPTC( $parsed[
'2#085'], $c );
89 $titleCount = count( $titles );
90 for ( $i = 0; $i < $titleCount; $i++ ) {
91 if ( isset( $bylines[$i] ) ) {
94 $bylines[$i] = $titles[$i] .
', ' . $bylines[$i];
97 $data[
'Artist'] = $bylines;
100 $data[
'Keywords'] = self::convIPTC( $val, $c );
103 $data[
'CountryDest'] = self::convIPTC( $val, $c );
106 $data[
'ProvinceOrStateDest'] = self::convIPTC( $val, $c );
109 $data[
'CityDest'] = self::convIPTC( $val, $c );
112 $data[
'SublocationDest'] = self::convIPTC( $val, $c );
115 $data[
'ObjectName'] = self::convIPTC( $val, $c );
118 $data[
'SpecialInstructions'] = self::convIPTC( $val, $c );
121 $data[
'Headline'] = self::convIPTC( $val, $c );
126 $data[
'Credit'] = self::convIPTC( $val, $c );
132 $data[
'Source'] = self::convIPTC( $val, $c );
136 $data[
'EditStatus'] = self::convIPTC( $val, $c );
139 $data[
'iimCategory'] = self::convIPTC( $val, $c );
142 $data[
'iimSupplementalCategory'] = self::convIPTC( $val, $c );
145 $data[
'Urgency'] = self::convIPTC( $val, $c );
150 $data[
'FixtureIdentifier'] = self::convIPTC( $val, $c );
156 $data[
'LocationDestCode'] = self::convIPTC( $val, $c );
161 $data[
'LocationDest'] = self::convIPTC( $val, $c );
167 $software = self::convIPTC( $val, $c );
169 if ( count( $software ) !== 1 ) {
173 wfDebugLog(
'iptc',
'IPTC: Wrong count on 2:65 Software field' );
177 if ( isset( $parsed[
'2#070'] ) ) {
179 $softwareVersion = self::convIPTC( $parsed[
'2#070'], $c );
180 unset( $parsed[
'2#070'] );
181 $data[
'Software'] = [ [ $software[0], $softwareVersion[0] ] ];
183 $data[
'Software'] = $software;
189 $data[
'ObjectCycle'] = self::convIPTC( $val, $c );
197 $data[
'CountryCodeDest'] = self::convIPTC( $val, $c );
204 $data[
'OriginalTransmissionRef'] = self::convIPTC( $val, $c );
207 $data[
'Contact'] = self::convIPTC( $val, $c );
214 $data[
'Writer'] = self::convIPTC( $val, $c );
217 $data[
'LanguageCode'] = self::convIPTC( $val, $c );
227 $time = $parsed[
'2#060'] ?? [];
228 $timestamp = self::timeHelper( $val, $time, $c );
230 $data[
'DateTimeOriginal'] = $timestamp;
237 $time = $parsed[
'2#063'] ?? [];
238 $timestamp = self::timeHelper( $val, $time, $c );
240 $data[
'DateTimeDigitized'] = $timestamp;
246 $time = $parsed[
'2#035'] ?? [];
247 $timestamp = self::timeHelper( $val, $time, $c );
249 $data[
'DateTimeReleased'] = $timestamp;
255 $time = $parsed[
'2#038'] ?? [];
256 $timestamp = self::timeHelper( $val, $time, $c );
258 $data[
'DateTimeExpires'] = $timestamp;
266 if ( strlen( $val[0] ) == 2 ) {
268 $versionValue = ord( substr( $val[0], 0, 1 ) ) * 256;
269 $versionValue += ord( substr( $val[0], 1, 1 ) );
270 $data[
'iimVersion'] = $versionValue;
284 $con = self::convIPTC( $val, $c );
285 if ( strlen( $con[0] ) < 5 ) {
291 $extracted = substr( $con[0], 4 );
292 $data[
'IntellectualGenre'] = $extracted;
300 $codes = self::convIPTC( $val, $c );
301 foreach ( $codes as $ic ) {
302 $fields = explode(
':', $ic, 3 );
304 if ( count( $fields ) < 2 || $fields[0] !==
'IPTC' ) {
306 .
'Invalid 2:12 - ' . $ic );
309 $data[
'SubjectNewsCode'] = $fields[1];
328 wfDebugLog(
'iptc',
"Unsupported iptc tag: $tag. Value: " . implode(
',', $val ) );