/usr/share/perl5/Image/ExifTool/CanonVRD.pm is in libimage-exiftool-perl 10.40-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #------------------------------------------------------------------------------
# File: CanonVRD.pm
#
# Description: Read/write Canon VRD and DR4 information
#
# Revisions: 2006/10/30 - P. Harvey Created
# 2007/10/23 - PH Added new VRD 3.0 tags
# 2008/08/29 - PH Added new VRD 3.4 tags
# 2008/12/02 - PH Added new VRD 3.5 tags
# 2010/06/18 - PH Support variable-length CustomPictureStyle data
# 2010/09/14 - PH Added r/w support for XMP in VRD
# 2015/05/16 - PH Added DR4 support (DPP 4.1.50.0)
#
# References: 1) Bogdan private communication (Canon DPP v3.4.1.1)
# 2) Gert Kello private communiation (DPP 3.8)
#------------------------------------------------------------------------------
package Image::ExifTool::CanonVRD;
use strict;
use vars qw($VERSION);
use Image::ExifTool qw(:DataAccess :Utils);
use Image::ExifTool::Canon;
$VERSION = '1.28';
sub ProcessCanonVRD($$;$);
sub WriteCanonVRD($$;$);
sub ProcessEditData($$$);
sub ProcessIHL($$$);
sub ProcessIHLExif($$$);
sub ProcessDR4($$;$);
sub SortDR4($$);
# map for adding directories to VRD
my %vrdMap = (
XMP => 'CanonVRD',
CanonVRD => 'VRD',
);
my %noYes = (
PrintConvColumns => 2,
PrintConv => { 0 => 'No', 1 => 'Yes' },
);
# DR4 format codes
my %vrdFormat = (
1 => 'int32u',
2 => 'string',
8 => 'int32u',
9 => 'int32s',
13 => 'double',
33 => 'int32u', # (array)
38 => 'double', # (array)
# 254 => 'undef', ?
255 => 'undef',
);
# empty VRD header/footer for creating VRD from scratch
my $blankHeader = "CANON OPTIONAL DATA\0\0\x01\0\0\0\0\0\0";
my $blankFooter = "CANON OPTIONAL DATA\0" . ("\0" x 42) . "\xff\xd9";
# main tag table blocks in CanonVRD trailer (ref PH)
%Image::ExifTool::CanonVRD::Main = (
WRITE_PROC => \&WriteCanonVRD,
PROCESS_PROC => \&ProcessCanonVRD,
NOTES => q{
Canon Digital Photo Professional writes VRD (Recipe Data) information as a
trailer record to JPEG, TIFF, CRW and CR2 images, or as stand-alone VRD or
DR4 files. The tags listed below represent information found in these
records. The complete VRD/DR4 data record may be accessed as a block using
the Extra 'CanonVRD' or 'CanonDR4' tag, but this tag is not extracted or
copied unless specified explicitly.
},
0xffff00f4 => {
Name => 'EditData',
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::Edit' },
},
0xffff00f5 => {
Name => 'IHLData',
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::IHL' },
},
0xffff00f6 => {
Name => 'XMP',
Flags => [ 'Binary', 'Protected' ],
Writable => 'undef', # allow writing/deleting as a block
SubDirectory => {
DirName => 'XMP',
TagTable => 'Image::ExifTool::XMP::Main',
},
},
0xffff00f7 => {
Name => 'Edit4Data',
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::Edit4' },
},
);
# the VRD edit information is divided into sections
%Image::ExifTool::CanonVRD::Edit = (
WRITE_PROC => \&ProcessEditData,
PROCESS_PROC => \&ProcessEditData,
VARS => { ID_LABEL => 'Index' }, # change TagID label in documentation
NOTES => 'Canon VRD edit information.',
0 => {
Name => 'VRD1',
Size => 0x272, # size of version 1.0 edit information in bytes
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::Ver1' },
},
1 => {
Name => 'VRDStampTool',
Size => 0, # size is variable, and obtained from int32u at directory start
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::StampTool' },
},
2 => {
Name => 'VRD2',
Size => undef, # size is the remaining edit data
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::Ver2' },
},
);
# Canon DPP version 4 edit information
%Image::ExifTool::CanonVRD::Edit4 = (
WRITE_PROC => \&ProcessEditData,
PROCESS_PROC => \&ProcessEditData,
VARS => { ID_LABEL => 'Index' }, # change TagID label in documentation
NOTES => 'Canon DPP version 4 edit information.',
0 => {
Name => 'DR4',
Size => undef, # size is the remaining edit data
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::DR4' },
},
);
# "IHL Created Optional Item Data" tags (not yet writable)
%Image::ExifTool::CanonVRD::IHL = (
PROCESS_PROC => \&ProcessIHL,
TAG_PREFIX => 'VRD_IHL',
GROUPS => { 2 => 'Image' },
1 => [
# this contains edited TIFF-format data, with an original IFD at 0x0008
# and an edited IFD with offset given in the TIFF header.
{
Name => 'IHL_EXIF',
Condition => '$self->Options("ExtractEmbedded")',
SubDirectory => {
TagTable => 'Image::ExifTool::Exif::Main',
ProcessProc => \&ProcessIHLExif,
},
},{
Name => 'IHL_EXIF',
Notes => q{
extracted as a block if the Unknown option is used, or processed as the
first sub-document with the ExtractEmbedded option
},
Binary => 1,
Unknown => 1,
},
],
# 2 - written by DPP 3.0.2.6, and it looks something like edit data,
# but I haven't decoded it yet - PH
3 => {
# (same size as the PreviewImage with DPP 3.0.2.6)
Name => 'ThumbnailImage',
Groups => { 2 => 'Preview' },
Binary => 1,
},
4 => {
Name => 'PreviewImage',
Groups => { 2 => 'Preview' },
Binary => 1,
},
5 => {
Name => 'RawCodecVersion',
ValueConv => '$val =~ s/\0.*//s; $val', # truncate string at null
},
6 => {
Name => 'CRCDevelParams',
Binary => 1,
Unknown => 1,
},
);
# VRD version 1 tags (ref PH)
%Image::ExifTool::CanonVRD::Ver1 = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
WRITABLE => 1,
FIRST_ENTRY => 0,
GROUPS => { 2 => 'Image' },
DATAMEMBER => [ 0x002 ], # necessary for writing
#
# RAW image adjustment
#
0x002 => {
Name => 'VRDVersion',
Format => 'int16u',
Writable => 0,
DataMember => 'VRDVersion',
RawConv => '$$self{VRDVersion} = $val',
PrintConv => '$val =~ s/^(\d)(\d*)(\d)$/$1.$2.$3/; $val',
},
0x006 => {
Name => 'WBAdjRGGBLevels',
Format => 'int16u[4]',
},
0x018 => {
Name => 'WhiteBalanceAdj',
Format => 'int16u',
PrintConvColumns => 2,
PrintConv => {
0 => 'Auto',
1 => 'Daylight',
2 => 'Cloudy',
3 => 'Tungsten',
4 => 'Fluorescent',
5 => 'Flash',
8 => 'Shade',
9 => 'Kelvin',
30 => 'Manual (Click)',
31 => 'Shot Settings',
},
},
0x01a => {
Name => 'WBAdjColorTemp',
Format => 'int16u',
},
# 0x01c similar to 0x006
0x024 => {
Name => 'WBFineTuneActive',
Format => 'int16u',
%noYes,
},
0x028 => {
Name => 'WBFineTuneSaturation',
Format => 'int16u',
},
0x02c => {
Name => 'WBFineTuneTone',
Format => 'int16u',
},
0x02e => {
Name => 'RawColorAdj',
Format => 'int16u',
PrintConv => {
0 => 'Shot Settings',
1 => 'Faithful',
2 => 'Custom',
},
},
0x030 => {
Name => 'RawCustomSaturation',
Format => 'int32s',
},
0x034 => {
Name => 'RawCustomTone',
Format => 'int32s',
},
0x038 => {
Name => 'RawBrightnessAdj',
Format => 'int32s',
ValueConv => '$val / 6000',
ValueConvInv => 'int($val * 6000 + ($val < 0 ? -0.5 : 0.5))',
PrintConv => 'sprintf("%.2f",$val)',
PrintConvInv => '$val',
},
0x03c => {
Name => 'ToneCurveProperty',
Format => 'int16u',
PrintConvColumns => 2,
PrintConv => {
0 => 'Shot Settings',
1 => 'Linear',
2 => 'Custom 1',
3 => 'Custom 2',
4 => 'Custom 3',
5 => 'Custom 4',
6 => 'Custom 5',
},
},
# 0x040 usually "10 9 2"
0x07a => {
Name => 'DynamicRangeMin',
Format => 'int16u',
},
0x07c => {
Name => 'DynamicRangeMax',
Format => 'int16u',
},
# 0x0c6 usually "10 9 2"
#
# RGB image adjustment
#
0x110 => {
Name => 'ToneCurveActive',
Format => 'int16u',
%noYes,
},
0x113 => {
Name => 'ToneCurveMode',
PrintConv => { 0 => 'RGB', 1 => 'Luminance' },
},
0x114 => {
Name => 'BrightnessAdj',
Format => 'int8s',
},
0x115 => {
Name => 'ContrastAdj',
Format => 'int8s',
},
0x116 => {
Name => 'SaturationAdj',
Format => 'int16s',
},
0x11e => {
Name => 'ColorToneAdj',
Notes => 'in degrees, so -1 is the same as 359',
Format => 'int32s',
},
0x126 => {
Name => 'LuminanceCurvePoints',
Format => 'int16u[21]',
PrintConv => 'Image::ExifTool::CanonVRD::ToneCurvePrint($val)',
PrintConvInv => 'Image::ExifTool::CanonVRD::ToneCurvePrintInv($val)',
},
0x150 => {
Name => 'LuminanceCurveLimits',
Notes => '4 numbers: input and output highlight and shadow points',
Format => 'int16u[4]',
},
0x159 => {
Name => 'ToneCurveInterpolation',
PrintConv => { 0 => 'Curve', 1 => 'Straight' },
},
0x160 => {
Name => 'RedCurvePoints',
Format => 'int16u[21]',
PrintConv => 'Image::ExifTool::CanonVRD::ToneCurvePrint($val)',
PrintConvInv => 'Image::ExifTool::CanonVRD::ToneCurvePrintInv($val)',
},
# 0x193 same as 0x159
0x19a => {
Name => 'GreenCurvePoints',
Format => 'int16u[21]',
PrintConv => 'Image::ExifTool::CanonVRD::ToneCurvePrint($val)',
PrintConvInv => 'Image::ExifTool::CanonVRD::ToneCurvePrintInv($val)',
},
# 0x1cd same as 0x159
0x1d4 => {
Name => 'BlueCurvePoints',
Format => 'int16u[21]',
PrintConv => 'Image::ExifTool::CanonVRD::ToneCurvePrint($val)',
PrintConvInv => 'Image::ExifTool::CanonVRD::ToneCurvePrintInv($val)',
},
0x18a => {
Name => 'RedCurveLimits',
Format => 'int16u[4]',
},
0x1c4 => {
Name => 'GreenCurveLimits',
Format => 'int16u[4]',
},
0x1fe => {
Name => 'BlueCurveLimits',
Format => 'int16u[4]',
},
# 0x207 same as 0x159
0x20e => {
Name => 'RGBCurvePoints',
Format => 'int16u[21]',
PrintConv => 'Image::ExifTool::CanonVRD::ToneCurvePrint($val)',
PrintConvInv => 'Image::ExifTool::CanonVRD::ToneCurvePrintInv($val)',
},
0x238 => {
Name => 'RGBCurveLimits',
Format => 'int16u[4]',
},
# 0x241 same as 0x159
0x244 => {
Name => 'CropActive',
Format => 'int16u',
%noYes,
},
0x246 => {
Name => 'CropLeft',
Notes => 'crop coordinates in original unrotated image',
Format => 'int16u',
},
0x248 => {
Name => 'CropTop',
Format => 'int16u',
},
0x24a => {
Name => 'CropWidth',
Format => 'int16u',
},
0x24c => {
Name => 'CropHeight',
Format => 'int16u',
},
0x25a => {
Name => 'SharpnessAdj',
Format => 'int16u',
},
0x260 => {
Name => 'CropAspectRatio',
Format => 'int16u',
PrintConv => {
0 => 'Free',
1 => '3:2',
2 => '2:3',
3 => '4:3',
4 => '3:4',
5 => 'A-size Landscape',
6 => 'A-size Portrait',
7 => 'Letter-size Landscape',
8 => 'Letter-size Portrait',
9 => '4:5',
10 => '5:4',
11 => '1:1',
12 => 'Circle',
65535 => 'Custom',
},
},
0x262 => {
Name => 'ConstrainedCropWidth',
Format => 'float',
PrintConv => 'sprintf("%.7g",$val)',
PrintConvInv => '$val',
},
0x266 => {
Name => 'ConstrainedCropHeight',
Format => 'float',
PrintConv => 'sprintf("%.7g",$val)',
PrintConvInv => '$val',
},
0x26a => {
Name => 'CheckMark',
Format => 'int16u',
PrintConv => {
0 => 'Clear',
1 => 1,
2 => 2,
3 => 3,
},
},
0x26e => {
Name => 'Rotation',
Format => 'int16u',
PrintConv => {
0 => 0,
1 => 90,
2 => 180,
3 => 270,
},
},
0x270 => {
Name => 'WorkColorSpace',
Format => 'int16u',
PrintConv => {
0 => 'sRGB',
1 => 'Adobe RGB',
2 => 'Wide Gamut RGB',
3 => 'Apple RGB',
4 => 'ColorMatch RGB',
},
},
# (VRD 1.0.0 edit data ends here -- 0x272 bytes)
);
# VRD Stamp Tool tags (ref PH)
%Image::ExifTool::CanonVRD::StampTool = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
GROUPS => { 2 => 'Image' },
0x00 => {
Name => 'StampToolCount',
Format => 'int32u',
},
);
# VRD version 2 and 3 tags (ref PH)
%Image::ExifTool::CanonVRD::Ver2 = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
WRITABLE => 1,
FIRST_ENTRY => 0,
FORMAT => 'int16s',
DATAMEMBER => [ 0x58, 0xdc, 0xdf, 0xe0 ], # (required for DataMember and var-format tags)
IS_SUBDIR => [ 0xe0 ],
GROUPS => { 2 => 'Image' },
NOTES => 'Tags added in DPP version 2.0 and later.',
0x02 => {
Name => 'PictureStyle',
PrintConvColumns => 2,
PrintConv => {
0 => 'Standard',
1 => 'Portrait',
2 => 'Landscape',
3 => 'Neutral',
4 => 'Faithful',
5 => 'Monochrome',
6 => 'Unknown?', # PH (maybe in-camera custom picture style?)
7 => 'Custom',
},
},
0x03 => { Name => 'IsCustomPictureStyle', %noYes },
# 0x08: 3
# 0x09: 4095
# 0x0a: 0
# 0x0b: 4095
# 0x0c: 0
0x0d => 'StandardRawColorTone',
0x0e => 'StandardRawSaturation',
0x0f => 'StandardRawContrast',
0x10 => { Name => 'StandardRawLinear', %noYes },
0x11 => 'StandardRawSharpness',
0x12 => 'StandardRawHighlightPoint',
0x13 => 'StandardRawShadowPoint',
0x14 => 'StandardOutputHighlightPoint', #2
0x15 => 'StandardOutputShadowPoint', #2
0x16 => 'PortraitRawColorTone',
0x17 => 'PortraitRawSaturation',
0x18 => 'PortraitRawContrast',
0x19 => { Name => 'PortraitRawLinear', %noYes },
0x1a => 'PortraitRawSharpness',
0x1b => 'PortraitRawHighlightPoint',
0x1c => 'PortraitRawShadowPoint',
0x1d => 'PortraitOutputHighlightPoint',
0x1e => 'PortraitOutputShadowPoint',
0x1f => 'LandscapeRawColorTone',
0x20 => 'LandscapeRawSaturation',
0x21 => 'LandscapeRawContrast',
0x22 => { Name => 'LandscapeRawLinear', %noYes },
0x23 => 'LandscapeRawSharpness',
0x24 => 'LandscapeRawHighlightPoint',
0x25 => 'LandscapeRawShadowPoint',
0x26 => 'LandscapeOutputHighlightPoint',
0x27 => 'LandscapeOutputShadowPoint',
0x28 => 'NeutralRawColorTone',
0x29 => 'NeutralRawSaturation',
0x2a => 'NeutralRawContrast',
0x2b => { Name => 'NeutralRawLinear', %noYes },
0x2c => 'NeutralRawSharpness',
0x2d => 'NeutralRawHighlightPoint',
0x2e => 'NeutralRawShadowPoint',
0x2f => 'NeutralOutputHighlightPoint',
0x30 => 'NeutralOutputShadowPoint',
0x31 => 'FaithfulRawColorTone',
0x32 => 'FaithfulRawSaturation',
0x33 => 'FaithfulRawContrast',
0x34 => { Name => 'FaithfulRawLinear', %noYes },
0x35 => 'FaithfulRawSharpness',
0x36 => 'FaithfulRawHighlightPoint',
0x37 => 'FaithfulRawShadowPoint',
0x38 => 'FaithfulOutputHighlightPoint',
0x39 => 'FaithfulOutputShadowPoint',
0x3a => {
Name => 'MonochromeFilterEffect',
PrintConv => {
-2 => 'None',
-1 => 'Yellow',
0 => 'Orange',
1 => 'Red',
2 => 'Green',
},
},
0x3b => {
Name => 'MonochromeToningEffect',
PrintConv => {
-2 => 'None',
-1 => 'Sepia',
0 => 'Blue',
1 => 'Purple',
2 => 'Green',
},
},
0x3c => 'MonochromeContrast',
0x3d => { Name => 'MonochromeLinear', %noYes },
0x3e => 'MonochromeSharpness',
0x3f => 'MonochromeRawHighlightPoint',
0x40 => 'MonochromeRawShadowPoint',
0x41 => 'MonochromeOutputHighlightPoint',
0x42 => 'MonochromeOutputShadowPoint',
0x45 => { Name => 'UnknownContrast', Unknown => 1 },
0x46 => { Name => 'UnknownLinear', %noYes, Unknown => 1 },
0x47 => { Name => 'UnknownSharpness', Unknown => 1 },
0x48 => { Name => 'UnknownRawHighlightPoint', Unknown => 1 },
0x49 => { Name => 'UnknownRawShadowPoint', Unknown => 1 },
0x4a => { Name => 'UnknownOutputHighlightPoint',Unknown => 1 },
0x4b => { Name => 'UnknownOutputShadowPoint', Unknown => 1 },
0x4c => 'CustomColorTone',
0x4d => 'CustomSaturation',
0x4e => 'CustomContrast',
0x4f => { Name => 'CustomLinear', %noYes },
0x50 => 'CustomSharpness',
0x51 => 'CustomRawHighlightPoint',
0x52 => 'CustomRawShadowPoint',
0x53 => 'CustomOutputHighlightPoint',
0x54 => 'CustomOutputShadowPoint',
0x58 => {
Name => 'CustomPictureStyleData',
Format => 'var_int16u',
Binary => 1,
Notes => 'variable-length data structure',
Writable => 0,
RawConv => 'length($val) == 2 ? undef : $val', # ignore if no data
},
# (VRD 2.0.0 edit data ends here: 178 bytes, index 0x59)
0x5e => [{
Name => 'ChrominanceNoiseReduction',
Condition => '$$self{VRDVersion} < 330',
Notes => 'VRDVersion prior to 3.3.0',
PrintConv => {
0 => 'Off',
58 => 'Low',
100 => 'High',
},
},{ #1
Name => 'ChrominanceNoiseReduction',
Notes => 'VRDVersion 3.3.0 or later',
PrintHex => 1,
PrintConvColumns => 4,
PrintConv => {
0x00 => 0,
0x10 => 1,
0x21 => 2,
0x32 => 3,
0x42 => 4,
0x53 => 5,
0x64 => 6,
0x74 => 7,
0x85 => 8,
0x96 => 9,
0xa6 => 10,
0xa7 => 11,
0xa8 => 12,
0xa9 => 13,
0xaa => 14,
0xab => 15,
0xac => 16,
0xad => 17,
0xae => 18,
0xaf => 19,
0xb0 => 20,
},
}],
0x5f => [{
Name => 'LuminanceNoiseReduction',
Condition => '$$self{VRDVersion} < 330',
Notes => 'VRDVersion prior to 3.3.0',
PrintConv => {
0 => 'Off',
65 => 'Low',
100 => 'High',
},
},{ #1
Name => 'LuminanceNoiseReduction',
Notes => 'VRDVersion 3.3.0 or later',
PrintHex => 1,
PrintConvColumns => 4,
PrintConv => {
0x00 => 0,
0x41 => 1,
0x64 => 2,
0x6e => 3,
0x78 => 4,
0x82 => 5,
0x8c => 6,
0x96 => 7,
0xa0 => 8,
0xaa => 9,
0xb4 => 10,
0xb5 => 11,
0xb6 => 12,
0xb7 => 13,
0xb8 => 14,
0xb9 => 15,
0xba => 16,
0xbb => 17,
0xbc => 18,
0xbd => 19,
0xbe => 20,
},
}],
0x60 => [{
Name => 'ChrominanceNR_TIFF_JPEG',
Condition => '$$self{VRDVersion} < 330',
Notes => 'VRDVersion prior to 3.3.0',
PrintConv => {
0 => 'Off',
33 => 'Low',
100 => 'High',
},
},{ #1
Name => 'ChrominanceNR_TIFF_JPEG',
Notes => 'VRDVersion 3.3.0 or later',
PrintHex => 1,
PrintConvColumns => 4,
PrintConv => {
0x00 => 0,
0x10 => 1,
0x21 => 2,
0x32 => 3,
0x42 => 4,
0x53 => 5,
0x64 => 6,
0x74 => 7,
0x85 => 8,
0x96 => 9,
0xa6 => 10,
0xa7 => 11,
0xa8 => 12,
0xa9 => 13,
0xaa => 14,
0xab => 15,
0xac => 16,
0xad => 17,
0xae => 18,
0xaf => 19,
0xb0 => 20,
},
}],
# 0x61: 1
# (VRD 3.0.0 edit data ends here: 196 bytes, index 0x62)
0x62 => { Name => 'ChromaticAberrationOn', %noYes },
0x63 => { Name => 'DistortionCorrectionOn', %noYes },
0x64 => { Name => 'PeripheralIlluminationOn', %noYes },
0x65 => { Name => 'ColorBlur', %noYes },
0x66 => {
Name => 'ChromaticAberration',
ValueConv => '$val / 0x400',
ValueConvInv => 'int($val * 0x400 + 0.5)',
PrintConv => 'sprintf("%.0f%%", $val * 100)',
PrintConvInv => 'ToFloat($val) / 100',
},
0x67 => {
Name => 'DistortionCorrection',
ValueConv => '$val / 0x400',
ValueConvInv => 'int($val * 0x400 + 0.5)',
PrintConv => 'sprintf("%.0f%%", $val * 100)',
PrintConvInv => 'ToFloat($val) / 100',
},
0x68 => {
Name => 'PeripheralIllumination',
ValueConv => '$val / 0x400',
ValueConvInv => 'int($val * 0x400 + 0.5)',
PrintConv => 'sprintf("%.0f%%", $val * 100)',
PrintConvInv => 'ToFloat($val) / 100',
},
0x69 => {
Name => 'AberrationCorrectionDistance',
Notes => '100% = infinity',
RawConv => '$val == 0x7fff ? undef : $val',
ValueConv => '1 - $val / 0x400',
ValueConvInv => 'int((1 - $val) * 0x400 + 0.5)',
PrintConv => 'sprintf("%.0f%%", $val * 100)',
PrintConvInv => 'ToFloat($val) / 100',
},
0x6a => 'ChromaticAberrationRed',
0x6b => 'ChromaticAberrationBlue',
0x6d => { #1
Name => 'LuminanceNR_TIFF_JPEG',
Notes => 'val = raw / 10',
ValueConv => '$val / 10',
ValueConvInv => 'int($val * 10 + 0.5)',
},
# (VRD 3.4.0 edit data ends here: 220 bytes, index 0x6e)
0x6e => { Name => 'AutoLightingOptimizerOn', %noYes },
0x6f => {
Name => 'AutoLightingOptimizer',
PrintConv => {
100 => 'Low',
200 => 'Standard',
300 => 'Strong',
0x7fff => 'n/a', #1
},
},
# 0x71: 200
# 0x73: 100
# (VRD 3.5.0 edit data ends here: 232 bytes, index 0x74)
0x75 => {
Name => 'StandardRawHighlight',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x76 => {
Name => 'PortraitRawHighlight',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x77 => {
Name => 'LandscapeRawHighlight',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x78 => {
Name => 'NeutralRawHighlight',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x79 => {
Name => 'FaithfulRawHighlight',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x7a => {
Name => 'MonochromeRawHighlight',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x7b => {
Name => 'UnknownRawHighlight',
Unknown => 1,
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x7c => {
Name => 'CustomRawHighlight',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x7e => {
Name => 'StandardRawShadow',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x7f => {
Name => 'PortraitRawShadow',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x80 => {
Name => 'LandscapeRawShadow',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x81 => {
Name => 'NeutralRawShadow',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x82 => {
Name => 'FaithfulRawShadow',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x83 => {
Name => 'MonochromeRawShadow',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x84 => {
Name => 'UnknownRawShadow',
Unknown => 1,
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x85 => {
Name => 'CustomRawShadow',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
},
0x8b => { #2
Name => 'AngleAdj',
Format => 'int32s',
ValueConv => '$val / 100',
ValueConvInv => '$val * 100',
},
0x8e => {
Name => 'CheckMark2',
Format => 'int16u',
PrintConvColumns => 2,
PrintConv => {
0 => 'Clear',
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
},
},
# (VRD 3.8.0 edit data ends here: 286 bytes, index 0x8f)
0x90 => {
Name => 'UnsharpMask',
PrintConv => { 0 => 'Off', 1 => 'On' },
},
0x92 => 'StandardUnsharpMaskStrength',
0x94 => 'StandardUnsharpMaskFineness',
0x96 => 'StandardUnsharpMaskThreshold',
0x98 => 'PortraitUnsharpMaskStrength',
0x9a => 'PortraitUnsharpMaskFineness',
0x9c => 'PortraitUnsharpMaskThreshold',
0x9e => 'LandscapeUnsharpMaskStrength',
0xa0 => 'LandscapeUnsharpMaskFineness',
0xa2 => 'LandscapeUnsharpMaskThreshold',
0xa4 => 'NeutraUnsharpMaskStrength',
0xa6 => 'NeutralUnsharpMaskFineness',
0xa8 => 'NeutralUnsharpMaskThreshold',
0xaa => 'FaithfulUnsharpMaskStrength',
0xac => 'FaithfulUnsharpMaskFineness',
0xae => 'FaithfulUnsharpMaskThreshold',
0xb0 => 'MonochromeUnsharpMaskStrength',
0xb2 => 'MonochromeUnsharpMaskFineness',
0xb4 => 'MonochromeUnsharpMaskThreshold',
0xb6 => 'CustomUnsharpMaskStrength',
0xb8 => 'CustomUnsharpMaskFineness',
0xba => 'CustomUnsharpMaskThreshold',
0xbc => 'CustomDefaultUnsharpStrength',
0xbe => 'CustomDefaultUnsharpFineness',
0xc0 => 'CustomDefaultUnsharpThreshold',
# (VRD 3.9.1 edit data ends here: 392 bytes, index 0xc4)
# 0xc9: 3 - some RawSharpness
# 0xca: 4095 - some RawHighlightPoint
# 0xcb: 0 - some RawShadowPoint
# 0xcc: 4095 - some OutputHighlightPoint
# 0xcd: 0 - some OutputShadowPoint
# 0xd1: 3 - some UnsharpMaskStrength
# 0xd3: 7 - some UnsharpMaskFineness
# 0xd5: 3,4 - some UnsharpMaskThreshold
0xd6 => { Name => 'CropCircleActive', %noYes },
0xd7 => 'CropCircleX',
0xd8 => 'CropCircleY',
0xd9 => 'CropCircleRadius',
# 0xda: 0, 1
# 0xdb: 100
0xdc => {
Name => 'DLOOn',
DataMember => 'DLOOn',
RawConv => '$$self{DLOOn} = $val',
%noYes,
},
0xdd => 'DLOSetting',
# (VRD 3.11.0 edit data ends here: 444 bytes, index 0xde)
0xde => {
Name => 'DLOShootingDistance',
Notes => '100% = infinity',
RawConv => '$val == 0x7fff ? undef : $val',
ValueConv => '1 - $val / 0x400',
ValueConvInv => 'int((1 - $val) * 0x400 + 0.5)',
PrintConv => 'sprintf("%.0f%%", $val * 100)',
PrintConvInv => 'ToFloat($val) / 100',
},
0xdf => {
Name => 'DLODataLength',
DataMember => 'DLODataLength',
Format => 'int32u',
Writable => 0,
RawConv => '$$self{DLODataLength} = $val',
},
0xe0 => { # (yes, this overlaps DLODataLength)
Name => 'DLOInfo',
# - have seen DLODataLengths of 65536,64869 when DLO is Off, so must test DLOOn flag
Condition => '$$self{DLOOn}',
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::DLOInfo' },
Hook => '$varSize += $$self{DLODataLength} + 0x16',
},
0xe1 => 'CameraRawColorTone',
# (VRD 3.11.2 edit data ends here: 452 bytes, index 0xe2, unless DLO is on)
0xe2 => 'CameraRawSaturation',
0xe3 => 'CameraRawContrast',
0xe4 => { Name => 'CameraRawLinear', %noYes },
0xe5 => 'CameraRawSharpness',
0xe6 => 'CameraRawHighlightPoint',
0xe7 => 'CameraRawShadowPoint',
0xe8 => 'CameraRawOutputHighlightPoint',
0xe9 => 'CameraRawOutputShadowPoint',
);
# DLO tags (ref PH)
%Image::ExifTool::CanonVRD::DLOInfo = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
WRITABLE => 1,
FIRST_ENTRY => 1,
FORMAT => 'int16s',
GROUPS => { 2 => 'Image' },
NOTES => 'Tags added when DLO (Digital Lens Optimizer) is on.',
# 0x01 - seen 3112,3140
0x04 => 'DLOSettingApplied',
0x05 => {
Name => 'DLOVersion', #(NC)
Format => 'string[10]',
},
0x0a => {
Name => 'DLOData',
LargeTag => 1, # large tag, so avoid storing unnecessarily
Notes => 'variable-length Digital Lens Optimizer data, stored in JPEG-like format',
Format => 'undef[$$self{DLODataLength}]',
Writable => 0,
Binary => 1,
},
);
# VRD version 4 tags (ref PH)
%Image::ExifTool::CanonVRD::DR4 = (
PROCESS_PROC => \&ProcessDR4,
WRITE_PROC => \&ProcessDR4,
WRITABLE => 1,
GROUPS => { 2 => 'Image' },
VARS => { HEX_ID => 1, SORT_PROC => \&SortDR4 },
NOTES => q{
Tags written by Canon DPP version 4 in CanonVRD trailers and DR4 files. Each
tag has three associated flag words which are stored with the directory
entry, some of which are extracted as a separate tag, indicated in the table
below by a decimal appended to the tag ID (.0, .1 or .2).
},
header => {
Name => 'DR4Header',
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::DR4Header' },
},
0x10002 => 'Rotation', # left/right rotation 90,180,270
0x10003 => 'AngleAdj', # crop angle
# 0x10018 - fmt=8: 0
# 0x10020 - fmt=2: ''
0x10021 => 'CustomPictureStyle', # (string)
0x10101 => {
Name => 'CheckMark',
PrintConv => {
0 => 'Clear',
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
},
},
0x10200 => {
Name => 'WorkColorSpace',
PrintConv => {
1 => 'sRGB',
2 => 'Adobe RGB',
3 => 'Wide Gamut RGB',
4 => 'Apple RGB',
5 => 'ColorMatch RGB',
},
},
# 0x10201 - fmt=9: 0
# 0x10f20 - fmt=9: 350
0x20001 => 'RawBrightnessAdj',
0x20101 => {
Name => 'WhiteBalanceAdj',
PrintConvColumns => 2,
PrintConv => {
-1 => 'Manual (Click)',
0 => 'Auto',
1 => 'Daylight',
2 => 'Cloudy',
3 => 'Tungsten',
4 => 'Fluorescent',
5 => 'Flash',
8 => 'Shade',
9 => 'Kelvin',
255 => 'Shot Settings',
},
},
0x20102 => 'WBAdjColorTemp',
0x20105 => 'WBAdjMagentaGreen',
0x20106 => 'WBAdjBlueAmber',
0x20125 => {
Name => 'WBAdjRGGBLevels',
PrintConv => '$val =~ s/^\d+ //; $val', # remove first integer (14: what is this for?)
PrintConvInv => '"14 $val"',
},
0x20200 => { Name => 'GammaLinear', %noYes },
0x20301 => {
Name => 'PictureStyle',
PrintHex => 1,
PrintConv => {
0x81 => 'Standard',
0x82 => 'Portrait',
0x83 => 'Landscape',
0x84 => 'Neutral',
0x85 => 'Faithful',
0x86 => 'Monochrome',
0x87 => 'Auto',
0x88 => 'Fine Detail',
0xf0 => 'Shot Settings',
0xff => 'Custom',
},
},
# 0x20302 - Gamma curve data
0x20303 => 'ContrastAdj',
0x20304 => 'ColorToneAdj',
0x20305 => 'ColorSaturationAdj',
0x20306 => {
Name => 'MonochromeToningEffect',
PrintConv => {
0 => 'None',
1 => 'Sepia',
2 => 'Blue',
3 => 'Purple',
4 => 'Green',
},
},
0x20307 => {
Name => 'MonochromeFilterEffect',
PrintConv => {
0 => 'None',
1 => 'Yellow',
2 => 'Orange',
3 => 'Red',
4 => 'Green',
},
},
0x20308 => 'UnsharpMaskStrength',
0x20309 => 'UnsharpMaskFineness',
0x2030a => 'UnsharpMaskThreshold',
0x2030b => 'ShadowAdj',
0x2030c => 'HighlightAdj',
0x20310 => {
Name => 'SharpnessAdj',
PrintConv => {
0 => 'Sharpness',
1 => 'Unsharp Mask',
},
},
'0x20310.0' => { Name => 'SharpnessAdjOn', %noYes },
0x20311 => 'SharpnessStrength',
0x20400 => {
Name => 'ToneCurve',
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::ToneCurve' },
},
'0x20400.1' => { Name => 'ToneCurveOriginal', %noYes },
# 0x20401 - fmt=33 (312 bytes)
0x20410 => 'ToneCurveBrightness',
0x20411 => 'ToneCurveContrast',
0x20500 => {
Name => 'AutoLightingOptimizer',
PrintConv => {
0 => 'Low',
1 => 'Standard',
2 => 'Strong',
},
},
'0x20500.0' => {
Name => 'AutoLightingOptimizerOn',
Notes => 'ignored if gamma is linear',
%noYes,
},
# 0x20501 - fmt=13: 0
# 0x20502 - fmt=13: 0
0x20600 => 'LuminanceNoiseReduction',
0x20601 => 'ChrominanceNoiseReduction',
# 0x20650 - fmt=9: 0 (JPG images)
0x20701 => {
Name => 'ShootingDistance',
Notes => '100% = infinity',
ValueConv => '$val / 10',
ValueConvInv => '$val * 10',
PrintConv => 'sprintf("%.0f%%", $val * 100)',
PrintConvInv => 'ToFloat($val) / 100',
},
0x20702 => {
Name => 'PeripheralIllumination',
PrintConv => 'sprintf "%g", $val',
PrintConvInv => '$val',
},
'0x20702.0' => { Name => 'PeripheralIlluminationOn', %noYes },
0x20703 => {
Name => 'ChromaticAberration',
PrintConv => 'sprintf "%g", $val',
PrintConvInv => '$val',
},
'0x20703.0' => { Name => 'ChromaticAberrationOn', %noYes },
0x20704 => { Name => 'ColorBlurOn', %noYes },
0x20705 => {
Name => 'DistortionCorrection',
PrintConv => 'sprintf "%g", $val',
PrintConvInv => '$val',
},
'0x20705.0' => { Name => 'DistortionCorrectionOn', %noYes },
0x20706 => 'DLOSetting',
'0x20706.0' => { Name => 'DLOOn', %noYes },
0x20707 => {
Name => 'ChromaticAberrationRed',
PrintConv => 'sprintf "%g", $val',
PrintConvInv => '$val',
},
0x20708 => {
Name => 'ChromaticAberrationBlue',
PrintConv => 'sprintf "%g", $val',
PrintConvInv => '$val',
},
0x20709 => {
Name => 'DistortionEffect',
PrintConv => {
0 => 'Shot Settings',
1 => 'Emphasize Linearity',
2 => 'Emphasize Distance',
3 => 'Emphasize Periphery',
4 => 'Emphasize Center',
},
},
# 0x20800 - fmt=1: 0
# 0x20801 - fmt=1: 0
0x20900 => 'ColorHue',
0x20901 => 'SaturationAdj',
0x20910 => 'RedHSL',
0x20911 => 'OrangeHSL',
0x20912 => 'GreenHSL',
0x20913 => 'AquaHSL',
0x20914 => 'BlueHSL',
0x20915 => 'BlueHSL',
0x20916 => 'PurpleHSL',
0x20917 => 'MagentaHSL',
0x20a00 => {
Name => 'GammaInfo',
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::GammaInfo' },
},
# 0x20a01 - Auto picture style settings
# 0x20a02 - Standard picture style settings
# 0x20a03 - Portrait picture style settings
# 0x20a04 - Landscape picture style settings
# 0x20a05 - Neutral picture style settings
# 0x20a06 - Faithful picture style settings
# 0x20a07 - Monochrome picture style settings
# 0x20a08 - (unknown picture style settings)
# 0x20a09 - Custom picture style settings
# 0x20a20 - Fine Detail picture style settings
0x30101 => {
Name => 'CropAspectRatio',
PrintConv => {
0 => 'Free',
1 => 'Custom',
2 => '1:1',
3 => '3:2',
4 => '2:3',
5 => '4:3',
6 => '3:4',
7 => '5:4',
8 => '4:5',
9 => '16:9',
10 => '9:16',
},
},
0x30102 => 'CropAspectRatioCustom',
# 0x30103 - fmt=33: "0 0 8"
0xf0100 => {
Name => 'CropInfo',
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::CropInfo' },
},
0xf0500 => {
Name => 'CustomPictureStyleData',
Binary => 1,
},
0xf0510 => {
Name => 'StampInfo',
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::StampInfo' },
},
0xf0511 => {
Name => 'DustInfo',
SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::DustInfo' },
},
0xf0512 => 'LensFocalLength',
# 0xf0521 - DLO data
# 0xf0520 - DLO data
# 0xf0530 - created when dust delete data applied (4 bytes, all zero)
# 0xf0600 - fmt=253 (2308 bytes, JPG images)
# 0xf0601 - fmt=253 (2308 bytes, JPG images)
# 0x1ff52c - values: 129,130,132 (related to custom picture style somehow)
# to do:
# - find 8-15mm CR2 sample and decode linear distortion effect fine-tune
);
# Version 4 header information (ref PH)
%Image::ExifTool::CanonVRD::DR4Header = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
WRITABLE => 1,
FIRST_ENTRY => 0,
FORMAT => 'int32u',
GROUPS => { 2 => 'Image' },
# 0 - value: 'IIII' (presumably byte order)
# 1 - value: 0x00040004 (currently use this for magic number)
# 2 - value: 6
3 => {
Name => 'DR4CameraModel',
Writable => 'int32u',
PrintHex => 1,
SeparateTable => 'Canon CameraModelID',
PrintConv => \%Image::ExifTool::Canon::canonModelID,
},
# 4 - value: 3
# 5 - value: 4
# 6 - value: 5
# 7 - DR4 directory entry count
);
# Version 4 RGB tone curve information (ref PH)
%Image::ExifTool::CanonVRD::ToneCurve = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
WRITABLE => 1,
FIRST_ENTRY => 0,
FORMAT => 'int32u',
GROUPS => { 2 => 'Image' },
0x00 => {
Name => 'ToneCurveColorSpace',
PrintConv => {
0 => 'RGB',
1 => 'Luminance',
},
},
0x01 => {
Name => 'ToneCurveShape',
PrintConv => {
0 => 'Curve',
1 => 'Straight',
},
},
0x03 => { Name => 'ToneCurveInputRange', Format => 'int32u[2]', Notes => '255 max' },
0x05 => { Name => 'ToneCurveOutputRange', Format => 'int32u[2]', Notes => '255 max' },
0x07 => {
Name => 'RGBCurvePoints',
Format => 'int32u[21]',
PrintConv => 'Image::ExifTool::CanonVRD::ToneCurvePrint($val)',
PrintConvInv => 'Image::ExifTool::CanonVRD::ToneCurvePrintInv($val)',
},
0x0a => 'ToneCurveX',
0x0b => 'ToneCurveY',
0x2d => {
Name => 'RedCurvePoints',
Format => 'int32u[21]',
PrintConv => 'Image::ExifTool::CanonVRD::ToneCurvePrint($val)',
PrintConvInv => 'Image::ExifTool::CanonVRD::ToneCurvePrintInv($val)',
},
0x53 => {
Name => 'GreenCurvePoints',
Format => 'int32u[21]',
PrintConv => 'Image::ExifTool::CanonVRD::ToneCurvePrint($val)',
PrintConvInv => 'Image::ExifTool::CanonVRD::ToneCurvePrintInv($val)',
},
0x79 => {
Name => 'BlueCurvePoints',
Format => 'int32u[21]',
PrintConv => 'Image::ExifTool::CanonVRD::ToneCurvePrint($val)',
PrintConvInv => 'Image::ExifTool::CanonVRD::ToneCurvePrintInv($val)',
},
);
# Version 4 gamma curve information (ref PH)
%Image::ExifTool::CanonVRD::GammaInfo = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
WRITABLE => 1,
FIRST_ENTRY => 0,
FORMAT => 'double',
GROUPS => { 2 => 'Image' },
0x02 => 'GammaContrast',
0x03 => 'GammaColorTone',
0x04 => 'GammaSaturation',
0x05 => 'GammaUnsharpMaskStrength',
0x06 => 'GammaUnsharpMaskFineness',
0x07 => 'GammaUnsharpMaskThreshold',
0x08 => 'GammaSharpnessStrength',
0x09 => 'GammaShadow',
0x0a => 'GammaHighlight',
# 0x0b-0x10 are the same as first 6 doubles of tag DR4_0x20302
# 0x0b - value: 14
0x0c => {
Name => 'GammaBlackPoint',
ValueConv => q{
return 0 if $val <= 0;
$val = log($val / 4.6875) / log(2) + 1;
return abs($val) > 1e-10 ? $val : 0;
},
ValueConvInv => '$val ? exp(($val - 1) * log(2)) * 4.6876 : 0',
PrintConv => 'sprintf("%+.3f", $val)',
PrintConvInv => '$val',
},
0x0d => {
Name => 'GammaWhitePoint',
ValueConv => q{
return $val if $val <= 0;
$val = log($val / 4.6875) / log(2) - 11.77109325169954;
return abs($val) > 1e-10 ? $val : 0;
},
ValueConvInv => '$val ? exp(($val + 11.77109325169954) * log(2)) * 4.6875 : 0',
PrintConv => 'sprintf("%+.3f", $val)',
PrintConvInv => '$val',
},
0x0e => {
Name => 'GammaMidPoint',
ValueConv => q{
return $val if $val <= 0;
$val = log($val / 4.6875) / log(2) - 8;
return abs($val) > 1e-10 ? $val : 0;
},
ValueConvInv => '$val ? exp(($val + 8) * log(2)) * 4.6876 : 0',
PrintConv => 'sprintf("%+.3f", $val)',
PrintConvInv => '$val',
},
0x0f => { Name => 'GammaCurveOutputRange', Format => 'double[2]', Notes => '16383 max' },
);
# Version 4 crop information (ref PH)
%Image::ExifTool::CanonVRD::CropInfo = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
WRITABLE => 1,
FIRST_ENTRY => 0,
FORMAT => 'int32s',
GROUPS => { 2 => 'Image' },
0 => { Name => 'CropActive', %noYes },
1 => 'CropRotatedOriginalWidth',
2 => 'CropRotatedOriginalHeight',
3 => 'CropX',
4 => 'CropY',
5 => 'CropWidth',
6 => 'CropHeight',
8 => {
Name => 'CropRotation',
Format => 'double',
PrintConv => 'sprintf("%.7g",$val)',
PrintConvInv => '$val',
},
0x0a => 'CropOriginalWidth',
0x0b => 'CropOriginalHeight',
# 0x0c double - value: 100
);
# DR4 Stamp Tool tags (ref PH)
%Image::ExifTool::CanonVRD::StampInfo = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
GROUPS => { 2 => 'Image' },
FORMAT => 'int32u',
FIRST_ENTRY => 0,
0x02 => 'StampToolCount',
);
# DR4 dust delete information (ref PH)
%Image::ExifTool::CanonVRD::DustInfo = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
GROUPS => { 2 => 'Image' },
FORMAT => 'int32u',
FIRST_ENTRY => 0,
0x02 => { Name => 'DustDeleteApplied', %noYes },
);
#------------------------------------------------------------------------------
# sort DR4 tag ID's for the documentation
sub SortDR4($$)
{
my ($a, $b) = @_;
my ($aHex, $aDec, $bHex, $bDec);
($aHex, $aDec) = ($1, $2) if $a =~ /^(0x[0-9a-f]+)?\.?(\d*?)$/;
($bHex, $bDec) = ($1, $2) if $b =~ /^(0x[0-9a-f]+)?\.?(\d*?)$/;
if ($aHex) {
return 1 unless defined $bDec; # $b is 'header';
return hex($aHex) <=> hex($bHex) || $aDec <=> $bDec if $bHex;
return hex($aHex) <=> $bDec || 1;
} elsif ($bHex) {
return -1 unless defined $aDec;
return $aDec <=> hex($bHex) || -1;
} else {
return 1 unless defined $bDec;
return -1 unless defined $aDec;
return $aDec <=> $bDec;
}
}
#------------------------------------------------------------------------------
# Tone curve print conversion
sub ToneCurvePrint($)
{
my $val = shift;
my @vals = split ' ', $val;
return $val unless @vals == 21;
my $n = shift @vals;
return $val unless $n >= 2 and $n <= 10;
$val = '';
while ($n--) {
$val and $val .= ' ';
$val .= '(' . shift(@vals) . ',' . shift(@vals) . ')';
}
return $val;
}
#------------------------------------------------------------------------------
# Inverse print conversion for tone curve
sub ToneCurvePrintInv($)
{
my $val = shift;
my @vals = ($val =~ /\((\d+),(\d+)\)/g);
return undef unless @vals >= 4 and @vals <= 20 and not @vals & 0x01;
unshift @vals, scalar(@vals) / 2;
while (@vals < 21) { push @vals, 0 }
return join(' ',@vals);
}
#------------------------------------------------------------------------------
# Read/Write VRD edit data
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
# Returns: Reading: 1 on success; Writing: modified edit data, or undef if nothing changed
sub ProcessEditData($$$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
$et or return 1; # allow dummy access
my $dataPt = $$dirInfo{DataPt};
my $pos = $$dirInfo{DirStart};
my $dataPos = $$dirInfo{DataPos};
my $outfile = $$dirInfo{OutFile};
my $dirLen = $$dirInfo{DirLen};
my $verbose = $et->Options('Verbose');
my $out = $et->Options('TextOut');
my $oldChanged = $$et{CHANGED};
$et->VerboseDir('VRD Edit Data', 0, $dirLen) unless $outfile;
if ($outfile) {
# make a copy for editing in place
my $buff = substr($$dataPt, $pos, $dirLen);
$dataPt = $$dirInfo{DataPt} = \$buff;
$pos = $$dirInfo{DirStart} = 0;
}
my $dirEnd = $pos + $dirLen;
# loop through all records in the edit data
my ($recNum, $recLen, $err);
for ($recNum=0;; ++$recNum, $pos+=$recLen) {
if ($pos + 4 > $dirEnd) {
last if $pos == $dirEnd; # all done if we arrived at end
$recLen = 0; # just reset record size (will exit loop on test below)
} else {
$recLen = Get32u($dataPt, $pos);
# (DR4 has a null terminator)
last if $recLen == 0 and $pos + 4 == $dirEnd;
}
$pos += 4; # move to start of record
if ($pos + $recLen > $dirEnd) {
$et->Warn('Possibly corrupt CanonVRD Edit record');
$err = 1;
last;
}
my $saveRecLen = $recLen;
if ($verbose > 1 and not $outfile) {
printf $out "$$et{INDENT}CanonVRD Edit record ($recLen bytes at offset 0x%x)\n",
$pos + $dataPos;
if ($recNum and $verbose > 2) {
my %parms = (
Start => $pos,
Addr => $pos + $dataPos,
Out => $out,
Prefix => $$et{INDENT},
);
$parms{MaxLen} = $verbose == 3 ? 96 : 2048 if $verbose < 5;
HexDump($dataPt, $recLen, %parms);
}
}
# our edit information is the 0th record, so don't process the others
next if $recNum;
# process VRD edit information
my $subTablePtr = $tagTablePtr;
my $index;
my %subdirInfo = (
DataPt => $dataPt,
DataPos => $dataPos,
DirStart => $pos,
DirLen => $recLen,
OutFile => $outfile,
);
my $subStart = 0;
# loop through various sections of the VRD edit data
for ($index=0; ; ++$index) {
my $tagInfo = $$subTablePtr{$index} or last;
my $subLen;
my $maxLen = $recLen - $subStart;
if ($$tagInfo{Size}) {
$subLen = $$tagInfo{Size};
} elsif (defined $$tagInfo{Size}) {
# get size from int32u at $subStart
last unless $subStart + 4 <= $recLen;
$subLen = Get32u($dataPt, $subStart + $pos);
$subStart += 4; # skip the length word
} else {
$subLen = $maxLen;
}
$subLen > $maxLen and $subLen = $maxLen;
if ($subLen) {
my $subTable = GetTagTable($$tagInfo{SubDirectory}{TagTable});
my $subName = $$tagInfo{Name};
$subdirInfo{DirStart} = $subStart + $pos;
$subdirInfo{DirLen} = $subLen;
$subdirInfo{DirName} = $subName;
if ($outfile) {
# rewrite this section of the VRD edit information
$verbose and print $out " Rewriting Canon $subName\n";
my $newVal = $et->WriteDirectory(\%subdirInfo, $subTable);
if ($newVal) {
my $sizeDiff = length($newVal) - $subLen;
substr($$dataPt, $pos+$subStart, $subLen) = $newVal;
if ($sizeDiff) {
$subLen = length $newVal;
$recLen += $sizeDiff;
$dirEnd += $sizeDiff;
$dirLen += $sizeDiff;
}
}
} else {
$et->VPrint(0, "$$et{INDENT}$subName (SubDirectory) -->\n");
$et->VerboseDump($dataPt,
Start => $pos + $subStart,
Addr => $dataPos + $pos + $subStart,
Len => $subLen,
);
# extract tags from this section of the VRD edit information
$et->ProcessDirectory(\%subdirInfo, $subTable);
}
}
# next section starts at the end of this one
$subStart += $subLen;
}
if ($outfile and $saveRecLen ne $recLen) {
# update record length if necessary
Set32u($recLen, $dataPt, $pos - 4)
}
}
if ($outfile) {
return undef if $oldChanged == $$et{CHANGED};
return substr($$dataPt, $$dirInfo{DirStart}, $dirLen);
}
return $err ? 0 : 1;
}
#------------------------------------------------------------------------------
# Process VRD IHL data
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
# Returns: 1 on success
sub ProcessIHL($$$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
my $dataPt = $$dirInfo{DataPt};
my $dataPos = $$dirInfo{DataPos};
my $pos = $$dirInfo{DirStart};
my $dirLen = $$dirInfo{DirLen};
my $dirEnd = $pos + $dirLen;
$et->VerboseDir('VRD IHL', 0, $dirLen);
SetByteOrder('II'); # (make up your mind, Canon!)
while ($pos + 48 <= $dirEnd) {
my $hdr = substr($$dataPt, $pos, 48);
unless ($hdr =~ /^IHL Created Optional Item Data\0\0/) {
$et->Warn('Possibly corrupted VRD IHL data');
last;
}
my $tag = Get32u($dataPt, $pos + 36);
my $size = Get32u($dataPt, $pos + 40); # size of data in IHL record
my $next = Get32u($dataPt, $pos + 44); # size of complete IHL record
if ($size > $next or $pos + 48 + $next > $dirEnd) {
$et->Warn(sprintf('Bad size for VRD IHL tag 0x%.4x', $tag));
last;
}
$pos += 48;
$et->HandleTag($tagTablePtr, $tag, substr($$dataPt, $pos, $size),
DataPt => $dataPt,
DataPos => $dataPos,
Start => $pos,
Size => $size
);
$pos += $next;
}
return 1;
}
#------------------------------------------------------------------------------
# Process VRD IHL EXIF data
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
# Returns: 1 on success
sub ProcessIHLExif($$$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
$$et{DOC_NUM} = 1;
# the IHL-edited maker notes may look messed up, but the offsets should be OK
my $oldFix = $et->Options(FixBase => 0);
my $rtnVal = $et->ProcessTIFF($dirInfo, $tagTablePtr);
$et->Options(FixBase => $oldFix);
delete $$et{DOC_NUM};
return $rtnVal;
}
#------------------------------------------------------------------------------
# Wrap DR4 data with the VRD header/footer and edit record
# Inputs: 0) DR4 record
# Returns: VRD[Edit[DR4]] data
sub WrapDR4($)
{
my $val = shift;
my $n = length $val;
my $oldOrder = GetByteOrder();
SetByteOrder('MM');
$val = $blankHeader . "\xff\xff\0\xf7" . Set32u($n+8) . Set32u($n) .
$val . "\0\0\0\0" . $blankFooter;
# update the new VRD length in the header/footer
Set32u($n + 16, \$val, 0x18); # (extra 16 bytes for the edit record wrapper)
Set32u($n + 16, \$val, length($val) - 0x2c);
SetByteOrder($oldOrder);
return $val;
}
#------------------------------------------------------------------------------
# Read/Write DPP version 4 edit data or DR4 file
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
# Returns:
# Reading from memory (not RAF and not IsWriting): 1 on success
# Editing from memory (not RAF and IsWriting): modified edit data, or undef if nothing changed
# Reading file (RAF and not OutFile): 1 if a valid DR4 file, 0 if not
# Writing file (RAF and OutFile): 1 if valid DR4 file, 0 if not, -1 on write error
# (serves me right for not having a consistent interface for the various modes of operation)
sub ProcessDR4($$;$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
$et or return 1; # allow dummy access
my $dataPt = $$dirInfo{DataPt};
my $raf = $$dirInfo{RAF};
my $outfile = $$dirInfo{OutFile};
my $isWriting = $outfile || $$dirInfo{IsWriting};
my $dataPos = $$dirInfo{DataPos} || 0;
my $verbose = $et->Options('Verbose');
my $unknown = $et->Options('Unknown');
my ($pos, $dirLen, $numEntries, $err, $newTags);
# write CanonDR4 as a block if specified
if ($isWriting) {
my $nvHash;
my $newVal = $et->GetNewValue('CanonDR4', \$nvHash);
if ($newVal) {
$et->VPrint(0, " Writing CanonDR4 as a block\n");
$$et{DidCanonVRD} = 1; # set flag so we don't add this twice
++$$et{CHANGED};
if ($outfile) {
Write($$dirInfo{OutFile}, $newVal) or return -1;
return 1;
} else {
return $newVal;
}
} elsif (not $dataPt and ($nvHash or $$et{DEL_GROUP}{CanonVRD})) {
$et->Error("Can't delete all CanonDR4 information from a DR4 file");
return 1;
}
}
if ($dataPt) {
$pos = $$dirInfo{DirStart} || 0;
$dirLen = $$dirInfo{DirLen} || length($$dataPt) - $pos;
} else {
# load DR4 file into memory
my $buff;
$raf->Read($buff, 8) == 8 and $buff eq "IIII\x04\0\x04\0" or return 0;
$et->SetFileType();
$raf->Seek(0, 2) or return $err = 1;
$dirLen = $raf->Tell();
$raf->Seek(0, 0) or return $err = 1;
$raf->Read($buff, $dirLen) == $dirLen or $err = 1;
$err and $et->Warn('Error reading DR4 file'), return 1;
$tagTablePtr = GetTagTable('Image::ExifTool::CanonVRD::DR4');
$dataPt = \$buff;
$pos = 0;
}
my $dirEnd = $pos + $dirLen;
if (($$et{TAGS_FROM_FILE} and
not $$et{EXCL_TAG_LOOKUP}{canondr4}) or $$et{REQ_TAG_LOOKUP}{canondr4})
{
# extract CanonDR4 block if copying tags, or if requested
$et->FoundTag('CanonDR4', substr($$dataPt, $pos, $dirLen));
}
# version 4 header is 32 bytes (int32u[8])
if ($dirLen < 32) {
$err = 1;
} else {
SetByteOrder(substr($$dataPt, $pos, 2)) or $err = 1;
# process the DR4 header
my %hdrInfo = (
DataPt => $dataPt,
DirStart => $pos,
DirLen => 32,
DirName => 'DR4Header',
);
my $hdrTable = GetTagTable('Image::ExifTool::CanonVRD::DR4Header');
if ($outfile) {
my $hdr = $et->WriteDirectory(\%hdrInfo, $hdrTable);
substr($$dataPt, $pos, 32) = $hdr if $hdr and length $hdr == 32;
} else {
$et->VerboseDir('DR4Header', undef, 32);
$et->ProcessDirectory(\%hdrInfo, $hdrTable);
}
# number of entries in the DR4 directory
$numEntries = Get32u($dataPt, $pos + 28);
$err = 1 if $dirLen < 36 + 28 * $numEntries;
}
$err and $et->Warn('Invalid DR4 directory'), return $outfile ? undef : 0;
if ($outfile) {
$newTags = $et->GetNewTagInfoHash($tagTablePtr);
} else {
$et->VerboseDir('DR4', $numEntries, $dirLen);
}
my $index;
for ($index=0; $index<$numEntries; ++$index) {
my ($val, @flg, $i);
my $entry = $pos + 36 + 28 * $index;
last if $entry + 28 > $dirEnd;
my $tag = Get32u($dataPt, $entry);
my $fmt = Get32u($dataPt, $entry + 4);
$flg[0] = Get32u($dataPt, $entry + 8);
$flg[1] = Get32u($dataPt, $entry + 12);
$flg[2] = Get32u($dataPt, $entry + 16);
my $off = Get32u($dataPt, $entry + 20) + $pos;
my $len = Get32u($dataPt, $entry + 24);
next if $off + $len >= $dirEnd;
my $format = $vrdFormat{$fmt};
if (not $format) {
$val = unpack 'H*', substr($$dataPt, $off, $len);
$format = 'undef';
} elsif ($format eq 'double' and $len eq 8) {
# avoid teeny weeny values
$val = ReadValue($dataPt, $off, $format, undef, $len);
$val = 0 if abs($val) < 1e-100;
}
if ($outfile) {
# write (binary data) subdirectory if it exists
my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag);
if ($tagInfo and $$tagInfo{SubDirectory}) {
my %subdirInfo = (
DataPt => $dataPt,
DirStart => $off,
DirLen => $len,
DirName => $$tagInfo{Name},
);
my $subTablePtr = GetTagTable($$tagInfo{SubDirectory}{TagTable});
my $saveChanged = $$et{CHANGED};
my $dat = $et->WriteDirectory(\%subdirInfo, $subTablePtr);
if (defined $dat and length($dat) == $len) {
substr($$dataPt, $off, $len) = $dat;
} else {
$$et{CHANGED} = $saveChanged; # didn't change anything after all
}
} else {
# loop through main tag and flags (don't yet consider flag 2)
for ($i=-1; $i<2; ++$i) {
$tagInfo = $$newTags{$i>=0 ? sprintf('0x%x.%d',$tag,$i) : $tag};
next unless $tagInfo;
if ($i >= 0) {
$off = $entry + 8 + 4 * $i;
$format = 'int32u';
$len = 4;
undef $val;
}
$val = ReadValue($dataPt, $off, $format, undef, $len) unless defined $val;
my $nvHash;
my $newVal = $et->GetNewValue($tagInfo, \$nvHash);
if ($et->IsOverwriting($nvHash, $val) and defined $newVal) {
my $count = int($len / Image::ExifTool::FormatSize($format));
my $rtnVal = WriteValue($newVal, $format, $count, $dataPt, $off);
if (defined $rtnVal) {
$et->VerboseValue("- CanonVRD:$$tagInfo{Name}", $val);
$et->VerboseValue("+ CanonVRD:$$tagInfo{Name}", $newVal);
++$$et{CHANGED};
}
}
}
}
next;
}
$et->HandleTag($tagTablePtr, $tag, $val,
DataPt => $dataPt,
DataPos => $dataPos,
Start => $off,
Size => $len,
Index => $index,
Format => $format,
# $flg[0] is on/off flag
# $flg[1] "is default" flag?
# $flg[2] changed to 0 when some unsharp mask settings were changed
Extra => ", fmt=$fmt flags=" . join(',', @flg),
);
foreach $i (0..2) {
my $flagID = sprintf('0x%x.%d', $tag, $i);
$et->HandleTag($tagTablePtr, $flagID, $flg[$i]) if $$tagTablePtr{$flagID};
}
}
return 1 unless $isWriting;
return substr($$dataPt, $pos, $dirLen) unless $raf;
return 1 if Write($outfile, substr($$dataPt, $pos, $dirLen));
return -1;
}
#------------------------------------------------------------------------------
# Read/write Canon VRD file
# Inputs: 0) ExifTool object reference, 1) dirInfo reference
# Returns: 1 if this was a Canon VRD file, 0 otherwise, -1 on write error
sub ProcessVRD($$)
{
my ($et, $dirInfo) = @_;
my $raf = $$dirInfo{RAF};
my $buff;
my $num = $raf->Read($buff, 0x1c);
# initialize write directories if necessary
$et->InitWriteDirs(\%vrdMap, 'XMP') if $$dirInfo{OutFile};
if (not $num and $$dirInfo{OutFile}) {
# create new VRD file from scratch
my $newVal = $et->GetNewValue('CanonVRD');
if ($newVal) {
$et->VPrint(0, " Writing CanonVRD as a block\n");
Write($$dirInfo{OutFile}, $newVal) or return -1;
$$et{DidCanonVRD} = 1;
++$$et{CHANGED};
} else {
# allow VRD to be created from individual tags
if ($$et{ADD_DIRS}{CanonVRD}) {
my $newVal = '';
if (ProcessCanonVRD($et, { OutFile => \$newVal }) > 0) {
Write($$dirInfo{OutFile}, $newVal) or return -1;
++$$et{CHANGED};
return 1;
}
}
$et->Error('No CanonVRD information to write');
}
} else {
$num == 0x1c or return 0;
$buff =~ /^CANON OPTIONAL DATA\0/ or return 0;
$et->SetFileType();
$$dirInfo{DirName} = 'CanonVRD'; # set directory name for verbose output
my $result = ProcessCanonVRD($et, $dirInfo);
return $result if $result < 0;
$result or $et->Warn('Format error in VRD file');
}
return 1;
}
#------------------------------------------------------------------------------
# Write VRD data record as a block
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
# Returns: VRD data block (may be empty if no VRD data)
# Notes: Increments ExifTool CHANGED flag if changed
sub WriteCanonVRD($$;$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
$et or return 1; # allow dummy access
my $nvHash = $et->GetNewValueHash($Image::ExifTool::Extra{CanonVRD});
my $val = $et->GetNewValue($nvHash);
$val = '' unless defined $val;
return undef unless $et->IsOverwriting($nvHash, $val);
++$$et{CHANGED};
return $val;
}
#------------------------------------------------------------------------------
# Read/write CanonVRD information (from VRD file or VRD trailer)
# Inputs: 0) ExifTool object reference, 1) dirInfo reference
# Returns: 1 on success, 0 not valid VRD, or -1 error writing
# - updates DataPos to point to start of CanonVRD information
# - updates DirLen to existing trailer length
sub ProcessCanonVRD($$;$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
my $raf = $$dirInfo{RAF};
my $offset = $$dirInfo{Offset} || 0;
my $outfile = $$dirInfo{OutFile};
my $dataPt = $$dirInfo{DataPt};
my $verbose = $et->Options('Verbose');
my $out = $et->Options('TextOut');
my ($buff, $created, $err, $blockLen, $blockType, %didDir, $fromFile);
#
# The CanonVRD trailer has a 0x1c-byte header and a 0x40-byte footer,
# each beginning with "CANON OPTIONAL DATA\0" and containing an int32u
# giving the size of the contained data (at byte 0x18 and 0x14 respectively)
#
if ($raf) {
$fromFile = 1;
} else {
unless ($dataPt) {
return 1 unless $outfile;
# create blank VRD data from scratch
my $blank = $blankHeader . $blankFooter;
$dataPt = \$blank;
$verbose and print $out " Creating CanonVRD trailer\n";
$created = 1;
}
$raf = new File::RandomAccess($dataPt);
}
# read and validate the footer
$raf->Seek(-0x40-$offset, 2) or return 0;
$raf->Read($buff, 0x40) == 0x40 or return 0;
$buff =~ /^CANON OPTIONAL DATA\0(.{4})/s or return 0;
my $dirLen = unpack('N', $1) + 0x5c; # size including header+footer
# read and validate the header
unless ($dirLen < 0x80000000 and
$raf->Seek(-$dirLen, 1) and
$raf->Read($buff, 0x1c) == 0x1c and
$buff =~ /^CANON OPTIONAL DATA\0/ and
$raf->Seek(-0x1c, 1))
{
$et->Warn('Bad CanonVRD trailer');
return 0;
}
# set variables returned in dirInfo hash
$$dirInfo{DataPos} = $raf->Tell();
$$dirInfo{DirLen} = $dirLen;
if ($outfile and ref $outfile eq 'SCALAR' and not length $$outfile) {
# write directly to outfile to avoid duplicating data in memory
$$outfile = $$dataPt unless $fromFile;
# TRICKY! -- copy to outfile memory buffer and edit in place
# (so we must disable all Write() calls for this case)
$dataPt = $outfile;
}
if ($fromFile) {
$dataPt = \$buff unless $dataPt;
# read VRD data into memory if necessary
unless ($raf->Read($$dataPt, $dirLen) == $dirLen) {
$$dataPt = '' if $outfile and $outfile eq $dataPt;
$et->Warn('Error reading CanonVRD data');
return 0;
}
}
# exit quickly if writing and no CanonVRD tags are being edited
if ($outfile and not exists $$et{EDIT_DIRS}{CanonVRD}) {
print $out "$$et{INDENT} [nothing changed]\n" if $verbose;
return 1 if $outfile eq $dataPt;
return Write($outfile, $$dataPt) ? 1 : -1;
}
my $vrdType = 'VRD';
if ($outfile) {
$verbose and not $created and print $out " Rewriting CanonVRD trailer\n";
# delete CanonVRD information if specified
my $doDel = $$et{DEL_GROUP}{CanonVRD};
unless ($doDel) {
$doDel = 1 if $$et{DEL_GROUP}{Trailer} and $$et{FILE_TYPE} ne 'VRD';
unless ($doDel) {
# also delete if writing as a block (will get added back again later)
if ($$et{NEW_VALUE}{$Image::ExifTool::Extra{CanonVRD}}) {
# delete if this isn't version 4
$doDel = 1 unless $$dataPt =~ /^.{28}\xff\xff\0\xf7/s;
}
if ($$et{NEW_VALUE}{$Image::ExifTool::Extra{CanonDR4}} and not $doDel) {
# delete if this is version 4
$doDel = 1 if $$dataPt =~ /^.{28}\xff\xff\0\xf7/s;
}
}
}
if ($doDel) {
if ($$et{FILE_TYPE} eq 'VRD') {
my $newVal = $et->GetNewValue('CanonVRD');
if ($newVal) {
$verbose and print $out " Writing CanonVRD as a block\n";
if ($outfile eq $dataPt) {
$$outfile = $newVal;
} else {
Write($outfile, $newVal) or return -1;
}
$$et{DidCanonVRD} = 1;
++$$et{CHANGED};
} else {
$et->Error("Can't delete all CanonVRD information from a VRD file");
}
} else {
$verbose and print $out " Deleting CanonVRD trailer\n";
$$outfile = '' if $outfile eq $dataPt;
++$$et{CHANGED};
}
return 1;
}
# write now and return if CanonVRD was set as a block
my $val = $et->GetNewValue('CanonVRD');
unless ($val) {
$val = $et->GetNewValue('CanonDR4');
$vrdType = 'DR4' if $val;
}
if ($val) {
$verbose and print $out " Writing Canon$vrdType as a block\n";
# must wrap DR4 data with the VRD header/footer and edit record
$val = WrapDR4($val) if $vrdType eq 'DR4';
if ($outfile eq $dataPt) {
$$outfile = $val;
} else {
Write($outfile, $val) or return -1;
}
$$et{DidCanonVRD} = 1;
++$$et{CHANGED};
return 1;
}
} elsif ($verbose or $$et{HTML_DUMP}) {
$et->DumpTrailer($dirInfo) if $$dirInfo{RAF};
}
$tagTablePtr = GetTagTable('Image::ExifTool::CanonVRD::Main');
# validate VRD trailer and get position and length of edit record
SetByteOrder('MM'); # VRD header/footer is big-endian
my $pos = 0x1c; # start at end of header
# loop through the VRD blocks
for (;;) {
my $end = $dirLen - 0x40; # end of last VRD block (and start of footer)
if ($pos + 8 > $end) {
last if $pos == $end;
$blockLen = $end; # mark as invalid
} else {
$blockType = Get32u($dataPt, $pos);
$blockLen = Get32u($dataPt, $pos + 4);
}
$vrdType = 'DR4' if $blockType eq 0xffff00f7;
$pos += 8; # move to start of block
if ($pos + $blockLen > $end) {
$et->Warn('Possibly corrupt CanonVRD block');
last;
}
if ($verbose > 1 and not $outfile) {
printf $out " CanonVRD block 0x%.8x ($blockLen bytes at offset 0x%x)\n",
$blockType, $pos + $$dirInfo{DataPos};
if ($verbose > 2) {
my %parms = (
Start => $pos,
Addr => $pos + $$dirInfo{DataPos},
Out => $out,
Prefix => $$et{INDENT},
);
$parms{MaxLen} = $verbose == 3 ? 96 : 2048 if $verbose < 5;
HexDump($dataPt, $blockLen, %parms);
}
}
my $tagInfo = $$tagTablePtr{$blockType};
unless ($tagInfo) {
unless ($et->Options('Unknown')) {
$pos += $blockLen; # step to next block
next;
}
my $name = sprintf('CanonVRD_0x%.8x', $blockType);
my $desc = $name;
$desc =~ tr/_/ /;
$tagInfo = {
Name => $name,
Description => $desc,
Binary => 1,
};
AddTagToTable($tagTablePtr, $blockType, $tagInfo);
}
if ($$tagInfo{SubDirectory}) {
my $subTablePtr = GetTagTable($$tagInfo{SubDirectory}{TagTable});
my %subdirInfo = (
DataPt => $dataPt,
DataLen => length $$dataPt,
DataPos => $$dirInfo{DataPos},
DirStart => $pos,
DirLen => $blockLen,
DirName => $$tagInfo{Name},
Parent => 'CanonVRD',
OutFile => $outfile,
);
if ($outfile) {
# set flag indicating we did this directory
$didDir{$$tagInfo{Name}} = 1;
my ($dat, $diff);
if ($$et{NEW_VALUE}{$tagInfo}) {
# write as a block
$et->VPrint(0, "Writing $$tagInfo{Name} as a block\n");
$dat = $et->GetNewValue($tagInfo);
$dat = '' unless defined $dat;
++$$et{CHANGED};
} else {
$dat = $et->WriteDirectory(\%subdirInfo, $subTablePtr);
}
# update data with new directory
if (defined $dat) {
if (length $dat or $$et{FILE_TYPE} !~ /^(CRW|VRD)$/) {
# replace with new block (updating the block length word)
substr($$dataPt, $pos-4, $blockLen+4) = Set32u(length $dat) . $dat;
} else {
# remove block totally (CRW/VRD files only)
substr($$dataPt, $pos-8, $blockLen+8) = '';
}
# make necessary adjustments if block changes length
if (($diff = length($$dataPt) - $dirLen) != 0) {
$pos += $diff;
$dirLen += $diff;
# update the new VRD length in the header/footer
Set32u($dirLen - 0x5c, $dataPt, 0x18);
Set32u($dirLen - 0x5c, $dataPt, $dirLen - 0x2c);
}
}
} else {
# extract as a block if requested
$et->ProcessDirectory(\%subdirInfo, $subTablePtr);
}
} else {
$et->HandleTag($tagTablePtr, $blockType, substr($$dataPt, $pos, $blockLen));
}
$pos += $blockLen; # step to next block
}
if ($outfile) {
# create XMP block if necessary (CRW/VRD files only)
if ($$et{ADD_DIRS}{CanonVRD} and not $didDir{XMP}) {
my $subTablePtr = GetTagTable('Image::ExifTool::XMP::Main');
my $dat = $et->WriteDirectory({ Parent => 'CanonVRD' }, $subTablePtr);
if ($dat) {
my $blockLen = length $dat;
substr($$dataPt, -0x40, 0) = Set32u(0xffff00f6) . Set32u(length $dat) . $dat;
$dirLen = length $$dataPt;
# update the new VRD length in the header/footer
Set32u($dirLen - 0x5c, $dataPt, 0x18);
Set32u($dirLen - 0x5c, $dataPt, $dirLen - 0x2c);
}
}
# write CanonVRD trailer unless it is empty
if (length $$dataPt) {
Write($outfile, $$dataPt) or $err = 1 unless $outfile eq $dataPt;
} else {
$verbose and print $out " Deleting CanonVRD trailer\n";
}
} elsif ($vrdType eq 'VRD' and (($$et{TAGS_FROM_FILE} and
not $$et{EXCL_TAG_LOOKUP}{canonvrd}) or $$et{REQ_TAG_LOOKUP}{canonvrd}))
{
# extract CanonVRD block if copying tags, or if requested (and not DR4 info)
$et->FoundTag('CanonVRD', $buff);
}
undef $buff;
return $err ? -1 : 1;
}
1; # end
__END__
=head1 NAME
Image::ExifTool::CanonVRD - Read/write Canon VRD and DR4 information
=head1 SYNOPSIS
This module is used by Image::ExifTool
=head1 DESCRIPTION
This module contains definitions required by Image::ExifTool to read and
write VRD and DR4 Recipe Data information as written by the Canon Digital
Photo Professional software. This information is written to VRD and DR4
files, and as a trailer in JPEG, CRW, CR2 and TIFF images.
=head1 AUTHOR
Copyright 2003-2017, Phil Harvey (phil at owl.phy.queensu.ca)
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 ACKNOWLEDGEMENTS
Thanks to Bogdan and Gert Kello for decoding some tags.
=head1 SEE ALSO
L<Image::ExifTool::TagNames/CanonVRD Tags>,
L<Image::ExifTool(3pm)|Image::ExifTool>
=cut
|