console-seolan /add-ons/pjmt/Photoshop_File_Info.php

Language PHP Lines 2498
MD5 Hash 97e084ed80b56ce2e576afed3824bafe
Repository https://github.com/jcplat/console-seolan.git View Raw File
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
<?php

/******************************************************************************
*
* Filename:     Photoshop_File_Info.php
*
* Description:  Provides functions that mimic the way Photoshop reads and writes
*               metadata in it's 'File Info' dialog
*
* Author:       Evan Hunter
*
* Date:         11/11/2004
*
* Project:      JPEG Metadata
*
* Revision:     1.11
* Changes:      1.10 -> 1.11 : Changed displayed toolkit version numbers to reference Toolkit_Version.php
*
* URL:          http://electronics.ozhiker.com
*
* License:      This file is part of the PHP JPEG Metadata Toolkit.
*
*               The PHP JPEG Metadata Toolkit is free software; you can
*               redistribute it and/or modify it under the terms of the
*               GNU General Public License as published by the Free Software
*               Foundation; either version 2 of the License, or (at your
*               option) any later version.
*
*               The PHP JPEG Metadata Toolkit is distributed in the hope
*               that it will be useful, but WITHOUT ANY WARRANTY; without
*               even the implied warranty of MERCHANTABILITY or FITNESS
*               FOR A PARTICULAR PURPOSE.  See the GNU General Public License
*               for more details.
*
*               You should have received a copy of the GNU General Public
*               License along with the PHP JPEG Metadata Toolkit; if not,
*               write to the Free Software Foundation, Inc., 59 Temple
*               Place, Suite 330, Boston, MA  02111-1307  USA
*
*               If you require a different license for commercial or other
*               purposes, please contact the author: evan@ozhiker.com
*
******************************************************************************/

// TODO: XMP sections: XAPMM, TIFF, EXIF


include 'Toolkit_Version.php';          // Change: added as of version 1.11


/******************************************************************************
* Global Variable:      Software Name
*
* Contents:     The string that is appended to fields which store the name of
*               the software editor.
*
******************************************************************************/

$GLOBALS[ "Software Name" ] = "(PHP JPEG Metadata Toolkit v" . $GLOBALS['Toolkit_Version'] . ")";          // Change:  Changed version numbers to reference Toolkit_Version.php - as of version 1.11

/******************************************************************************
* End of Global Variable:     Software Name
******************************************************************************/






/******************************************************************************
*
* Function:     get_photoshop_file_info
*
* Description:  Retrieves Photoshop 'File Info' metadata in the same way that Photoshop
*               does. The results are returned in an array as below:
*
*               $file_info_array = array(
*                       "title"                  => "",
*                       "author"                 => "",
*                       "authorsposition"        => "",      // Note: Not used in Photoshop 7 or higher
*                       "caption"                => "",
*                       "captionwriter"          => "",
*                       "jobname"                => "",      // Note: Not used in Photoshop CS
*                       "copyrightstatus"        => "",
*                       "copyrightnotice"        => "",
*                       "ownerurl"               => "",
*                       "keywords"               => array( 0 => "", 1 => "", ... ),
*                       "category"               => "",     // Note: Max 3 characters
*                       "supplementalcategories" => array( 0 => "", 1 => "", ... ),
*                       "date"                   => "",     // Note: DATE MUST BE IN YYYY-MM-DD format
*                       "city"                   => "",
*                       "state"                  => "",
*                       "country"                => "",
*                       "credit"                 => "",
*                       "source"                 => "",
*                       "headline"               => "",
*                       "instructions"           => "",
*                       "transmissionreference"  => "",
*                       "urgency"                => "" );
*
* Parameters:   Exif_array - an array containing the EXIF information to be
*                            searched, as retrieved by get_EXIF_JPEG. (saves having to parse the EXIF again)
*               XMP_array - an array containing the XMP information to be
*                           searched, as retrieved by read_XMP_array_from_text. (saves having to parse the XMP again)
*               IRB_array - an array containing the Photoshop IRB information
*                           to be searched, as retrieved by get_Photoshop_IRB. (saves having to parse the IRB again)
*
* Returns:      outputarray - an array as above, containing the Photoshop File Info data
*
******************************************************************************/

function get_photoshop_file_info( $Exif_array, $XMP_array, $IRB_array )
{

        // Create a blank array to receive the output
        $outputarray = array(
                "title" => "",
                "author" => "",
                "authorsposition" => "",
                "caption" => "",
                "captionwriter" => "",
                "jobname" => "",
                "copyrightstatus" => "",
                "copyrightnotice" => "",
                "ownerurl" => "",
                "keywords" => array(),
                "category" => "",
                "supplementalcategories" => array(),
                "date" => "",
                "city" => "",
                "state" => "",
                "country" => "",
                "credit" => "",
                "source" => "",
                "headline" => "",
                "instructions" => "",
                "transmissionreference" => "",
                "urgency" => "" );


        /***************************************/

        // XMP Processing


        // Retrieve the dublin core section from the XMP header

        // Extract the Dublin Core section from the XMP
        $dublincore_block = find_XMP_block( $XMP_array, "dc" );

        // Check that the Dublin Core section exists
        if ( $dublincore_block != FALSE )
        {
                // Dublin Core Description Field contains caption
                // Extract Description
                $Item = find_XMP_item( $dublincore_block, "dc:description" );

                // Check if Description Tag existed
                if ( $Item != FALSE )
                {
                        // Ensure that the Description value exists and save it.
                        if  ( ( array_key_exists( 'children', $Item ) ) &&
                              ( $Item['children'][0]['tag'] == "rdf:Alt" ) &&
                              ( array_key_exists( 'value', $Item['children'][0]['children'][0] ) ) )
                        {
                                $outputarray = add_to_field( $outputarray, 'caption' , HTML_UTF8_Escape( $Item['children'][0]['children'][0]['value'] ), "\n" );
                        }
                }

                /***************************************/

                // Dublin Core Creator Field contains author
                // Extract Description
                $Item = find_XMP_item( $dublincore_block, "dc:creator" );

                // Check if Creator Tag existed
                if ( $Item != FALSE )
                {
                        // Ensure that the Creator value exists and save it.
                        if  ( ( array_key_exists( 'children', $Item ) ) &&
                              ( $Item['children'][0]['tag'] =="rdf:Seq" ) &&
                              ( array_key_exists( 'value', $Item['children'][0]['children'][0] ) ) )
                        {
                                $outputarray = add_to_field( $outputarray, 'author' , HTML_UTF8_Escape( $Item['children'][0]['children'][0]['value'] ), "\n" );
                        }
                }

                /***************************************/

                // Dublin Core Title Field contains title
                // Extract Title
                $Item = find_XMP_item( $dublincore_block, "dc:title" );

                // Check if Title Tag existed
                if ( $Item != FALSE )
                {
                        // Ensure that the Title value exists and save it.
                        if  ( ( array_key_exists( 'children', $Item ) ) &&
                              ( $Item['children'][0]['tag'] =="rdf:Alt" ) &&
                              ( array_key_exists( 'value', $Item['children'][0]['children'][0] ) ) )
                        {

                                $outputarray = add_to_field( $outputarray, 'title' , HTML_UTF8_Escape( $Item['children'][0]['children'][0]['value'] ), "," );
                        }
                }

                /***************************************/

                // Dublin Core Rights Field contains copyrightnotice
                // Extract Rights
                $Item = find_XMP_item( $dublincore_block, "dc:rights" );

                // Check if Rights Tag existed
                if ( $Item != FALSE )
                {
                        // Ensure that the Rights value exists and save it.
                        if  ( ( array_key_exists( 'children', $Item ) ) &&
                              ( $Item['children'][0]['tag'] =="rdf:Alt" ) &&
                              ( array_key_exists( 'value', $Item['children'][0]['children'][0] ) ) )
                        {

                                $outputarray = add_to_field( $outputarray, 'copyrightnotice' , HTML_UTF8_Escape( $Item['children'][0]['children'][0]['value'] ), "," );
                        }
                }

                /***************************************/

                // Dublin Core Subject Field contains keywords
                // Extract Subject
                $Item = find_XMP_item( $dublincore_block, "dc:subject" );

                // Check if Subject Tag existed
                if ( $Item != FALSE )
                {
                        // Ensure that the Subject values exist
                        if  ( ( array_key_exists( 'children', $Item ) ) && ( $Item['children'][0]['tag'] =="rdf:Bag" ) )
                        {
                                // Cycle through each Subject value and save them
                                foreach ( $Item['children'][0]['children'] as $keywords )
                                {
                                        if ( ! in_array ( HTML_UTF8_Escape( $keywords['value'] ), $outputarray['keywords']))
                                        {
                                                if  ( array_key_exists( 'value', $keywords ) )
                                                {
                                                        $outputarray['keywords'][] = HTML_UTF8_Escape( $keywords['value'] );
                                                }
                                        }
                                }
                        }
                }


        }

        /***************************************/

        // Find the Photoshop Information within the XMP block
        $photoshop_block = find_XMP_block( $XMP_array, "photoshop" );

        // Check that the Photoshop Information exists
        if ( $photoshop_block != FALSE )
        {
                // The Photoshop CaptionWriter tag contains captionwriter - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:CaptionWriter" );

                // Check that the CaptionWriter Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'captionwriter' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop Headline tag contains headline - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:Headline" );

                // Check that the Headline Field exists and save the value
                if ( ( $Item != FALSE )  && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'headline' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop Instructions tag contains instructions - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:Instructions" );

                // Check that the Instructions Field exists and save the value
                if ( ( $Item != FALSE )  && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'instructions' , HTML_UTF8_Escape( $Item['value'] ), "\n" );
                }

                /***************************************/

                // The Photoshop AuthorsPosition tag contains authorsposition - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:AuthorsPosition" );

                // Check that the AuthorsPosition Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'authorsposition' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop Credit tag contains credit - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:Credit" );

                // Check that the Credit Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'credit' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop Source tag contains source - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:Source" );

                // Check that the Credit Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'source' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop City tag contains city - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:City" );

                // Check that the City Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'city' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop State tag contains state - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:State" );

                // Check that the State Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'state' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop Country tag contains country - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:Country" );

                // Check that the Country Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'country' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop TransmissionReference tag contains transmissionreference - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:TransmissionReference" );

                // Check that the TransmissionReference Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'transmissionreference' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop Category tag contains category - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:Category" );

                // Check that the TransmissionReference Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'category' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop DateCreated tag contains date - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:DateCreated" );

                // Check that the DateCreated Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'date' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop Urgency tag contains urgency - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:Urgency" );

                // Check that the Urgency Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'urgency' , HTML_UTF8_Escape( $Item['value'] ), "," );
                }

                /***************************************/

                // The Photoshop SupplementalCategories tag contains supplementalcategories - Find it
                $Item = find_XMP_item( $photoshop_block, "photoshop:SupplementalCategories" );

                // Check that the SupplementalCategories Field exists
                if ( $Item != FALSE )
                {
                        // Check that the values exist
                        if  ( ( array_key_exists( 'children', $Item ) ) && ( $Item['children'][0]['tag'] =="rdf:Bag" ) )
                        {
                                // Cycle through the values and save them
                                foreach ( $Item['children'][0]['children'] as $sup_category )
                                {
                                        if ( ( array_key_exists( 'value', $sup_category ) ) &&
                                             ( ! in_array ( HTML_UTF8_Escape( $sup_category['value'] ), $outputarray['supplementalcategories'])) )
                                        {
                                                if ( array_key_exists( 'value', $sup_category ) )
                                                {
                                                        $outputarray['supplementalcategories'][] = HTML_UTF8_Escape( $sup_category['value'] );
                                                }
                                        }
                                }
                        }
                }

        }

        /***************************************/

        // Find the Job Reference Information within the XMP block
        $job_block = find_XMP_block( $XMP_array, "xapBJ" );

        // Check that the Job Reference Information exists
        if ( $job_block != FALSE )
        {
                // The JobRef Field contains jobname - Find it
                $Item = find_XMP_item( $job_block, "xapBJ:JobRef" );

                // Check that the JobRef Field exists
                if ( $Item != FALSE )
                {
                        // Check that the value exists and save it
                        if ( ( array_key_exists( 'children', $Item ) ) &&
                             ( $Item['children'][0]['tag'] =="rdf:Bag" ) &&
                             ( array_key_exists( 'children', $Item['children'][0] ) ) &&
                             ( $Item['children'][0]['children'][0]['tag'] =="rdf:li" ) &&
                             ( array_key_exists( 'children', $Item['children'][0]['children'][0] ) ) &&
                             ( $Item['children'][0]['children'][0]['children'][0]['tag'] =="stJob:name" ) &&
                             ( array_key_exists( 'value', $Item['children'][0]['children'][0]['children'][0] ) ) )
                        {
                                $outputarray = add_to_field( $outputarray, 'jobname' , HTML_UTF8_Escape( $Item['children'][0]['children'][0]['children'][0]['value'] ), "," );
                        }
                }
        }


        /***************************************/

        // Find the Rights Information within the XMP block
        $rights_block = find_XMP_block( $XMP_array, "xapRights" );

        // Check that the Rights Information exists
        if ( $rights_block != FALSE )
        {
                // The WebStatement Field contains ownerurl - Find it
                $Item = find_XMP_item( $rights_block, "xapRights:WebStatement" );

                // Check that the WebStatement Field exists and save the value
                if ( ( $Item != FALSE )  && ( array_key_exists( 'value', $Item ) ) )
                {
                        $outputarray = add_to_field( $outputarray, 'ownerurl' , HTML_UTF8_Escape( $Item['value'] ), "\n" );
                }

                /***************************************/

                // The Marked Field contains copyrightstatus - Find it
                $Item = find_XMP_item( $rights_block, "xapRights:Marked" );

                // Check that the Marked Field exists and save the value
                if ( ( $Item != FALSE ) && ( array_key_exists( 'value', $Item ) ) )
                {
                        if ( $Item['value'] == "True" )
                        {
                                $outputarray = add_to_field( $outputarray, 'copyrightstatus' , "Copyrighted Work", "," );
                        }
                        else
                        {
                                $outputarray = add_to_field( $outputarray, 'copyrightstatus' , "Public Domain", "," );
                        }
                }

        }





        /***************************************/

        // Photoshop IRB Processing

        // Check that the Photoshop IRB exists
        if ( $IRB_array != FALSE )
        {
                // Create a translation table to convert carriage returns to linefeeds
                $irbtrans = array("\x0d" => "\x0a");

                // The Photoshop IRB Copyright flag (0x040A) contains copyrightstatus - find it
                $IRB_copyright_flag = find_Photoshop_IRB_Resource( $IRB_array, 0x040A );

                // Check if the Copyright flag Field exists, and save the value
                if( $IRB_copyright_flag != FALSE )
                {
                        // Check the value of the copyright flag
                        if ( hexdec( bin2hex( $IRB_copyright_flag['ResData'] ) ) == 1 )
                        {
                                // Save the value
                                $outputarray = add_to_field( $outputarray, 'copyrightstatus' , "Copyrighted Work", "," );
                        }
                        else
                        {
                                // Do nothing - copyrightstatus will be set to unmarked if still blank at end
                        }
                }

                /***************************************/

                // The Photoshop IRB URL (0x040B) contains ownerurl - find it
                $IRB_url = find_Photoshop_IRB_Resource( $IRB_array, 0x040B );

                // Check if the URL Field exists and save the value
                if( $IRB_url != FALSE )
                {
                        $outputarray = add_to_field( $outputarray, 'ownerurl' , strtr( $IRB_url['ResData'], $irbtrans ), "\n" );
                }

                /***************************************/

                // Extract any IPTC block from the Photoshop IRB information
                $IPTC_array = get_Photoshop_IPTC( $IRB_array );

                // Check if the IPTC block exits
                if ( ( $IPTC_array != FALSE ) && ( count( $IPTC_array ) != 0 ) )
                {
                        // The IPTC Caption/Abstract Field contains caption - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:120" );

                        // Check if the Caption/Abstract Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'caption' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Caption Writer/Editor Field contains captionwriter - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:122" );

                        // Check if the Caption Writer/Editor Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'captionwriter' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Headline Field contains headline - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:105" );

                        // Check if the Headline Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'headline' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Special Instructions Field contains instructions - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:40" );

                        // Check if the Special Instructions Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'instructions' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC By-Line Field contains author - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:80" );

                        // Check if the By-Line Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'author' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC By-Line Title Field contains authorsposition - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:85" );

                        // Check if the By-Line Title Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'authorsposition' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Credit Field contains credit - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:110" );

                        // Check if the Credit Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'credit' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Source Field contains source - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:115" );

                        // Check if the Source Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'source' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Object Name Field contains title - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:05" );

                        // Check if the Object Name Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'title' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Date Created Field contains date - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:55" );

                        // Check if the Date Created Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $date_array = unpack( "a4Year/a2Month/A2Day", $record['RecData'] );
                                $tmpdate = $date_array['Year'] . "-" . $date_array['Month'] . "-" . $date_array['Day'];
                                $outputarray = add_to_field( $outputarray, 'date' , strtr( $tmpdate, $irbtrans ), "," );

                        }

                        /***************************************/

                        // The IPTC City Field contains city - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:90" );

                        // Check if the City Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'city' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Province/State Field contains state - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:95" );

                        // Check if the Province/State Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'state' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Country/Primary Location Name Field contains country - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:101" );

                        // Check if the Country/Primary Location Name Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'country' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Original Transmission Reference Field contains transmissionreference - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:103" );

                        // Check if the Original Transmission Reference Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'transmissionreference' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                        /***************************************/

                        // The IPTC Category Field contains category - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:15" );

                        // Check if the Category Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'category' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }


                        /***************************************/

                        // Cycle through the IPTC records looking for Supplemental Category records
                        foreach ($IPTC_array as $record)
                        {
                                // Check if a Supplemental Category record has been found
                                if ( $record['IPTC_Type'] == "2:20" )
                                {
                                        // A Supplemental Category record has been found, save it's value if the value doesn't already exist
                                        if ( ! in_array ( $record['RecData'], $outputarray['supplementalcategories']))
                                        {
                                                $outputarray['supplementalcategories'][] = strtr( $record['RecData'], array("\x0a" => "", "\x0d" => "&#xA;") ) ;
                                        }
                                }
                        }


                        /***************************************/

                        // The IPTC Urgency Field contains urgency - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:10" );

                        // Check if the Urgency Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'urgency' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }



                        /***************************************/

                        // Cycle through the IPTC records looking for Keywords records
                        foreach ($IPTC_array as $record)
                        {
                                // Check if a Keywords record has been found
                                if ( $record['IPTC_Type'] == "2:25" )
                                {
                                        // A Keywords record has been found, save it's value if the value doesn't already exist
                                        if ( ! in_array ( $record['RecData'], $outputarray['keywords']))
                                        {
                                                $outputarray['keywords'][] = strtr( $record['RecData'], array("\x0a" => "", "\x0d" => "&#xA;") ) ;
                                        }
                                }
                        }


                        /***************************************/

                        // The IPTC Copyright Notice Field contains copyrightnotice - find it
                        $record = find_IPTC_Resource( $IPTC_array, "2:116" );

                        // Check if the Copyright Field exists and save the value
                        if ( $record != FALSE  )
                        {
                                $outputarray = add_to_field( $outputarray, 'copyrightnotice' , strtr( $record['RecData'], $irbtrans ), "\n" );
                        }

                }
        }




        /***************************************/

        // EXIF Processing


        // Retreive Information from the EXIF data if it exists

        if ( ( $Exif_array != FALSE ) || ( count( $Exif_array ) == 0 ) )
        {
                // Check the Image Description Tag - it can contain the caption
                if ( array_key_exists( 270, $Exif_array[0] ) )
                {
                        $outputarray = add_to_field( $outputarray, 'caption' , $Exif_array[0][270]['Data'][0], "\n" );
                }

                /***************************************/

                // Check the Copyright Information Tag - it contains the copyrightnotice
                if ( array_key_exists( 33432, $Exif_array[0] ) )
                {
                        $outputarray = add_to_field( $outputarray, 'copyrightnotice' , HTML_UTF8_UnEscape( $Exif_array[0][33432]['Data'][0] ), "\n" );
                }

                /***************************************/

                // Check the Artist Name Tag - it contains the author
                if ( array_key_exists( 315, $Exif_array[0] ) )
                {
                        $outputarray = add_to_field( $outputarray, 'author' , HTML_UTF8_UnEscape( $Exif_array[0][315]['Data'][0] ), "\n" );
                }

        }


        /***************************/

        // FINISHED RETRIEVING INFORMATION

        // Perform final processing


        // Check if any urgency information was found
        if ( $outputarray["urgency"] == "" )
        {
                // No urgency information was found - set it to default (None)
                $outputarray["urgency"] = "none";
        }

        // Check if any copyrightstatus information was found
        if ( $outputarray["copyrightstatus"] == "" )
        {
                // No copyrightstatus information was found - set it to default (Unmarked)
                $outputarray["copyrightstatus"] = "unmarked";
        }

        // Return the resulting Photoshop File Info Array
        return $outputarray;

}

/******************************************************************************
* End of Function:     get_photoshop_file_info
******************************************************************************/






/******************************************************************************
*
* Function:     put_photoshop_file_info
*
* Description:  Stores Photoshop 'File Info' metadata in the same way that Photoshop
*               does. The 'File Info' metadata must be in an array similar to that
*               returned by get_photoshop_file_info, as follows:
*
*               $file_info_array = array(
*                       "title"                  => "",
*                       "author"                 => "",
*                       "authorsposition"        => "",      // Note: Not used in Photoshop 7 or higher
*                       "caption"                => "",
*                       "captionwriter"          => "",
*                       "jobname"                => "",      // Note: Not used in Photoshop CS
*                       "copyrightstatus"        => "",
*                       "copyrightnotice"        => "",
*                       "ownerurl"               => "",
*                       "keywords"               => array( 0 => "", 1 => "", ... ),
*                       "category"               => "",     // Note: Max 3 characters
*                        "supplementalcategories" => array( 0 => "", 1 => "", ... ),
*                       "date"                   => "",     // Note: DATE MUST BE IN YYYY-MM-DD format
*                       "city"                   => "",
*                       "state"                  => "",
*                       "country"                => "",
*                       "credit"                 => "",
*                       "source"                 => "",
*                       "headline"               => "",
*                       "instructions"           => "",
*                       "transmissionreference"  => "",
*                       "urgency"                => "" );
*
* Parameters:   jpeg_header_data - a JPEG header data array in the same format
*                                  as from get_jpeg_header_data. This contains the
*                                  header information which is to be updated.
*               new_ps_file_info_array - An array as above, which contains the
*                                        'File Info' metadata information to be
*                                        written.
*               Old_Exif_array - an array containing the EXIF information to be
*                                updated, as retrieved by get_EXIF_JPEG. (saves having to parse the EXIF again)
*               Old_XMP_array - an array containing the XMP information to be
*                               updated, as retrieved by read_XMP_array_from_text. (saves having to parse the XMP again)
*               Old_IRB_array - an array containing the Photoshop IRB information
*                                to be updated, as retrieved by get_Photoshop_IRB. (saves having to parse the IRB again)
*
* Returns:      jpeg_header_data - a JPEG header data array in the same format
*                                  as from get_jpeg_header_data, containing the
*                                  Photshop 'File Info' metadata. This can then
*                                  be written to a file using put_jpeg_header_data.
*
******************************************************************************/

function put_photoshop_file_info( $jpeg_header_data, $new_ps_file_info_array, $Old_Exif_array, $Old_XMP_array, $Old_IRB_array )
{
        /*******************************************/
        // PREPROCESSING

        // Check that the date is in the correct format (YYYY-MM-DD)

        // Explode the date into pieces using the - symbol
        $date_pieces = explode( "-", $new_ps_file_info_array[ 'date' ] );

        // If there are not 3 pieces to the date, it is invalid
        if ( count( $date_pieces ) != 3 )
        {
                // INVALID DATE
                echo "Invalid Date - must be YYYY-MM-DD format<br>";
                return FALSE;
        }

        // Cycle through each piece of the date
        foreach( $date_pieces as $piece )
        {
                // If the piece is not numeric, then the date is invalid.
                if ( ! is_numeric( $piece ) )
                {
                        // INVALID DATE
                        echo "Invalid Date - must be YYYY-MM-DD format<br>";
                        return FALSE;
                }
        }

        // Make a unix timestamp at midnight on the date specified
        $date_stamp = mktime( 0,0,0, $date_pieces[1], $date_pieces[2], $date_pieces[0] );




        // Create a translation table to remove carriage return characters
        $trans = array( "\x0d" => "" );

        // Cycle through each of the File Info elements
        foreach( $new_ps_file_info_array as $valkey => $val )
        {
                // If the element is 'Keywords' or 'Supplemental Categories', then
                // it is an array, and needs to be treated as one
                if ( ( $valkey != 'supplementalcategories' ) && ( $valkey != 'keywords' ) )
                {
                        // Not Keywords or Supplemental Categories
                        // Convert escaped HTML characters to UTF8 and remove carriage returns
                        $new_ps_file_info_array[ $valkey ] = strtr( HTML_UTF8_UnEscape( $val ), $trans );
                }
                else
                {
                        // Either Keywords or Supplemental Categories
                        // Cycle through the array,
                        foreach( $val as $subvalkey => $subval )
                        {
                                // Convert escaped HTML characters to UTF8 and remove carriage returns
                                $new_ps_file_info_array[ $valkey ][ $subvalkey ] = strtr( HTML_UTF8_UnEscape( $subval ), $trans );
                        }
                }
        }





        /*******************************************/

        // EXIF Processing


        // Check if the EXIF array exists
        if( $Old_Exif_array == FALSE )
        {
                // EXIF Array doesn't exist - create a new one
                $new_Exif_array = array (       'Byte_Align' => "MM",
                                                'Makernote_Tag' => false,
                                                'Tags Name' => "TIFF",
                                                 0 => array( "Tags Name" => "TIFF" ) );
        }
        else
        {
                // EXIF Array Does Exist - use it
                $new_Exif_array = $Old_Exif_array;
        }



        // Update the EXIF Image Description Tag with the new value
        $new_Exif_array[0][270] = array (       "Tag Name"   => $GLOBALS[ "IFD_Tag_Definitions" ]['TIFF'][ 270 ]['Name'],
                                                "Tag Number" => 270,
                                                "Data Type"  => 2,
                                                "Type"       => $GLOBALS[ "IFD_Tag_Definitions" ]['TIFF'][ 270 ]['Type'],
                                                "Data"       => array( HTML_UTF8_Escape( $new_ps_file_info_array[ 'caption' ]) ));

        // Update the EXIF Artist Name Tag with the new value
        $new_Exif_array[0][315] = array (       "Tag Name"   => $GLOBALS[ "IFD_Tag_Definitions" ]['TIFF'][ 315 ]['Name'],
                                                "Tag Number" => 315,
                                                "Data Type"  => 2,
                                                "Type"       => $GLOBALS[ "IFD_Tag_Definitions" ]['TIFF'][ 315 ]['Type'],
                                                "Data"       => array( HTML_UTF8_Escape( $new_ps_file_info_array[ 'author' ] ) ) );

        // Update the EXIF Copyright Information Tag with the new value
        $new_Exif_array[0][33432] = array (     "Tag Name"   => $GLOBALS[ "IFD_Tag_Definitions" ]['TIFF'][ 33432 ]['Name'],
                                                "Tag Number" => 33432,
                                                "Data Type"  => 2,
                                                "Type"       => $GLOBALS[ "IFD_Tag_Definitions" ]['TIFF'][ 33432 ]['Type'],
                                                "Data"       => array( HTML_UTF8_Escape( $new_ps_file_info_array[ 'copyrightnotice' ]) ) );


        // Photoshop checks if the "Date and Time of Original" and "Date and Time when Digitized" tags exist
        // If they don't exist, it means that the EXIF date may be wiped out if it is changed, so Photoshop
        // copies the EXIF date to these two tags

        if ( ( array_key_exists( 306, $new_Exif_array[0] ) )&&
             ( array_key_exists( 34665, $new_Exif_array[0] ) ) &&
             ( array_key_exists( 0, $new_Exif_array[0][34665] ) ) )
        {
                // Replace "Date and Time of Original" if it doesn't exist
                if ( ! array_key_exists( 36867, $new_Exif_array[0][34665][0] ) )
                {
                        $new_Exif_array[0][34665][0][36867] = array (       "Tag Name"   => $GLOBALS[ "IFD_Tag_Definitions" ]['EXIF'][ 36867 ]['Name'],
                                                "Tag Number" => 36867,
                                                "Data Type"  => 2,
                                                "Type"       => $GLOBALS[ "IFD_Tag_Definitions" ]['EXIF'][ 36867 ]['Type'],
                                                "Data"       => $new_Exif_array[0][306]['Data'] );
                }

                // Replace "Date and Time when Digitized" if it doesn't exist
                if ( ! array_key_exists( 36868, $new_Exif_array[0][34665][0] ) )
                {
                        $new_Exif_array[0][34665][0][36868] = array (       "Tag Name"   => $GLOBALS[ "IFD_Tag_Definitions" ]['EXIF'][ 36868 ]['Name'],
                                                "Tag Number" => 36868,
                                                "Data Type"  => 2,
                                                "Type"       => $GLOBALS[ "IFD_Tag_Definitions" ]['EXIF'][ 36868 ]['Type'],
                                                "Data"       => $new_Exif_array[0][306]['Data'] );
                }
        }


        // Photoshop changes the EXIF date Tag (306) to the current date, not the date that was entered in File Info
        $exif_date = date ( "Y:m:d H:i:s" );

        // Update the EXIF Date and Time Tag with the new value
        $new_Exif_array[0][306] = array (       "Tag Name"   => $GLOBALS[ "IFD_Tag_Definitions" ]['TIFF'][ 306 ]['Name'],
                                                "Tag Number" => 306,
                                                "Data Type"  => 2,
                                                "Type"       => $GLOBALS[ "IFD_Tag_Definitions" ]['TIFF'][ 306 ]['Type'],
                                                "Data"       => array( $exif_date ) );



        // Photoshop replaces the EXIF Software or Firmware Tag with "Adobe Photoshop ..."
        // This toolkit instead preserves existing value and appends the toolkit name to the end of it

        // Check if the EXIF Software or Firmware Tag exists
        if ( array_key_exists( 305, $new_Exif_array[0] ) )
        {
                // An existing EXIF Software or Firmware Tag was found
                // Check if the existing Software or Firmware Tag already contains the Toolkit's name
                if ( stristr ( $new_Exif_array[0][305]['Data'][0], $GLOBALS[ "Software Name" ]) == FALSE )
                {
                        // Toolkit Name string not found in the existing Software/Firmware string - append it.
                        $firmware_str = $new_Exif_array[0][305]['Data'][0] . " " . $GLOBALS[ "Software Name" ];
                }
                else
                {
                        // Toolkit name already exists in Software/Firmware string - don't put another copy in the string
                        $firmware_str = $new_Exif_array[0][305]['Data'][0];
                }
        }
        else
        {
                // No Software/Firmware string exists - create one
                $firmware_str = $GLOBALS[ "Software Name" ];
        }

        // Update the EXIF Software/Firmware Tag with the new value
        $new_Exif_array[0][305] = array(        "Tag Name"   => $GLOBALS[ "IFD_Tag_Definitions" ]['TIFF'][ 305 ]['Name'],
                                                "Tag Number" => 305,
                                                "Data Type"  => 2,
                                                "Type"       => $GLOBALS[ "IFD_Tag_Definitions" ]['TIFF'][ 305 ]['Type'],
                                                "Data"       => array( HTML_UTF8_Escape( $firmware_str ) ) );





        /*******************************************/

        // Photoshop IRB Processing


        // Check if there is an existing Photoshop IRB array
        if ($Old_IRB_array == FALSE )
        {
                // No existing IRB array - create one
                $new_IRB_array = array();
        }
        else
        {
                // There is an existing Photoshop IRB array - use it
                $new_IRB_array = $Old_IRB_array;
        }

        // Remove any existing Copyright Flag, URL, or IPTC resources - these will be re-written
        foreach( $new_IRB_array as  $resno => $res )
        {
                if ( ( $res[ 'ResID' ] == 0x040A ) ||
                     ( $res[ 'ResID' ] == 0x040B ) ||
                     ( $res[ 'ResID' ] == 0x0404 ) )
                {
                        array_splice( $new_IRB_array, $resno, 1 );
                }
        }


        // Add a new Copyright Flag resource
        if ( $new_ps_file_info_array[ 'copyrightstatus' ] == "Copyrighted Work" )
        {
                $PS_copyright_flag = "\x01"; // Copyrighted
        }
        else
        {
                $PS_copyright_flag = "\x00"; // Public domain or Unmarked
        }
        $new_IRB_array[] = array(       'ResID' => 0x040A,
                                        'ResName' => $GLOBALS[ "Photoshop_ID_Names" ][0x040A],
                                        'ResDesc' => $GLOBALS[ "Photoshop_ID_Descriptions" ][0x040A],
                                        'ResEmbeddedName' => "",
                                        'ResData' => $PS_copyright_flag );



        // Add a new URL resource
        $new_IRB_array[] = array(       'ResID' => 0x040B,
                                        'ResName' => $GLOBALS[ "Photoshop_ID_Names" ][0x040B],
                                        'ResDesc' => $GLOBALS[ "Photoshop_ID_Descriptions" ][0x040B],
                                        'ResEmbeddedName' => "",
                                        'ResData' => $new_ps_file_info_array[ 'ownerurl' ] );



        // Create IPTC resource

        // IPTC requires date to be in the following format YYYYMMDD
        $iptc_date = date( "Ymd", $date_stamp );

        // Create the new IPTC array
        $new_IPTC_array = array (
                                  0 =>
                                  array (
                                    'IPTC_Type' => '2:00',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:00'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:00'],
                                    'RecData' => "\x00\x02",
                                  ),
                                  1 =>
                                  array (
                                    'IPTC_Type' => '2:120',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:120'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:120'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'caption' ] ), 0 , 2000 ),
                                  ),
                                  2 =>
                                  array (
                                    'IPTC_Type' => '2:122',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:122'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:122'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'captionwriter' ] ), 0 , 32 ),
                                  ),
                                  3 =>
                                  array (
                                    'IPTC_Type' => '2:105',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:105'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:105'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'headline' ] ), 0 , 256 ),
                                  ),
                                  4 =>
                                  array (
                                    'IPTC_Type' => '2:40',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:40'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:40'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'instructions' ] ), 0, 256 ),
                                  ),
                                  5 =>
                                  array (
                                    'IPTC_Type' => '2:80',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:80'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:80'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'author' ] ), 0, 32 ),
                                  ),
                                  6 =>
                                  array (
                                    'IPTC_Type' => '2:85',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:85'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:85'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'authorsposition' ] ), 0, 32 ),
                                  ),
                                  7 =>
                                  array (
                                    'IPTC_Type' => '2:110',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:110'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:110'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'credit' ] ), 0, 32 ),
                                  ),
                                  8 =>
                                  array (
                                    'IPTC_Type' => '2:115',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:115'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:115'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'source' ] ), 0, 32 ),
                                  ),
                                  9 =>
                                  array (
                                    'IPTC_Type' => '2:05',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:05'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:05'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'title' ] ), 0, 64 ),
                                  ),
                                  10 =>
                                  array (
                                    'IPTC_Type' => '2:55',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:55'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:55'],
                                    'RecData' => "$iptc_date",
                                  ),
                                  11 =>
                                  array (
                                    'IPTC_Type' => '2:90',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:90'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:90'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'city' ] ), 0, 32 ),
                                  ),
                                  12 =>
                                  array (
                                    'IPTC_Type' => '2:95',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:95'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:95'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'state' ] ), 0, 32 ),
                                  ),
                                  13 =>
                                  array (
                                    'IPTC_Type' => '2:101',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:101'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:101'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'country' ] ), 0, 64 ),
                                  ),
                                  14 =>
                                  array (
                                    'IPTC_Type' => '2:103',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:103'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:103'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'transmissionreference' ] ), 0, 32 ),
                                  ),
                                  15 =>
                                  array (
                                    'IPTC_Type' => '2:15',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:15'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:15'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'category' ] ), 0, 3 ),
                                  ),
                                  21 =>
                                  array (
                                    'IPTC_Type' => '2:116',
                                    'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:10'],
                                    'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:10'],
                                    'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'copyrightnotice' ] ), 0, 128 ),
                                  ),
                                );

        // Check the value of urgency is valid
        if ( ( $new_ps_file_info_array[ 'urgency' ] > 0 ) && ( $new_ps_file_info_array[ 'urgency' ] < 9 ) )
        {
                // Add the Urgency item to the IPTC array
                $new_IPTC_array[] = array (
                                                'IPTC_Type' => '2:10',
                                                'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:10'],
                                                'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:10'],
                                                'RecData' => substr( HTML_UTF8_Escape( $new_ps_file_info_array[ 'urgency' ] ), 0, 1 ),
                                          );
        }

        // Cycle through the Supplemental Categories,
        foreach( $new_ps_file_info_array[ 'supplementalcategories' ] as $supcat )
        {
                // Add this Supplemental Category to the IPTC array
                $new_IPTC_array[] = array (
                                            'IPTC_Type' => '2:20',
                                            'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:20'],
                                            'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:20'],
                                            'RecData' => HTML_UTF8_Escape( $supcat ),
                                          );
        }


        // Cycle through the Keywords,
        foreach( $new_ps_file_info_array[ 'keywords' ] as $keyword )
        {
                // Add this Keyword to the IPTC array
                $new_IPTC_array[] = array (
                                            'IPTC_Type' => '2:25',
                                            'RecName' => $GLOBALS[ "IPTC_Entry_Names" ]['2:25'],
                                            'RecDesc' => $GLOBALS[ "IPTC_Entry_Descriptions" ]['2:25'],
                                            'RecData' => $keyword,
                                          );
        }


        /***********************************/

        // XMP Processing

        // Check if XMP existed previously
        if ($Old_XMP_array == FALSE )
        {
                // XMP didn't exist - create a new one based on a blank structure
                $new_XMP_array = XMP_Check( $GLOBALS[ 'Blank XMP Structure' ], array( ) );
        }
        else
        {
                // XMP does exist
                // Some old XMP processors used x:xapmeta, check for this
                if ( $Old_XMP_array[0]['tag'] == 'x:xapmeta' )
                {
                        // x:xapmeta found - change it to x:xmpmeta
                        $Old_XMP_array[0]['tag'] = 'x:xmpmeta';
                }

                // Ensure that the existing XMP has all required fields, and add any that are missing
                $new_XMP_array = XMP_Check( $GLOBALS[ 'Blank XMP Structure' ], $Old_XMP_array );
        }


        // Process the XMP Photoshop block

        // Find the Photoshop Information within the XMP block
        $photoshop_block = & find_XMP_block( $new_XMP_array, "photoshop" );

        // The Photoshop CaptionWriter tag contains captionwriter - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:CaptionWriter" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'captionwriter' ];

        // The Photoshop Category tag contains category - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:Category" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'category' ];

        // The Photoshop DateCreated tag contains date - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:DateCreated" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'date' ];

        // The Photoshop City tag contains city - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:City" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'city' ];

        // The Photoshop State tag contains state - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:State" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'state' ];

        // The Photoshop Country tag contains country - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:Country" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'country' ];

        // The Photoshop AuthorsPosition tag contains authorsposition - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:AuthorsPosition" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'authorsposition' ];

        // The Photoshop Credit tag contains credit - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:Credit" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'credit' ];

        // The Photoshop Source tag contains source - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:Source" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'source' ];

        // The Photoshop Headline tag contains headline - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:Headline" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'headline' ];

        // The Photoshop Instructions tag contains instructions - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:Instructions" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'instructions' ];

        // The Photoshop TransmissionReference tag contains transmissionreference - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:TransmissionReference" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'transmissionreference' ];

        // The Photoshop Urgency tag contains urgency - Find it and Update the value
        $Item = & find_XMP_item( $photoshop_block, "photoshop:Urgency" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'urgency' ];

        // The Photoshop SupplementalCategories tag contains supplementalcategories - Find it
        $Item = & find_XMP_item( $photoshop_block, "photoshop:SupplementalCategories" );

        // Create an array to receive the XML list items for the Supplemental Categories
        $new_supcat_array = array( );

        // Cycle through the Supplemental Categories
        foreach ( $new_ps_file_info_array[ 'supplementalcategories' ] as $sup_category )
        {
                // Add a new list item for this Supplemental Category
                $new_supcat_array[] = array( 'tag' => 'rdf:li', 'value' => $sup_category );
        }

        // Add the array of Supplemental Category List Items to the Photoshop SupplementalCategories tag
        $Item[ 'children' ][ 0 ][ 'children' ] = $new_supcat_array;



        // Process the XMP XAP block

        // Find the XAP Information within the XMP block
        $XAP_block = & find_XMP_block( $new_XMP_array, "xap" );

        // The XAP CreateDate tag contains date XMP was first created - Find it and Update the value
        $Item = & find_XMP_item( $XAP_block, "xap:CreateDate" );

        // Check if the CreateDate is blank
        if ( $Item[ 'value' ] == "" )
        {
                // CreateDate is blank - we must have just added it - set it to the current date
                $Item[ 'value' ] = date( "Y-m-d\TH:i:s" );
                $Item[ 'value' ] .= get_Local_Timezone_Offset( );
        }


        // The XAP ModifyDate tag contains last resource change date  - Find it and Update the value to the current date
        $Item = & find_XMP_item( $XAP_block, "xap:ModifyDate" );
        $Item[ 'value' ] = date( "Y-m-d\TH:i:s" );
        $Item[ 'value' ] .= get_Local_Timezone_Offset( );

        // The XAP ModifyDate tag contains last XMP change date  - Find it and Update the value to the current date
        $Item = & find_XMP_item( $XAP_block, "xap:MetadataDate" );
        $Item[ 'value' ] = date( "Y-m-d\TH:i:s" );
        $Item[ 'value' ] .= get_Local_Timezone_Offset( );



        // The XAP CreatorTool tag contains name of the software editor  - Find it
        $Item = & find_XMP_item( $XAP_block, "xap:CreatorTool" );

        // Photoshop replaces the CreatorTool with "Adobe Photoshop ..."
        // This toolkit instead preserves existing value and appends the toolkit name to the end of it

        // Check if a CreatorTool already exists
        if ( $Item[ 'value' ] != "" )
        {
                // An existing CreatorTool was found
                // Check if the existing CreatorTool already contains the Toolkit's name
                if ( stristr ( $Item[ 'value' ], $GLOBALS[ "Software Name" ]) == FALSE )
                {
                        // Toolkit Name string not found in the existing CreatorTool string - append it.
                        $Item[ 'value' ] = $Item[ 'value' ] . " " . $GLOBALS[ "Software Name" ];
                }
                else
                {
                        // Toolkit name already exists in CreatorTool string - leave as is
                }
        }
        else
        {
                // No CreatorTool string exists - create one
                $Item[ 'value' ] = $GLOBALS[ "Software Name" ];
        }




        // Process the XMP Basic Job Information block

        // Find the XAP Basic Job Information within the XMP block
        $XAPBJ_block = & find_XMP_block( $new_XMP_array, "xapBJ" );

        // The XAP Basic Job JobRef tag contains urgency - Find it and Update the value
        $Item = & find_XMP_item( $XAPBJ_block, "xapBJ:JobRef" );
        $Item[ 'children' ][ 0 ][ 'children' ] =
                array( array (  'tag'        => 'rdf:li',
                                'attributes' => array ( 'rdf:parseType' => 'Resource' ),
                                'children'   => array ( 0 => array (    'tag'   => 'stJob:name',
                                                                        'value' => $new_ps_file_info_array[ 'jobname' ] ),
                                                      ),
                             ),
                     );




        // Process the XMP XAP Rights Information block

        // Find the XAP Rights Information within the XMP block
        $XAPRights_block = & find_XMP_block( $new_XMP_array, "xapRights" );



        // The XAP Rights Marked tag should only be present if copyrightstatus is 'Copyrighted Work' or 'Public Domain'
        // If copyrightstatus 'Unmarked' or anything else, the XAP Rights Marked tag should be missing


        // Remove any existing XAP Rights Marked tags - they will be replaced
        foreach( $XAPRights_block as  $tagno => $tag )
        {
                if ( $tag[ 'tag' ] == "xapRights:Marked" )
                {
                        array_splice( $XAPRights_block, $tagno, 1 );
                }
        }

        // Check the value of the copyrightstatus flag
        if ( $new_ps_file_info_array[ 'copyrightstatus' ] == "Copyrighted Work" )
        {
                // Copyrighted - add the tag
                $XAPRights_block[] = array ( 'tag' => 'xapRights:Marked', 'value' => 'True' );
        }
        else if ( $new_ps_file_info_array[ 'copyrightstatus' ] == "Public Domain" )
        {
                // Public domain - add the tag
                $XAPRights_block[] = array ( 'tag' => 'xapRights:Marked', 'value' => 'False' );
        }
        else
        {
                // Unmarked or Other - Do nothing - don't add a Marked tag
        }


        // The XAP Rights WebStatement tag contains ownerurl - Find it and Update the value
        $Item = & find_XMP_item( $XAPRights_block, "xapRights:WebStatement" );
        $Item[ 'value' ] = $new_ps_file_info_array[ 'ownerurl' ];




        // Process the XMP Dublin Core block

        // Find the Dublin Core Information within the XMP block
        $DC_block = & find_XMP_block( $new_XMP_array, "dc" );


        // The Dublin Core description tag contains caption - Find it and Update the value
        $Item = & find_XMP_item( $DC_block, "dc:description" );
        $Item[ 'children' ][ 0 ][ 'children' ] = array( array(  'tag'   => "rdf:li",
                                                                'value' => $new_ps_file_info_array[ 'caption' ],
                                                                'attributes' => array( 'xml:lang' => "x-default" ) ) );


        // The Dublin Core title tag contains title - Find it and Update the value
        $Item = & find_XMP_item( $DC_block, "dc:title" );
        $Item[ 'children' ][ 0 ][ 'children' ] = array( array(  'tag'   => "rdf:li",
                                                                'value' => $new_ps_file_info_array[ 'title' ],
                                                                'attributes' => array( 'xml:lang' => "x-default" ) ) );


        // The Dublin Core rights tag contains copyrightnotice - Find it and Update the value
        $Item = & find_XMP_item( $DC_block, "dc:rights" );
        $Item[ 'children' ][ 0 ][ 'children' ] = array( array(  'tag'   => "rdf:li",
                                                                'value' => $new_ps_file_info_array[ 'copyrightnotice' ],
                                                                'attributes' => array( 'xml:lang' => "x-default" ) ) );

        // The Dublin Core creator tag contains author - Find it and Update the value
        $Item = & find_XMP_item( $DC_block, "dc:creator" );
        $Item[ 'children' ][ 0 ][ 'children' ] = array( array(  'tag'   => "rdf:li",
                                                                'value' => $new_ps_file_info_array[ 'author' ]) );

        // The Dublin Core subject tag contains keywords - Find it
        $Item = & find_XMP_item( $DC_block, "dc:subject" );

        // Create an array to receive the Keywords List Items
        $new_keywords_array = array( );

        // Cycle through each keyword
        foreach( $new_ps_file_info_array[ 'keywords' ] as $keyword )
        {
                // Add a List item for this keyword
                $new_keywords_array[] = array(  'tag'   => "rdf:li", 'value' => $keyword );
        }
        // Add the Keywords List Items array to the Dublin Core subject tag
        $Item[ 'children' ][ 0 ][ 'children' ] = $new_keywords_array;



        /***************************************/

        // FINISHED UPDATING VALUES

        // Insert the new IPTC array into the Photoshop IRB array
        $new_IRB_array = put_Photoshop_IPTC( $new_IRB_array, $new_IPTC_array );

        // Write the EXIF array to the JPEG header
        $jpeg_header_data = put_EXIF_JPEG( $new_Exif_array, $jpeg_header_data );

        // Convert the XMP array to XMP text
        $xmp_text = write_XMP_array_to_text( $new_XMP_array );

        // Write the XMP text to the JPEG Header
        $jpeg_header_data = put_XMP_text( $jpeg_header_data, $xmp_text );

        // Write the Photoshop IRB array to the JPEG header
        $jpeg_header_data = put_Photoshop_IRB( $jpeg_header_data, $new_IRB_array );

        return $jpeg_header_data;

}

/******************************************************************************
* End of Function:     put_photoshop_file_info
******************************************************************************/



































/******************************************************************************
*
*         INTERNAL FUNCTIONS
*
******************************************************************************/


































/******************************************************************************
*
* Function:     get_Local_Timezone_Offset
*
* Description:  Returns a string indicating the time difference between the local
*               timezone and GMT in hours and minutes, e.g.  +10:00 or -06:30
*
* Parameters:   None
*
* Returns:      $tz_str - a string containing the timezone offset
*
******************************************************************************/

function get_Local_Timezone_Offset( )
{
        // Retrieve the Timezone offset in seconds
        $tz_seconds = date( "Z" );

        // Check if the offset is less than zero
        if ( $tz_seconds < 0 )
        {
                // Offset is less than zero - add a Minus sign to the output
                $tz_str = "-";
        }
        else
        {
                // Offset is greater than or equal to zero - add a Plus sign to the output
                $tz_str = "+";
        }

        // Add the absolute offset to the output, formatted as HH:MM
        $tz_str .= gmdate( "H:i", abs($tz_seconds) );

        // Return the result
        return $tz_str;
}

/******************************************************************************
* End of Function:     get_Local_Timezone_Offset
******************************************************************************/



/******************************************************************************
*
* Function:     XMP_Check
*
* Description:  Checks a given XMP array against a reference array, and adds any
*               missing blocks and tags
*
*               NOTE: This is a recursive function
*
* Parameters:   reference_array - The standard XMP array which contains all required tags
*               check_array - The XMP array to check
*
* Returns:      output - a string containing the timezone offset
*
******************************************************************************/

function XMP_Check( $reference_array, $check_array)
{
        // Cycle through each of the elements of the reference XMP array
        foreach( $reference_array as $valkey => $val )
        {

                // Search for the current reference tag within the XMP array to be checked
                $tagpos = find_XMP_Tag( $check_array,  $val );

                // Check if the tag was found
                if ( $tagpos === FALSE )
                {
                        // Tag not found - Add tag to array being checked
                        $tagpos = count( $check_array );
                        $check_array[ $tagpos ] = $val;
                }

                // Check if the reference tag has children
                if ( array_key_exists( 'children', $val ) )
                {
                        // Reference tag has children - these need to be checked too

                        // Determine if the array being checked has children for this tag
                        if ( ! array_key_exists( 'children', $check_array[ $tagpos ] ) )
                        {
                                // Array being checked has no children - add a blank children array
                                $check_array[ $tagpos ][ 'children' ] = array( );
                        }

                        // Recurse, checking the children tags against the reference children
                        $check_array[ $tagpos ][ 'children' ] = XMP_Check( $val[ 'children' ] , $check_array[ $tagpos ][ 'children' ] );
                }
                else
                {
                        // No children - don't need to check anything else
                }
        }

        // Return the checked XMP array
        return $check_array;
}


/******************************************************************************
* End of Function:     XMP_Check
******************************************************************************/




/******************************************************************************
*
* Function:     find_XMP_Tag
*
* Description:  Searches one level of an XMP array for a specific tag, and
*               returns the tag position. Does not descend the XMP tree.
*
* Parameters:   XMP_array - The XMP array which should be searched
*               tag - The XMP tag to search for (in same format as would be found in XMP array)
*
* Returns:      output - a string containing the timezone offset
*
******************************************************************************/

function find_XMP_Tag( $XMP_array, $tag )
{
        $namespacestr = "";

        // Some tags have a namespace attribute which defines them (i.e. rdf:Description tags)

        // Check if the tag being searched for has attributs
        if ( array_key_exists( 'attributes', $tag ) )
        {
                // Tag has attributes - cycle through them
                foreach( $tag['attributes'] as $key => $val )
                {
                        // Check if the current attribute is the namespace attribute - i.e. starts with xmlns:
                        if ( strcasecmp( substr($key,0,6), "xmlns:" ) == 0 )
                        {
                                // Found a namespace attribute - save it for later.
                                $namespacestr = $key;
                        }
                }
        }



        // Cycle through the elements of the XMP array to be searched.
        foreach( $XMP_array as $valkey => $val )
        {

                // Check if the current element is a rdf:Description tag
                if ( strcasecmp ( $tag[ 'tag' ], 'rdf:Description' ) == 0 )
                {
                        // Current element is a rdf:Description tag
                        // Check if the namespace attribute is the same as in the tag that is being searched for
                        if ( array_key_exists( $namespacestr, $val['attributes'] ) )
                        {
                                // Namespace is the same - this is the correct tag - return it's position
                                return $valkey;
                        }
                }
                // Otherwise check if the current element has the same name as the tag in question
                else if ( strcasecmp ( $val[ 'tag' ], $tag[ 'tag' ] ) == 0 )
                {
                        // Tags have same name - this is the correct tag - return it's position
                        return $valkey;
                }
        }

        // Cycled through all tags without finding the correct one - return error value
        return FALSE;
}

/******************************************************************************
* End of Function:     find_XMP_Tag
******************************************************************************/




/******************************************************************************
*
* Function:     create_GUID
*
* Description:  Creates a Globally Unique IDentifier, in the format that is used
*               by XMP (and Windows). This value is not guaranteed to be 100% unique,
*               but it is ridiculously unlikely that two identical values will be produced
*
* Parameters:   none
*
* Returns:      output - a string containing the timezone offset
*
******************************************************************************/

function create_GUID( )
{
        // Create a md5 sum of a random number - this is a 32 character hex string
        $raw_GUID = md5( uniqid( getmypid() . rand( ) . (double)microtime()*1000000, TRUE ) );

        // Format the string into 8-4-4-4-12 (numbers are the number of characters in each block)
        return  substr($raw_GUID,0,8) . "-" . substr($raw_GUID,8,4) . "-" . substr($raw_GUID,12,4) . "-" . substr($raw_GUID,16,4) . "-" . substr($raw_GUID,20,12);
}

/******************************************************************************
* End of Function:     create_GUID
******************************************************************************/





/******************************************************************************
*
* Function:     add_to_field
*
* Description:  Adds a value to a particular field in a Photoshop File Info array,
*               first checking whether the value is already there. If the value is
*               already in the array, it is not changed, otherwise the value is appended
*               to whatever is already in that field of the array
*
* Parameters:   field_array - The Photoshop File Info array to receive the new value
*               field - The File Info field which the value is for
*               value - The value to be written into the File Info
*               separator - The string to place between values when having to append the value
*
* Returns:      output - the Photoshop File Info array with the value added
*
******************************************************************************/

function add_to_field( $field_array, $field, $value, $separator )
{
        // Check if the value is blank
        if ( $value == "" )
        {
                // Value is blank - return File Info array unchanged
                return $field_array;
        }

        // Check if the value can be found anywhere within the existing value for this field
        if ( stristr ( $field_array[ $field ], $value ) == FALSE)
        {
                // Value could not be found
                // Check if the existing value for the field is blank
                if ( $field_array[$field] != "" )
                {
                        // Existing value for field is not blank - append a separator
                        $field_array[$field] .= $separator;
                }
                // Append the value to the field
                $field_array[$field] .= $value;
        }

        // Return the File Info Array
        return $field_array;
}

/******************************************************************************
* End of Function:     add_to_field
******************************************************************************/



/******************************************************************************
*
* Function:     find_IPTC_Resource
*
* Description:  Searches an IPTC array for a particular record, and returns it if found
*
* Parameters:   IPTC_array - The IPTC array to search
*               record_type - The IPTC record number to search for (e.g.  2:151 )
*
* Returns:      output - the contents of the record if found
*               FALSE - otherwise
*
******************************************************************************/

function find_IPTC_Resource( $IPTC_array, $record_type )
{
        // Cycle through the ITPC records
        foreach ($IPTC_array as $record)
        {
                // Check the IPTC type against the required type
                if ( $record['IPTC_Type'] == $record_type )
                {
                        // IPTC type matches - return this record
                        return $record;
                }
        }

        // No matching record found - return error code
        return FALSE;
}

/******************************************************************************
* End of Function:     find_IPTC_Resource
******************************************************************************/




/******************************************************************************
*
* Function:     find_Photoshop_IRB_Resource
*
* Description:  Searches a Photoshop IRB array for a particular resource, and returns it if found
*
* Parameters:   IRB_array - The IRB array to search
*               resource_ID - The IRB resource number to search for (e.g.  0x03F9 )
*
* Returns:      output - the contents of the resource if found
*               FALSE - otherwise
*
******************************************************************************/

function find_Photoshop_IRB_Resource( $IRB_array, $resource_ID )
{
        // Cycle through the IRB resources
        foreach( $IRB_array as $IRB_Resource )
        {
                // Check the IRB resource ID against the required ID
                if ( $resource_ID == $IRB_Resource['ResID'] )
                {
                        // Resource ID matches - return this resource
                        return $IRB_Resource;
                }
        }

        // No matching resource found - return error code
        return FALSE;
}

/******************************************************************************
* End of Function:     find_Photoshop_IRB_Resource
******************************************************************************/








/******************************************************************************
*
* Function:     find_XMP_item
*
* Description:  Searches a one level of a XMP array for a particular item by name, and returns it if found.
*               Does not descend through the XMP array
*
* Parameters:   Item_Array - The XMP array to search
*               item_name - The name of the tag to serch for (e.g.  photoshop:CaptionWriter )
*
* Returns:      output - the contents of the tag if found
*               FALSE - otherwise
*
******************************************************************************/

function & find_XMP_item( & $Item_Array, $item_name )
{
        // Cycle through the top level of the XMP array
        foreach( $Item_Array as $Item_Key => $Item )
        {
                // Check this tag name against the required tag name
                if( $Item['tag'] == $item_name )
                {
                        // The tag names match - return the item
                        return $Item_Array[ $Item_Key ];
                }
        }

        // No matching tag found - return error code
        return FALSE;
}

/******************************************************************************
* End of Function:     find_XMP_item
******************************************************************************/





/******************************************************************************
*
* Function:     find_XMP_block
*
* Description:  Searches a for a particular rdf:Description block within a XMP array, and returns its children if found.
*
* Parameters:   XMP_array - The XMP array to search as returned by read_XMP_array_from_text
*               block_name - The namespace of the XMP block to be found (e.g.  photoshop or xapRights )
*
* Returns:      output - the children of the tag if found
*               FALSE - otherwise
*
******************************************************************************/

function & find_XMP_block( & $XMP_array, $block_name )
{
        // Check that the rdf:RDF section can be found (which contains the rdf:Description tags
        if ( ( $XMP_array !== FALSE ) &&
             ( ( $XMP_array[0]['tag'] ==  "x:xapmeta" ) ||
               ( $XMP_array[0]['tag'] ==  "x:xmpmeta" ) ) &&
             ( $XMP_array[0]['children'][0]['tag'] ==  "rdf:RDF" ) )
        {
                // Found rdf:RDF
                // Make it's children easily accessible
                $RDF_Contents = $XMP_array[0]['children'][0]['children'];

                // Cycle through the children (rdf:Description tags)
                foreach ($RDF_Contents as $RDF_Key => $RDF_Item)
                {
                        // Check if this is a rdf:description tag that has children
                        if ( ( $RDF_Item['tag'] == "rdf:Description" ) &&
                             ( array_key_exists( 'children', $RDF_Item ) ) )
                        {
                                // RDF Description tag has children,
                                // Cycle through it's attributes
                                foreach( $RDF_Item['attributes'] as $key => $val )
                                {
                                        // Check if this attribute matches the namespace block name required
                                        if ( $key == "xmlns:$block_name" )
                                        {
                                                // Namespace matches required block name - return it's children
                                                return  $XMP_array[0]['children'][0]['children'][ $RDF_Key ]['children'];
                                        }
                                }
                        }
                }
        }

        // No matching rdf:Description block found
        return FALSE;
}

/******************************************************************************
* End of Function:     find_XMP_block
******************************************************************************/









/******************************************************************************
* Global Variable:      Blank XMP Structure
*
* Contents:     A template XMP array which can be used to create a new XMP segment
*
******************************************************************************/

// Create a GUID to be used in this template array
$new_GUID = create_GUID( );

$GLOBALS[ 'Blank XMP Structure' ] =
array (
  0 =>
  array (
    'tag' => 'x:xmpmeta',
    'attributes' =>
    array (
      'xmlns:x' => 'adobe:ns:meta/',
      'x:xmptk' => 'XMP toolkit 3.0-28, framework 1.6',
    ),
    'children' =>
    array (
      0 =>
      array (
        'tag' => 'rdf:RDF',
        'attributes' =>
        array (
          'xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
          'xmlns:iX' => 'http://ns.adobe.com/iX/1.0/',
        ),
        'children' =>
        array (
          1 =>
          array (
            'tag' => 'rdf:Description',
            'attributes' =>
            array (
              'rdf:about' => "uuid:$new_GUID",
              'xmlns:pdf' => 'http://ns.adobe.com/pdf/1.3/',
            ),
          ),
          2 =>
          array (
            'tag' => 'rdf:Description',
            'attributes' =>
            array (
              'rdf:about' => "uuid:$new_GUID",
              'xmlns:photoshop' => 'http://ns.adobe.com/photoshop/1.0/',
            ),
            'children' =>
            array (
              0 =>
              array (
                'tag' => 'photoshop:CaptionWriter',
                'value' => '',
              ),
              1 =>
              array (
                'tag' => 'photoshop:Category',
                'value' => '',
              ),
              2 =>
              array (
                'tag' => 'photoshop:DateCreated',
                'value' => '',
              ),
              3 =>
              array (
                'tag' => 'photoshop:City',
                'value' => '',
              ),
              4 =>
              array (
                'tag' => 'photoshop:State',
                'value' => '',
              ),
              5 =>
              array (
                'tag' => 'photoshop:Country',
                'value' => '',
              ),
              6 =>
              array (
                'tag' => 'photoshop:Credit',
                'value' => '',
              ),
              7 =>
              array (
                'tag' => 'photoshop:Source',
                'value' => '',
              ),
              8 =>
              array (
                'tag' => 'photoshop:Headline',
                'value' => '',
              ),
              9 =>
              array (
                'tag' => 'photoshop:Instructions',
                'value' => '',
              ),
              10 =>
              array (
                'tag' => 'photoshop:TransmissionReference',
                'value' => '',
              ),
              11 =>
              array (
                'tag' => 'photoshop:Urgency',
                'value' => '',
              ),
              12 =>
              array (
                'tag' => 'photoshop:SupplementalCategories',
                'children' =>
                array (
                  0 =>
                  array (
                    'tag' => 'rdf:Bag',
                  ),
                ),
              ),
              13 =>
              array (
                'tag' => 'photoshop:AuthorsPosition',
                'value' => '',
              ),
            ),
          ),
          4 =>
          array (
            'tag' => 'rdf:Description',
            'attributes' =>
            array (
              'rdf:about' => "uuid:$new_GUID",
              'xmlns:xap' => 'http://ns.adobe.com/xap/1.0/',
            ),
            'children' =>
            array (
              0 =>
              array (
                'tag' => 'xap:CreateDate',
                'value' => '',
              ),
              1 =>
              array (
                'tag' => 'xap:ModifyDate',
                'value' => '',
              ),
              2 =>
              array (
                'tag' => 'xap:MetadataDate',
                'value' => '',
              ),
              3 =>
              array (
                'tag' => 'xap:CreatorTool',
                'value' => '',
              ),
            ),
          ),
          5 =>
          array (
            'tag' => 'rdf:Description',
            'attributes' =>
            array (
              'about' => "uuid:$new_GUID",
              'xmlns:stJob' => 'http://ns.adobe.com/xap/1.0/sType/Job#',
              'xmlns:xapBJ' => 'http://ns.adobe.com/xap/1.0/bj/',
            ),
            'children' =>
            array (
              0 =>
              array (
                'tag' => 'xapBJ:JobRef',
                'children' =>
                array (
                  0 =>
                  array (
                    'tag' => 'rdf:Bag',
                    'children' =>
                    array (
                    ),
                  ),
                ),
              ),
            ),
          ),
          6 =>
          array (
            'tag' => 'rdf:Description',
            'attributes' =>
            array (
              'rdf:about' => "uuid:$new_GUID",
              'xmlns:xapRights' => 'http://ns.adobe.com/xap/1.0/rights/',
            ),
            'children' =>
            array (
              1 =>
              array (
                'tag' => 'xapRights:WebStatement',
                'value' => '',
              ),
            ),
          ),
          7 =>
          array (
            'tag' => 'rdf:Description',
            'attributes' =>
            array (
              'rdf:about' => "uuid:$new_GUID",
              'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
            ),
            'children' =>
            array (
              0 =>
              array (
                'tag' => 'dc:format',
                'value' => 'image/jpeg',
              ),
              1 =>
              array (
                'tag' => 'dc:title',
                'children' =>
                array (
                  0 =>
                  array (
                    'tag' => 'rdf:Alt',
                  ),
                ),
              ),
              2 =>
              array (
                'tag' => 'dc:description',
                'children' =>
                array (
                  0 =>
                  array (
                    'tag' => 'rdf:Alt',
                  ),
                ),
              ),
              3 =>
              array (
                'tag' => 'dc:rights',
                'children' =>
                array (
                  0 =>
                  array (
                    'tag' => 'rdf:Alt',
                  ),
                ),
              ),
              4 =>
              array (
                'tag' => 'dc:creator',
                'children' =>
                array (
                  0 =>
                  array (
                    'tag' => 'rdf:Seq',
                  ),
                ),
              ),
              5 =>
              array (
                'tag' => 'dc:subject',
                'children' =>
                array (
                  0 =>
                  array (
                    'tag' => 'rdf:Bag',
                  ),
                ),
              ),
            ),
          ),

/*          0 =>
          array (
            'tag' => 'rdf:Description',
            'attributes' =>
            array (
              'rdf:about' => "uuid:$new_GUID",
              'xmlns:exif' => 'http://ns.adobe.com/exif/1.0/',
            ),
            'children' =>
            array (

//EXIF DATA GOES HERE - Not Implemented yet
            ),
          ),
*/
/*
          2 =>
          array (
            'tag' => 'rdf:Description',
            'attributes' =>
            array (
              'rdf:about' => "uuid:$new_GUID",
              'xmlns:tiff' => 'http://ns.adobe.com/tiff/1.0/',
            ),
            'children' =>
            array (
// TIFF DATA GOES HERE - Not Implemented yet
              0 =>
              array (
                'tag' => 'tiff:Make',
                'value' => 'NIKON CORPORATION',
              ),
            ),
          ),
*/
/*
          3 =>
          array (
            'tag' => 'rdf:Description',
            'attributes' =>
            array (
              'rdf:about' => "uuid:$new_GUID",
              'xmlns:stRef' => 'http://ns.adobe.com/xap/1.0/sType/ResourceRef#',
              'xmlns:xapMM' => 'http://ns.adobe.com/xap/1.0/mm/',
            ),
            'children' =>
            array (
// XAPMM DATA GOES HERE - Not Implemented yet
              0 =>
              array (
                'tag' => 'xapMM:DocumentID',
                'value' => 'adobe:docid:photoshop:dceba4c2-e699-11d8-94b2-b6ec48319f2d',
              ),
              1 =>
              array (
                'tag' => 'xapMM:DerivedFrom',
                'attributes' =>
                array (
                  'rdf:parseType' => 'Resource',
                ),
                'children' =>
                array (
                  0 =>
                  array (
                    'tag' => 'stRef:documentID',
                    'value' => 'adobe:docid:photoshop:5144475b-e698-11d8-94b2-b6ec48319f2d',
                  ),
                  1 =>
                  array (
                    'tag' => 'stRef:instanceID',
                    'value' => "uuid:$new_GUID",
                  ),
                ),
              ),
            ),
          ),
*/

        ),
      ),
    ),
  ),
);



/******************************************************************************
* End of Global Variable:     Blank XMP Structure
******************************************************************************/





?>
Back to Top