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 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 7 December 2008), see www.w3.org" />
<title>RMagick 2.13.1: class Image (instance methods p-w)</title>
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<meta name="GENERATOR" content="Quanta Plus" />
<meta name="Copyright" content=
"Copyright (C) 2006 by Timothy P. Hunter" />
<link rel="stylesheet" type="text/css" href="css/doc.css" />
<script type="text/javascript" src="scripts/doc.js">
</script>
<script type="text/javascript">
//<![CDATA[
<!-- Pre-load this image so that the browser knows how big it is. -->
<!-- Begin
flower_hat = new Image();
flower_hat.src = "ex/images/Flower_Hat.jpg";
// End -->
//]]>
</script>
<style type="text/css">
/*<![CDATA[*/
/*
* This style is used for the list of PreviewType
* constants defined for the preview method, below.
*/
#prevlist ul {
float: left;
list-style: none;
margin-bottom: 0;
}
/*
* This style is used for the list of QuantumOperator
* constants defined for the quantum_operator method, below.
*
*/
#quantum_op_list {
list-style-type: none;
}
/*]]>*/
</style>
</head>
<body>
<h6 id="header">RMagick 2.13.1 User's Guide and Reference</h6>
<div class="nav">
« <a href="image2.html">Prev</a> | <a href=
"index.html">Contents</a> | <a href=
"draw.html">Next</a> »
</div>
<h1>class Image <span class="superclass">< Object</span>
(instance methods p-w)<br />
<span class="mixin">mixes in Comparable</span></h1>
<div id="toc">
<h2>Table of Contents</h2>
<h3>instance methods</h3>
<div>
<div class="toccol">
<ul>
<li><a href="#palette_q">palette?</a></li>
<li><a href=
"#paint_transparent">paint_transparent</a></li>
<li><a href="#pixel_color">pixel_color</a></li>
<li><a href="#polaroid">polaroid</a></li>
<li><a href="#posterize">posterize</a></li>
<li><a href="#preview">preview</a></li>
<li><a href="#profile_bang">profile!</a></li>
<li><a href="#properties">properties</a></li>
<li><a href="#quantize">quantize</a></li>
<li><a href="#quantum_operator">quantum_operator</a></li>
<li><a href="#radial_blur">radial_blur</a></li>
<li><a href=
"#radial_blur_channel">radial_blur_channel</a></li>
<li><a href="#raise">raise</a></li>
<li><a href=
"#random_threshold_channel">random_threshold_channel</a></li>
<li><a href="#recolor">recolor</a></li>
<li><a href="#reduce_noise">reduce_noise</a></li>
<li><a href="#remap">remap</a></li>
<li><a href="#resample">resample</a></li>
<li><a href="#resize">resize</a></li>
<li><a href="#resize_bang">resize!</a></li>
<li><a href="#resize_to_fill">resize_to_fill</a></li>
<li><a href=
"#resize_to_fill_bang">resize_to_fill!</a></li>
<li><a href="#resize_to_fit">resize_to_fit</a></li>
<li><a href="#resize_to_fit_bang">resize_to_fit!</a></li>
<li><a href="#roll">roll</a></li>
<li><a href="#rotate">rotate</a></li>
<li><a href="#rotate_bang">rotate!</a></li>
</ul>
</div>
<div class="toccol">
<ul>
<li><a href="#sample">sample</a></li>
<li><a href="#sample_bang">sample!</a></li>
<li><a href="#scale">scale</a></li>
<li><a href="#scale_bang">scale!</a></li>
<li><a href="#segment">segment</a></li>
<li><a href=
"#selective_blur_channel">selective_blur_channel</a></li>
<li><a href="#separate">separate</a></li>
<li><a href="#sepiatone">sepiatone</a></li>
<li><a href=
"#set_channel_depth">set_channel_depth</a></li>
<li><a href="#shade">shade</a></li>
<li><a href="#shadow">shadow</a></li>
<li><a href="#sharpen">sharpen</a></li>
<li><a href="#sharpen_channel">sharpen_channel</a></li>
<li><a href="#shave">shave</a></li>
<li><a href="#shave_bang">shave!</a></li>
<li><a href="#shear">shear</a></li>
<li><a href=
"#sigmoidal_contrast_channel">sigmoidal_contrast_channel</a></li>
<li><a href="#signature">signature</a></li>
<li><a href="#sketch">sketch</a></li>
<li><a href="#solarize">solarize</a></li>
<li><a href="#sparse_color">sparse_color</a></li>
<li><a href="#splice">splice</a></li>
<li><a href="#spread">spread</a></li>
<li><a href="#stegano">stegano</a></li>
<li><a href="#stereo">stereo</a></li>
<li><a href="#store_pixels">store_pixels</a></li>
<li><a href="#strip_bang">strip!</a></li>
</ul>
</div>
<div class="toccol">
<ul>
<li><a href="#swirl">swirl</a></li>
<li><a href="#sync_profiles">sync_profiles</a></li>
<li><a href=
"#texture_fill_to_border">texture_fill_to_border</a></li>
<li><a href=
"#texture_floodfill">texture_floodfill</a></li>
<li><a href="#threshold">threshold</a></li>
<li><a href="#thumbnail">thumbnail</a></li>
<li><a href="#thumbnail_bang">thumbnail!</a></li>
<li><a href="#to_blob">to_blob</a></li>
<li><a href="#to_color">to_color</a></li>
<li><a href="#transparent">transparent</a></li>
<li><a href=
"#transparent_chroma">transparent_chroma</a></li>
<li><a href="#transpose">transpose</a></li>
<li><a href="#transpose_bang">transpose!</a></li>
<li><a href="#transverse">transverse</a></li>
<li><a href="#transverse_bang">transverse!</a></li>
<li><a href="#trim">trim</a></li>
<li><a href="#trim_bang">trim!</a></li>
<li><a href="#unique_colors">unique_colors</a></li>
<li><a href="#unsharp_mask">unsharp_mask</a></li>
<li><a href=
"#unsharp_mask_channel">unsharp_mask_channel</a></li>
<li><a href="#view">view</a></li>
<li><a href="#vignette">vignette</a></li>
<li><a href="#watermark">watermark</a></li>
<li><a href="#wave">wave</a></li>
<li><a href="#wet_floor">wet_floor</a></li>
<li><a href="#white_threshold">white_threshold</a></li>
<li><a href="#write">write</a></li>
</ul>
</div>
</div>
</div>
<h2 class="methods">instance methods</h2>
<div class="sig">
<h3 id="palette_q">palette?</h3>
<p><span class="arg">img</span>.palette? -> true or
false</p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Returns true if the image is <a href=
"constants.html#ClassType">PseudoClass</a> and has 256 unique
colors or less.</p>
<h4>Returns</h4>
<p>true or false</p>
<h4>Magick API</h4>
<p>IsPaletteImage</p>
</div>
<div class="sig">
<h3 id="paint_transparent">paint_transparent</h3>
<p><span class="arg">img</span>.paint_transparent(<span class=
"arg">color</span>, <span class=
"arg">opacity</span>=TransparentOpacity, <span class=
"arg">invert</span>=false, <span class=
"arg">fuzz</span>=<span class="arg">img</span>.fuzz) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Changes the opacity value of all the pixels that match
<span class="arg">color</span> to the value specified by
<span class="arg">opacity</span>. If <span class=
"arg">invert</span> is true, changes the pixels that don't
match <span class="arg">color</span>.</p>
<h4>Arguments</h4>
<dl>
<dt>color</dt>
<dd>Either a <a href="imusage.html#color_names">color
name</a> or a <a href="struct.html#Pixel">pixel</a>.</dd>
<dt>opacity</dt>
<dd>The new opacity value, either an <a href=
"constants.html#Opacity">opacity</a> value or a number
between 0 and QuantumRange. The default is
TransparentOpacity.</dd>
<dt>invert</dt>
<dd>If true, changes all the pixels that are <em>not</em> the
target color.</dd>
<dt>fuzz</dt>
<dd>By default the pixel must match exactly, but you can
specify a tolerance level by passing a positive value.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>See also</h4>
<p><a href="image2.html#matte_replace">matte_replace</a>,
<a href="draw.html#matte">Draw#matte</a>, <a href=
"#transparent">transparent</a></p>
<h4>Magick API</h4>
<p>TransparentPaintImage</p>
</div>
<div class="sig">
<h3 id="pixel_color">pixel_color</h3>
<p><span class="arg">img</span>.pixel_color(<span class=
"arg">x</span>, <span class="arg">y</span>[, <span class=
"arg">new_color</span>]) -> <em>pixel</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Returns the color of the pixel at <span class=
"arg">x</span>, <span class="arg">y</span>. Optionally, changes
the color of the pixel to a new color.</p>
<p>If new_color is specified, pixel_color changes the image
type to DirectClass if necessary.</p>
<h4>Arguments</h4>
<dl>
<dt>x, y</dt>
<dd>The x- and y-coordinates of the pixel.</dd>
<dt>new_color</dt>
<dd>If specified, the pixel is set to this color. May be
either a <a href="imusage.html#color_names">color name</a> or
a <a href="struct.html#Pixel">Pixel</a>.</dd>
</dl>
<h4>Returns</h4>A <a href="struct.html#Pixel">Pixel</a> having
the RGB values of the specified pixel.
<h4>Example</h4>
<pre>
old = image.pixel_color(20,40,"white")
</pre>
<h4>Magick API</h4>
<p>AcquireImagePixels</p>
</div>
<div class="sig">
<h3 id="polaroid">polaroid</h3>
<p><span class="arg">img</span>.polaroid(angle=-5.0) [
<span class="arg">{ optional arguments }</span> ] ->
image</p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Produce an image that looks like a Polaroid® instant
picture. If the image has a "Caption" <a href=
"image1.html#aset">property</a>, the value is used as a
caption.</p>
<p>Optional arguments may be specified in a block associated
with the method. These arguments control the shadow color and
how the label is rendered. By default the shadow color is
gray75. To specify a different shadow color, use
<code>self.shadow_color</code>. To specify a different border
color (that is, the color of the image border) use
<code>self.border_color</code>. Both of these methods accept
either a <a href="imusage.html#color_names">color name</a> or a
<a href="struct.html#Pixel">Pixel</a> argument.</p>
<p>The following <a href="draw.html#annotate">annotate</a>
attributes control the label rendering: <a href=
"draw.html#align_eq">align</a>, <a href=
"draw.html#decorate_eq">decorate</a>, <a href=
"draw.html#density_eq">density</a>, <a href=
"draw.html#encoding_eq">encoding</a>, <a href=
"draw.html#fill_eq">fill</a>, <a href=
"draw.html#font_eq">font</a>, <a href=
"draw.html#font_family_eq">font_family</a>, <a href=
"draw.html#font_stretch_eq">font_stretch</a>, <a href=
"draw.html#font_style_eq">font_style</a>, <a href=
"draw.html#font_weight_eq">font_weight</a>, <a href=
"draw.html#gravity_eq">gravity</a>, <a href=
"draw.html#pointsize_eq">pointsize</a>, <a href=
"draw.html#stroke_eq">stroke</a>, <a href=
"draw.html#stroke_width_eq">stroke_width</a>, <a href=
"draw.html#text_antialias_eq">text_antialias</a>, <a href=
"draw.html#undercolor_eq">undercolor</a>.</p>
<pre>
img.polaroid do
self.shadow_color = "gray40"
self.pointsize = 12
end
</pre>
<h4>Arguments</h4>
<dl>
<dt>angle</dt>
<dd>The resulting image is rotated by this amount, measured
in degrees. The default is -5.0.</dd>
</dl>
<h4>Example</h4>
<p><a href="javascript:popup('polaroid.rb.html')"><img src=
"ex/polaroid.jpg" alt="polaroid example" /></a></p>
<h4>Magick API</h4>
<p>PolaroidImage</p>
<h4>See also</h4>
<p><a href=
"http://rmagick.rubyforge.org/Polaroid/polaroid.html">The
Polaroid Effect</a></p>
<h4>Notes</h4>
<p>"Polaroid" and the other names of products of Polaroid
Corporation are trademarks of Polaroid Corporation.</p>
</div>
<div class="sig">
<h3 id="posterize">posterize</h3>
<p><span class="arg">img</span>.posterize(<span class=
"arg">levels</span>=4, <span class="arg">dither</span>=false)
-> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Reduces the image to a limited number of
colors for a "poster" effect.</p>
<h4>Arguments</h4>
<dl>
<dt>levels</dt>
<dd><span class="imquote">Number of color levels allowed in
each channel. Very low values (2, 3, or 4) have the most
visible effect.</span> The default is 4.</dd>
<dt>dither</dt>
<dd>If true, dither the image. The default is false.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('posterize.rb.html')"><img src=
"ex/posterize.jpg" alt="posterize example" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/posterize.jpg'" title=
"Click to see the example script" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="image2.html#ordered_dither">ordered_dither</a>,
<a href="image3.html#quantize">quantize</a></p>
<h4>Magick API</h4>
<p>PosterizeImage</p>
</div>
<div class="sig">
<h3 id="preview">preview</h3>
<p><span class="arg">img</span>.preview(<span class=
"arg">preview</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Creates an image that contains 9 small versions of the
receiver image. The center image is the unchanged receiver. The
other 8 images are variations created by transforming the
receiver according to the specified preview type with varying
parameters.</p>
<p>A preview image is an easy way to "try out" a transformation
method.</p>
<h4>Arguments</h4>
<p>One of the following PreviewType constants:</p>
<div id="prevlist">
<ul>
<li>RotatePreview</li>
<li>ShearPreview</li>
<li>RollPreview</li>
<li>HuePreview</li>
<li>SaturationPreview</li>
<li>BrightnessPreview</li>
<li>GammaPreview</li>
<li>SpiffPreview</li>
<li>DullPreview</li>
<li>GrayscalePreview</li>
<li>QuantizePreview</li>
<li>DespecklePreview</li>
<li>ReduceNoisePreview</li>
<li>AddNoisePreview</li>
<li>SharpenPreview</li>
</ul>
<ul>
<li>BlurPreview</li>
<li>ThresholdPreview</li>
<li>EdgeDetectPreview</li>
<li>SpreadPreview</li>
<li>SolarizePreview</li>
<li>ShadePreview</li>
<li>RaisePreview</li>
<li>SegmentPreview</li>
<li>SwirlPreview</li>
<li>ImplodePreview</li>
<li>WavePreview</li>
<li>OilPaintPreview</li>
<li>CharcoalDrawingPreview</li>
<li>JPEGPreview</li>
</ul>
</div>
<div style="clear:both"></div>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>This half-size preview demonstrates the SolarizePreview
argument.</p>
<p><a href="javascript:popup('preview.rb.html')"><img src=
"ex/preview.jpg" alt="preview example" title=
"Click to see the example script" /></a></p>
<h4>Magick API</h4>
<p>PreviewImage</p>
</div>
<div class="sig">
<h3 id="profile_bang">profile!</h3>
<p><span class="arg">img</span>.profile!(<span class=
"arg">name</span>, <span class="arg">profile</span>) ->
<em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p><span class="imquote">Adds or removes a ICM, IPTC, or
generic profile from an image.</span> If <code>profile</code>
is <code>nil</code>, the specified profile is removed from the
image. Use <code>profile('*', nil)</code> to remove all
profiles from the image.</p>
<h4>Arguments</h4>
<dl>
<dt>name</dt>
<dd>The profile name, or "*" to represent all the profiles in
the image.</dd>
<dt>profile</dt>
<dd>The profile value, or <code>nil</code> to cause the
profile to be removed.</dd>
</dl>
<h4>Returns</h4>
<p>self</p>
<h4>See also</h4>
<p><a href="image1.html#add_profile">add_profile</a> and
<a href="image1.html#delete_profile">delete_profile</a> perform
very similar functions. However, <code>add_profile</code>
accepts the name of a profile file on disk instead of the
profile data itself and, if the file contains more than one
profile, will load all the profiles at once.</p>
<h4>Magick API</h4>
<p>ProfileImage</p>
<h4>Notes</h4>
<p>ImageMagick does not automatically remove profiles when
resizing images. If you are trying to make your JPEG thumbnail
images as small as possible, use <code>profile!</code> to
remove any profiles from the image as well. Also see <a href=
"#strip_bang">strip!</a></p>
</div>
<div class="sig">
<h3 id="properties">properties</h3>
<p><span class="arg">img</span>.properties <span class="arg">[
{|name,value| block} ]</span> -> <em>hash</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>If called with an associated block, <code>properties</code>
runs the block once for each property defined for the image.
The block arguments are the property name and its value. If
there is no block, <code>properties</code> returns a hash with
one element for each property. The hash key is the property
name and the associated value is the property value.</p>
<h4>Returns</h4>
<p>If called without a block, returns a hash, otherwise returns
<code>self</code>.</p>
<h4>See also</h4>
<p><a href="image1.html#aref">[ ]</a>, <a href=
"image1.html#aset">[ ]=</a></p>
<h4>Note</h4>
<p>The EXIF property is not created until the first time an
EXIF tag or entry number is referenced.</p>
</div>
<div class="sig">
<h3 id="quantize">quantize</h3>
<p><span class="arg">img</span>.quantize(<span class=
"arg">number_colors</span>=256, <span class=
"arg">colorspace</span>=RGBColorspace, <span class=
"arg">dither</span>=<code>RiemersmaDitherMethod</code>,
<span class="arg">tree_depth</span>=0, <span class=
"arg">measure_error</span>=<code>false</code>) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Analyzes the colors within a reference image
and chooses a fixed number of colors to represent the image.
The goal of the algorithm is to minimize the difference between
the input and output image while minimizing the processing
time.</p>
<h4>Arguments</h4>
<dl>
<dt>number_colors</dt>
<dd>The maximum number of colors in the result image. Must be
<= <a href=
"constants.html#Miscellaneous_constants">QuantumRange</a>.</dd>
<dt>colorspace</dt>
<dd class="imquote">The <a href=
"constants.html#ColorspaceType">colorspace</a> to quantize
in. Color reduction, by default, takes place in the RGB color
space. Empirical evidence suggests that distances
in color spaces such as YUV or YIQ correspond
to perceptual color differences more closely
than do distances in RGB space. The Transparent color
space behaves uniquely in that it preserves the matte channel
of the image if it exists.</dd>
<dt>dither</dt>
<dd>A <a href="constants.html#DitherMethod">DitherMethod</a>
value. Set to <code>NoDitherMethod</code> to disable
dithering. See the documentation for the <a href=
"http://redux.imagemagick.org/script/command-line-options.php#dither">
ImageMagick -dither option</a> for more information.</dd>
<dt>tree_depth</dt>
<dd><span class="imquote">The tree depth to use while
quantizing. The values 0 and 1 support automatic tree depth
determination. The tree depth may be forced via values
ranging from 2 to 8. The ideal tree depth depends on the
characteristics of the input image, and may be determined
through experimentation.</span> See the documentation for the
<a href=
"http://redux.imagemagick.org/script/command-line-options.php#treedepth">
ImageMagick -treedepth option</a> for more information.</dd>
<dt>measure_error</dt>
<dd class="imquote">Set to <code>true</code> to calculate
quantization errors when quantizing the image.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>See the example for <a href=
"image1.html#colorize">colorize</a>.</p>
<h4>See also</h4>
<p><a href="image2.html#ordered_dither">ordered_dither</a>,
<a href="image3.html#posterize">posterize</a>, <a href=
"ilist.html#quantize">ImageList#quantize</a></p>
<h4>Magick API</h4>
<p>QuantizeImage</p>
</div>
<div class="sig">
<h3 id="quantum_operator">quantum_operator</h3>
<p><span class="arg">img</span>.quantum_operator(<span class=
"arg">operator</span>, <span class="arg">rvalue</span>,
<span class="arg">channel</span>=AllChannels) ->
<em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Performs the requested integer arithmetic operation on the
selected channel of the image. This method allows simple
arithmetic operations on the component values of all pixels in
an image. Of course, you could also do this in Ruby using
<a href="image2.html#get_pixels">get_pixels</a> and <a href=
"#store_pixels">store_pixels</a>, or <a href="#view">view</a>,
but <code>quantum_operator</code> will be faster, especially
for large numbers of pixels, since it does not need to convert
the pixels from C to Ruby.</p>
<h4>Arguments</h4>
<dl>
<dt>operator</dt>
<dd>
One of the following <code>QuantumExpressionOperator</code>
constants:
<ul id="quantum_op_list">
<li>AddQuantumOperator</li>
<li><code>AndQuantumOperator</code></li>
<li><code>DivideQuantumOperator</code></li>
<li><code>LShiftQuantumOperator</code></li>
<li><code>MaxQuantumOperator</code></li>
<li><code>MinQuantumOperator</code></li>
<li><code>MultiplyQuantumOperator</code></li>
<li><code>OrQuantumOperator</code></li>
<li><code>RShiftQuantumOperator</code></li>
<li><code>SubtractQuantumOperator</code></li>
<li><code>XorQuantumOperator</code></li>
<li><code>PowQuantumOperator</code></li>
<li><code>LogQuantumOperator</code></li>
<li><code>ThresholdQuantumOperator</code></li>
<li><code>ThresholdBlackQuantumOperator</code></li>
<li><code>ThresholdWhiteQuantumOperator</code></li>
<li><code>GaussianNoiseQuantumOperator</code></li>
<li><code>ImpulseNoiseQuantumOperator</code></li>
<li><code>LaplacianNoiseQuantumOperator</code></li>
<li><code>MultiplicativeNoiseQuantumOperator</code></li>
<li><code>PoissonNoiseQuantumOperator</code></li>
<li><code>UniformNoiseQuantumOperator</code></li>
<li><code>CosineQuantumOperator</code></li>
<li><code>SineQuantumOperator</code></li>
<li><code>AddModulusQuantumOperator</code></li>
</ul>Some of these constants are not defined in older
releases of ImageMagick. To see which ones are defined,
enter this statement in IRB:
<pre>
Magick::QuantumExpressionOperator.values {|v| puts v}
</pre>
</dd>
<dt>rvalue</dt>
<dd>a <code>Numeric</code> operation rvalue.</dd>
<dt>channel</dt>
<dd>A <a href="constants.html#ChannelType">ChannelType</a>
value. The default is to operate on the R, G. and B
channels.</dd>
</dl>
<h4>Returns</h4>
<p>self</p>
<h4>Example</h4>
<p>Divide the red component of all the pixels in the image by
2:</p>
<pre>
img.quantum_operator(DivideQuantumOperator, 2, RedChannel)
</pre>
<h4>See also</h4>
<p><a href=
"image2.html#function_channel">function_channel</a></p>
<p>The <a href="struct.html#view">Image:View</a> class supports
operations on individual pixels and collections of pixels, as
well as operations on channels within pixels. See <a href=
"#view">view</a>, below.</p>
<h4>Magick API</h4>
<p>EvaluateImageChannel</p>
</div>
<div class="sig">
<h3 id="radial_blur">radial_blur</h3>
<p><span class="arg">img</span>.radial_blur(<span class=
"arg">float</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Applies a radial blur to the image.</p>
<h4>Arguments</h4>
<dl>
<dt>angle</dt>
<dd>Amount of blur, in degrees</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('radial_blur.rb.html')"><img src=
"ex/radial_blur.jpg" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/radial_blur.jpg'" alt="radial_blur example"
title="Click to see the example script" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="image1.html#blur_image">blur_image</a>, <a href=
"image2.html#gaussian_blur">gaussian_blur</a>, <a href=
"image2.html#motion_blur">motion_blur</a>, <a href=
"#radial_blur_channel">radial_blur_channel</a>, <a href=
"#selective_blur_channel">selective_blur_channel</a></p>
<h4>Magick API</h4>
<p>RadialBlurImage</p>
</div>
<div class="sig">
<h3 id="radial_blur_channel">radial_blur_channel</h3>
<p><span class=
"arg">img</span>.radial_blur_channel(<span class="arg">float</span>
[, <span class="arg">channel</span>...]) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Applies a radial blur to the selected image channels.</p>
<h4>Arguments</h4>
<dl>
<dt>angle</dt>
<dd>Amount of blur, in degrees</dd>
<dt>channel...</dt>
<dd>0 or more <a href=
"constants.html#ChannelType">ChannelType</a> arguments. If no
channels are specified, all the channels are blurred.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>See also</h4>
<p><a href="#radial_blur">radial_blur</a></p>
<h4>Magick API</h4>
<p>RadialBlurImageChannel</p>
</div>
<div class="sig">
<h3 id="raise">raise</h3>
<p><span class="arg">img</span>.raise(<span class=
"arg">width</span>=6, <span class="arg">height</span>=6,
<span class="arg">raised</span>=<code>true</code>) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Creates a simulated three-dimensional
button-like effect by lightening and darkening the edges of the
image.</p>
<h4>Arguments</h4>
<dl>
<dt>width</dt>
<dd>The width of the raised edge in pixels. The default is
6.</dd>
<dt>height</dt>
<dd>The height of the raised edge in pixels. The default is
6.</dd>
<dt>raised</dt>
<dd>If <code>true</code>, the image is raised, otherwise
lowered.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('raise.rb.html')"><img src="ex/raise.jpg"
onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/raise.jpg'" alt="raise example" title=
"Click to see the example script" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>Magick API</h4>
<p>RaiseImage</p>
</div>
<div class="sig">
<h3 id="random_threshold_channel">random_threshold_channel</h3>
<p><span class="arg">img</span>.random_threshold_channel(
<span class="arg">thresholds</span>, [<span class=
"arg">channel</span>...] ) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Changes the value of individual pixels based
on the intensity of each pixel compared to a random threshold.
The result is a low-contrast, two color image.</p>
<h4>Arguments</h4>
<dl>
<dt>thresholds</dt>
<dd><span class="imquote">A geometry string containing
LOWxHIGH thresholds.</span> The string is in the form `XxY'.
The Y value may be omitted, in which case it is assigned the
value QuantumRange-X. If an % appears in the string then the
values are assumed to be percentages of QuantumRange.
<span class="imquote">If the string contains 2x2, 3x3, or
4x4, then an ordered dither of order 2, 3, or 4 will be
performed instead.</span> A <a href=
"struct.html#Geometry">Geometry</a> object may be used as
well.</dd>
<dt>channel...</dt>
<dd>0 or more <a href=
"constants.html#ChannelType">ChannelType</a> arguments. If no
channels are specified, all the channels are
thresholded.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<pre>
geom = Geometry.new(QuantumRange/2)
random_threshold_channel(geom, RedChannel)
</pre>
<p class="rollover"><a href=
"javascript:popup('random_threshold_channel.rb.html')"><img src="ex/random_threshold_channel.jpg"
alt="random_threshold_channel example" title=
"Click to see the example script" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/random_threshold_channel.jpg'" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href=
"image1.html#adaptive_threshold">adaptive_threshold</a>,
<a href="image1.html#bilevel_channel">bilevel_channel</a>,
<a href="#threshold">threshold</a></p>
<h4>Magick API</h4>
<p>RandomThresholdImageChannel</p>
</div>
<div class="sig">
<h3 id="recolor">recolor</h3>
<p><span class="arg">img</span>.recolor(<span class=
"arg">color_matrix</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Use this method to <span class="imquote">translate, scale,
shear, or rotate image colors. Although you can use variable
sized matrices, typically you use a 5×5 for an RGBA image
and a 6×6 for CMYKA. Populate the last row with
normalized values to translate.</span></p>
<h4>Arguments</h4>
<p>An array of Float values representing the recolor
matrix.</p>
<h4>Magick API</h4>
<p>RecolorImage</p>
</div>
<div class="sig">
<h3 id="reduce_noise">reduce_noise</h3>
<p><span class="arg">img</span>.reduce_noise(<span class=
"arg">radius</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Smooths the contours of an image while still
preserving edge information. The algorithm works by replacing
each pixel with its neighbor closest in value.</p>
<h4>Arguments</h4>
<dl>
<dt>radius</dt>
<dd class="imquote">A neighbor is defined by radius. Use a
radius of 0 and <code>reduce_noise</code> selects a suitable
radius for you.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>The left side of the image has been modified by <a href=
"#Image.add_noise"><code>add_noise</code></a>. The right side
has been filtered by <code>reduce_noise(0)</code>.</p>
<p><a href="javascript:popup('reduce_noise.rb.html')"><img src=
"ex/reduce_noise.jpg" title="Click to see the example script"
alt="reduce_noise example" /></a></p>
<h4>See also</h4>
<p><a href="image2.html#enhance">enhance</a>, <a href=
"#unsharp_mask">unsharp_mask</a></p>
<h4>Magick API</h4>
<p>ReduceNoiseImage</p>
</div>
<div class="sig">
<h3 id="remap">remap</h3>
<p><span class="arg">img</span>.remap(<span class=
"arg">remap_image</span>, <span class=
"arg">dither</span>=RiemersmaDitherMethod) ->
<em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Reduce the number of colors in <span class="arg">img</span>
to the colors used by <span class="arg">remap_image</span>. If
a dither method is specified <span class="imquote">then the
given colors are dithered over the image as necessary,
otherwise the closest color (in RGB colorspace) is selected to
replace that pixel in the image.</span></p>
<h4>Arguments</h4>
<dl>
<dt>remap_image</dt>
<dd>The reference image</dd>
<dt>dither</dt>
<dd>A <a href="constants.html#DitherMethod">DitherMethod</a>
value. RiemersmaDitherMethod is the default. To disable
dithering specify NoDitherMethod.</dd>
</dl>
<h4>Returns</h4>
<p>self</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('remap.rb.html')"><img onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/remap.jpg'" src="ex/remap.jpg" alt=
"remap example" title="Click to see the example script" /></a>
<img src="ex/images/spin.gif" alt="" class="spin" style=
"left: 202px;" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="ilist.html#remap">ImageList#remap</a></p>
<h4>Magick API</h4>
<p>RemapImage (available in ImageMagick 6.4.3-6)</p>
</div>
<div class="sig">
<h3 id="resample">resample</h3>
<p><span class="arg">img</span>.resample(<span class=
"arg">horizontal_res</span>=72.0[, <span class=
"arg">vertical_res</span>]) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Resample image to specified horizontal and
vertical resolution.</p>
<p><span class="imquote">Resize the image so that its rendered
size remains the same as the original at the specified target
resolution. For example, if a 300 DPI image renders at 3 inches
by 2 inches on a 300 DPI device, when the image has been
resampled to 72 DPI, it will render at 3 inches by 2 inches on
a 72 DPI device. Note that only a small number of image formats
(e.g. JPEG, PNG, and TIFF) are capable of storing the image
resolution. For formats which do not support an image
resolution, the original resolution of the image must be
specified via</span> the <a href=
"imageattrs.html#density">density</a> attribute <span class=
"imquote">prior to specifying the resample
resolution.</span></p>
<h4>Arguments</h4>
<dl>
<dt>horizontal_res</dt>
<dd>the target horizontal resolution. The default is
72.0.</dd>
<dt>vertical_res</dt>
<dd>the target vertical resolution. The default is
<span class="arg">horizontal_res</span>.</dd>
</dl>
</div>
<div class="sig">
<h3 id="resize">resize</h3>
<p><span class="arg">img</span>.resize(<span class=
"arg">new_width</span>, <span class="arg">new_height</span>,
<em>filter</em>=<a href=
"constants.html#FilterTypes">LanczosFilter</a>,
<em>support</em>=1.0) -> <em>image</em><br />
<span class="arg">img</span>.resize(<span class=
"arg">scale_factor</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Changes the size of the receiver to the specified
dimensions.</p>
<h4>Arguments</h4>
<p>You can specify the new size in two ways. Either specify the
new width and height explicitly, or specify a <em>scale
factor</em>, a number that represents the percentage
change.</p>
<p>Use the <a href=
"image1.html#change_geometry">change_geometry</a> method to
resize an image with constraints such as "maintain the current
proportions."</p>
<dl>
<dt>new_width, new_height</dt>
<dd>The desired width and height.</dd>
<dt>filter</dt>
<dd>The <a href="constants.html#FilterTypes">filter</a> to
use when resizing. If you do not specify a filter argument,
resize uses the value of the receiver's <a href=
"imageattrs.html#Image.filter">filter attribute</a>.
<span class="imquote">Most of the filters are FIR (finite
impulse response), however, Bessel, Gaussian, and Sinc are
IIR (infinite impulse response). Bessel and Sinc are windowed
(brought down to zero) with the Blackman filter.</span></dd>
<dt>support</dt>
<dd>Values > 1 increase the blurriness. Values < 1
increase the sharpness. If this argument is not specified,
<code>resize</code> uses the value of the receiver's <a href=
"imageattrs.html#Image.blur">blur</a> attribute.</dd>
<dt>scale_factor</dt>
<dd>You can use this argument instead of specifying the
desired width and height. The percentage size change. For
example, 1.25 makes the new image 125% of the size of the
receiver. The scale factor 0.5 makes the new image 50% of the
size of the receiver.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>See also</h4>
<p><a href="image1.html#change_geometry">change_geometry</a>,
<a href="#resize_bang">resize!</a>, <a href=
"image2.html#magnify">magnify</a>, <a href=
"image2.html#minify">minify</a>, <a href="#sample">sample</a>,
<a href="#scale">scale</a>, <a href=
"thumbnail">thumbnail</a></p>
<h4>Magick API</h4>
<p>ResizeImage</p>
</div>
<div class="sig">
<h3 id="resize_bang">resize!</h3>
<p><span class="arg">img</span>.resize!(<em>new_width</em>,
<em>new_height</em>, <em>filter</em>=<a href=
"constants.html#FilterTypes">LanczosFilter</a>,
<em>support</em>=1.0) -> <em>self</em><br />
<span class="arg">img</span>.resize!(<span class=
"arg">scale_factor</span>) -> <em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>In-place form of <a href="#resize">resize</a>.</p>
<h4>Returns</h4>
<p>self</p>
</div>
<div class="sig">
<h3 id="resize_to_fill">resize_to_fill</h3>
<p><span class="arg">img</span>.resize_to_fill(<span class=
"arg">width</span> [, <span class="arg">height</span> [,
<span class="arg">gravity</span>=<code>CenterGravity</code>]])
-> <span class="arg">image</span></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>A convenience method. Resize the image to fit within the
specified dimensions while retaining the aspect ratio of the
original image. If necessary, crop the image in the larger
dimension.</p>
<h4>Arguments</h4>
<dl>
<dt>width</dt>
<dd>The width of the resulting image in pixels</dd>
<dt>height</dt>
<dd>(Optional) The height of the resulting image in pixels.
If omitted, defaults to <span class="arg">width</span>.</dd>
<dt>gravity</dt>
<dd>Use this argument to specify which portion of the image
to retain when cropping. The value can be any <a href=
"constants.html#GravityType">GravityType</a> value. The
effect is the same as the <span class="arg">gravity</span>
argument to the <a href=
"image1.html#crop"><code>crop</code></a> method. The default
is <code>CenterGravity</code>.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>In this example, some rows have been cropped from the top
and bottom to produce a square thumbnail from a rectangular
image without distorting the image.</p>
<p class="rollover"><a href=
"javascript:popup('resize_to_fill.rb.html')">
<!-- This img tag displays the after image when the mouse is not over-->
<img src="ex/resize_to_fill.jpg" style=
"padding-left:62px; padding-right: 62px; padding-top: 87px;padding-bottom:87px;"
id="after_resize_to_fill" onmouseover=
"this.style.display='none'; before_resize_to_fill.style.display='';"
alt="resize_to_fill example" />
<!-- This img tag displays the before image when moused over -->
<img src="ex/images/Flower_Hat.jpg" style="display: none" id=
"before_resize_to_fill" onmouseout=
"this.style.display='none'; after_resize_to_fill.style.display='';"
alt="resize_to_fill example" title=
"Click to see the example script" /></a> <img src=
"ex/images/spin.gif" alt="" style="margin-bottom: 230px" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="image1.html#crop">crop</a>, <a href=
"#resize">resize</a>, <a href=
"#resize_to_fit">resize_to_fit</a></p>
<h4>Notes</h4>
<p><code>crop_resized</code> is an alias for this method.</p>
</div>
<div class="sig">
<h3 id="resize_to_fill_bang">resize_to_fill!</h3>
<p><span class="arg">img</span>.resize_to_fill!(<span class=
"arg">width</span> [, <span class="arg">height</span> [,
<span class="arg">gravity</span>=<code>CenterGravity</code>]])
-> <em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>The in-place form of <a href=
"#resize_to_fill">resize_to_fill</a>.
<h4>Returns</h4>
<p>self</p>
<h4>See also</h4>
<p><a href="image1.html#crop_bang">crop!</a>, <a href=
"#resize_bang">resize!</a>, <a href=
"#resize_to_fit_bang">resize_to_fit!</a></p>
<h4>Notes</h4>
<p><code>crop_resized!</code> is an alias for this method.</p>
</div>
<div class="sig">
<h3 id="resize_to_fit">resize_to_fit</h3>
<p><span class="arg">img</span>.resize_to_fit(<span class=
"arg">new_width</span> [, <span class="arg">new_height</span>])
-> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>A convenience method. Resize the image to fit within the
specified dimensions while retaining the original aspect ratio.
The image may be shorter or narrower than specified in the
smaller dimension but will not be larger than the specified
values.</p>
<h4>Arguments</h4>
<dl>
<dt>new_width</dt>
<dd>The maximum width of the resized image.</dd>
<dt>new_height</dt>
<dd>(Optional) The maximum height of the resized image. If
omitted it defaults to the value of <span class=
"arg">new_width</span>.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>Compare the result of this example to the result of the
<a href="#resize_to_fill">resize_to_fill</a> example above.</p>
<p class="rollover"><a href=
"javascript:popup('resize_to_fit.rb.html')">
<!-- This img tag displays the original image when the mouse is over -->
<img id="rtfless" style="display: none" onmouseout=
"this.style.display='none';rtf.style.display='';" src=
"ex/images/Flower_Hat.jpg" alt="resize_to_fit example" title=
"Click to see the example script" />
<!-- This img tag displays the framed image when the mouse is not over-->
<img style=
"padding-left:69px; padding-right: 69px; padding-top: 87px;padding-bottom:87px;"
id="rtf" onmouseover=
"this.style.display='none';rtfless.style.display='';" src=
"ex/resize_to_fit.jpg" alt="resize_to_fit example" /></a>
<img src="ex/images/spin.gif" alt="" style=
"margin-bottom: 230px" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="#resize">resize</a>, <a href=
"#resize_to_fill">resize_to_fill</a></p>
</div>
<div class="sig">
<h3 id="resize_to_fit_bang">resize_to_fit!</h3>
<p><span class="arg">img</span>.resize_to_fit!(<span class=
"arg">new_width</span> [, <span class="arg">new_height</span>])
-> <em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>In-place form of <a href=
"#resize_to_fit">resize_to_fit</a>.</p>
<h4>Returns</h4>
<p>self</p>
<h4>See also</h4>
<p><a href="#resize_bang">resize!</a>, <a href=
"#resize_to_fill_bang">resize_to_fill!</a></p>
</div>
<div class="sig">
<h3 id="roll">roll</h3>
<p><span class="arg">img</span>.roll(<span class=
"arg">x_offset</span>, <span class="arg">y_offset</span>) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Offsets an image as defined by <span class=
"arg">x_offset</span> and <span class=
"arg">y_offset</span>.</p>
<h4>Arguments</h4>
<dl>
<dt>x_offset</dt>
<dd>The number of columns to offset the image.</dd>
<dt>y_offset</dt>
<dd>The number of rows to offset the image.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>This image has been offset 25% in both directions.</p>
<p class="rollover"><a href=
"javascript:popup('roll.rb.html')"><img src="ex/roll.jpg"
title="Click to see the example script" alt="roll example"
onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/roll.jpg'" /></a><img src="ex/images/spin.gif"
alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>Magick API</h4>
<p>RollImage</p>
</div>
<div class="sig">
<h3 id="rotate">rotate</h3>
<p><span class="arg">img</span>.rotate(<span class=
"arg">amount</span> [, <span class="arg">qualifier</span>])
-> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Rotate the receiver by the specified angle. Positive angles
rotate clockwise while negative angles rotate
counter-clockwise. New pixels introduced by the rotation are
the same color as the current <a href=
"imageattrs.html#background_color">background color</a>. Set
the background color to "none" to make the new pixels
transparent black.</p>
<h4>Arguments</h4>
<dl>
<dt>amount</dt>
<dd>The number of degrees to rotate the image.</dd>
<dt>qualifier</dt>
<dd>If present, either ">" or "<". If ">", rotates
the image only if the image's width exceeds its height. If
"<" rotates the image only if its height exceeds its
width. If this argument is omitted the image is always
rotated.</dd>
</dl>
<h4>Returns</h4>
<p>A new image, or <code>nil</code> if the image was not
rotated because it did not meet the qualification specified by
the second argument.</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('rotate_f.rb.html')"><!--
This img tag displays the original image when the mouse is over.
Use CSS to add padding around the image to make it occupy the
same space as the rotated image. --><img style="padding-top:34px;padding-bottom:34px; display:none"
id="notrotated" onmouseout=
"this.style.display='none'; rotated.style.display='';" src=
"ex/images/Flower_Hat.jpg" alt="rotate example" title=
"Click to see the example script" /><!--
This img tag displays the rotated image.
--><img class="hide"
id="rotated" onmouseover=
"this.style.display='none'; notrotated.style.display='';" src=
"ex/rotate_f.jpg" alt="rotate example" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" style="left:322px;"
title="Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="image1.html#affine_transform">affine_transform</a>,
<a href="#shear">shear</a></p>
<h4>Magick API</h4>
<p>RotateImage</p>
</div>
<div class="sig">
<h3 id="rotate_bang">rotate!</h3>
<p><span class="arg">img</span>.rotate!(<span class=
"arg">amount</span> [, <span class="arg">qualifier</span>])
-> <em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>In-place form of <a href="#rotate">rotate</a>.</p>
<h4>Returns</h4>
<p>self, or <code>nil</code> if the image was not rotated
because it did not meet the qualification specified by the
second argument.</p>
</div>
<div class="sig">
<h3 id="sample">sample</h3>
<p><span class="arg">img</span>.sample(<span class=
"arg">new_width</span>, <span class="arg">new_height</span>)
-> <span class="arg">image</span><br />
<span class="arg">img</span>.sample(<span class=
"arg">scale_factor</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Scales an image to the desired dimensions with pixel
sampling. Unlike other scaling methods, this method does not
introduce any additional color into the scaled image.</p>
<h4>Arguments</h4>
<dl>
<dt>new_width, new_height</dt>
<dd>The desired width and height.</dd>
<dt>scale_factor</dt>
<dd>You can use this argument instead of specifying the
desired width and height. The percentage size change. For
example, 1.25 makes the new image 125% of the size of the
receiver. The scale factor 0.5 makes the new image 50% of the
size of the receiver.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>See also</h4>
<p><a href="#sample_bang">sample!</a>, <a href=
"image2.html#magnify">magnify</a>, <a href=
"image2.html#minify">minify</a>, <a href="#resize">resize</a>,
<a href="#scale">scale</a>, <a href=
"#thumbnail">thumbnail</a></p>
<h4>Magick API</h4>
<p>SampleImage</p>
</div>
<div class="sig">
<h3 id="sample_bang">sample!</h3>
<p><span class="arg">img</span>.sample!(<span class=
"arg">new_width</span>, <span class="arg">new_height</span>)
-> <em>self</em><br />
<span class="arg">img</span>.sample!(<span class=
"arg">scale_factor</span>) -> <em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>In-place form of <a href="#sample">sample</a>.</p>
<h4>Returns</h4>
<p>self</p>
</div>
<div class="sig">
<h3 id="scale">scale</h3>
<p><span class="arg">img</span>.scale(<span class=
"arg">new_width</span>, <span class="arg">new_height</span>)
-> <em>image</em><br />
<span class="arg">img</span>.scale(<span class=
"arg">scale_factor</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Changes the size of an image to the given
dimensions.</p>
<h4>Arguments</h4>
<dl>
<dt>new_width, new_height</dt>
<dd>The desired width and height.</dd>
<dt>scale_factor</dt>
<dd>You can use this argument instead of specifying the
desired width and height. The percentage size change. For
example, 1.25 makes the new image 125% of the size of the
receiver. The scale factor 0.5 makes the new image 50% of the
size of the receiver.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>See also</h4>
<p><a href="#scale_bang">scale!</a>, <a href=
"image2.html#magnify">magnify</a>, <a href=
"image2.html#minify">minify</a>, <a href="#resize">resize</a>,
<a href="#sample">sample</a>, <a href=
"#thumbnail">thumbnail</a></p>
<h4>Magick API</h4>
<p>ScaleImage</p>
</div>
<div class="sig">
<h3 id="scale_bang">scale!</h3>
<p><span class="arg">img</span>.scale!(<span class=
"arg">new_width</span>, <span class="arg">new_height</span>)
-> <em>self</em><br />
<span class="arg">img</span>.scale!(<span class=
"arg">scale_factor</span>) -> <em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>In-place form of <a href="#scale">scale</a>.</p>
<h4>Returns</h4>
<p>self</p>
</div>
<div class="sig">
<h3 id="segment">segment</h3>
<p><span class="arg">img</span>.segment(<span class=
"arg">colorspace</span>=RGBColorspace, <span class=
"arg">cluster_threshold</span>=1.0, <span class=
"arg">smoothing_threshold</span>=1.5, <span class=
"arg">verbose</span>=<code>false</code>) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Segments an image by analyzing the
histograms of the color components and identifying units that
are homogeneous with the fuzzy c-means technique.</p>
<h4>Arguments</h4>
<dl>
<dt>colorspace</dt>
<dd>A <a href=
"constants.html#ColorspaceType"><code>ColorspaceType</code></a>
value. <span class="imquote">Empirical evidence suggests that
distances in YUV or YIQ correspond to perceptual color
differences more closely than do distances in RGB space. The
image is then returned to RGB colorspace after color
reduction.</span></dd>
<dt>cluster_threshold</dt>
<dd class="imquote">The number of pixels in each cluster must
exceed the the cluster threshold to be considered valid.</dd>
<dt>smoothing_threshold</dt>
<dd>The <span class="imquote">smoothing threshold eliminates
noise in the second derivative of the histogram. As the value
is increased, you can expect a smoother second
derivative.</span></dd>
<dt>verbose</dt>
<dd>If <code>true</code>, <code>segment</code> prints
detailed information about the identified classes.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p><code>segment(YUVColorspace, 0.4, 0.4)</code></p>
<p class="rollover"><a href=
"javascript:popup('segment.rb.html')"><img src="ex/segment.jpg"
alt="segment example" title="Click to see the example script"
onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/segment.jpg'" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>Magick API</h4>
<p>SegmentImage</p>
</div>
<div class="sig">
<h3 id="selective_blur_channel">selective_blur_channel</h3>
<p><span class=
"arg">img</span>.selective_blur_channel(<span class=
"arg">radius</span>, <span class="arg">sigma</span>,
<span class="arg">threshold</span>[, <span class=
"arg">channel</span>...]) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Selectively blur pixels within a contrast
threshold.</p>
<h4>Arguments</h4>
<dl>
<dt>radius, sigma</dt>
<dd class="imquote">Use a Gaussian operator of the given
radius and standard deviation (sigma).</dd>
<dt>threshold</dt>
<dd>Threshold level represented as a percentage of the
quantum range. Either a floating-point number or a string in
the form "NN%".</dd>
<dt>channel...</dt>
<dd>The channels to blur. 0 or more <a href=
"constants.html#ChannelType">ChannelType</a> arguments. If no
channels are specified, the default is the red, green, and
blue channels.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<pre>
img2 = img.selective_blur_channel(0, 1, '10%')
</pre>
<h4>See also</h4>
<p><a href="image1.html#blur_channel">blur_channel</a>,
<a href="image1.html#blur_image">blur_image</a>, <a href=
"image2.html#gaussian_blur_channel">gaussian_blur_channel</a>,
<a href="image2.html#motion_blur">motion_blur</a>, <a href=
"#radial_blur">radial_blur</a></p>
<h4>Magick API</h4>
<p>SelectiveBlurImageChannel (available in ImageMagick
6.5.0-3)</p>
</div>
<div class="sig">
<h3 id="separate">separate</h3>
<p>Image.separate(<span class="arg">channel</span>...) ->
<em>imagelist</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Constructs a grayscale image for each channel specified.</p>
<h4>Arguments</h4>
<p>0 or more <a href=
"constants.html#ChannelType">ChannelType</a> arguments. If no
channels are specified, constructs an image for each of the
red, green, and blue channels.</p>
<h4>Returns</h4>
<p>A new imagelist containing the new images.</p>
<h4>See also</h4>
<p><a href="image1.html#channel">channel</a></p>
<h4>Notes</h4>
<p>If the image does not have an opacity channel an
OpacityChannel argument is ignored.</p>
<h4>Magick API</h4>
<p>SeparateImages</p>
</div>
<div class="sig">
<h3 id="sepiatone">sepiatone</h3>
<p><span class="arg">img</span>.sepiatone(<span class=
"arg">threshold</span>=QuantumRange) -> <span class=
"arg">image</span></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Applies a special effect to the image,
similar to the effect achieved in a photo darkroom by sepia
toning.</p>
<h4>Arguments</h4>
<dl>
<dt>threshold</dt>
<dd class="imquote"><span class="arg">Threshold</span> ranges
from 0 to QuantumRange and is a measure of the extent of the
sepia toning. A threshold of 80% is a good starting point for
a reasonable tone. The default is QuantumRange.</dd>
</dl>
<h4>Returns</h4>
<p>A new image.</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('sepiatone.rb.html')"><img src=
"ex/sepiatone.jpg" alt="sepiatone example" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/sepiatone.jpg'" title=
"Click to see the example script" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p>You can get more control by using <a href=
"image1.html#colorize">colorize</a>.</p>
<h4>Magick API</h4>
<p>SepiaToneImage</p>
</div>
<div class="sig">
<h3 id="set_channel_depth">set_channel_depth</h3>
<p><span class="arg">img.</span>set_channel_depth(<span class=
"arg">channel</span>, <span class="arg">depth</span>) ->
<em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Sets the depth of the image channel.</p>
<h4>Arguments</h4>
<dl>
<dt>channel</dt>
<dd>A <a href="constants.html#ChannelType">ChannelType</a>
value</dd>
<dt>depth</dt>
<dd>The desired depth (must be no greater than <a href=
"constants.html">QuantumDepth</a>)</dd>
</dl>
<h4>Returns</h4>
<p>self</p>
<h4>See also</h4>
<p><a href="image1.html#channel_depth">channel_depth</a></p>
<h4>Magick API</h4>
<p>SetImageChannelDepth</p>
</div>
<div class="sig">
<h3 id="shade">shade</h3>
<p><span class="arg">img</span>.shade(<span class=
"arg">shading</span>=<code>false</code>, <span class=
"arg">azimuth</span>=30, <span class="arg">elevation</span>=30)
-> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Shines a distant light on an image to create
a three-dimensional effect. You control the positioning of the
light with <span class="arg">azimuth</span> and <span class=
"arg">elevation</span>; <span class="arg">azimuth</span> is
measured in degrees off the x axis and <span class=
"arg">elevation</span> is measured in pixels above the Z
axis.</p>
<h4>Arguments</h4>
<dl>
<dt>shading</dt>
<dd>If <code>true</code>, <code>shade</code> shades the
intensity of each pixel.</dd>
<dt>azimuth, elevation</dt>
<dd>The light source direction. The azimuth is measured in
degrees. 0° is at 9 o'clock. Increasing values move the
light source counter-clockwise.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p><code>shade(true, 50, 50)</code></p>
<p class="rollover"><a href=
"javascript:popup('shade.rb.html')"><img src="ex/shade.jpg"
alt="shade example" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/shade.jpg'" title=
"Click to see the example script" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>Magick API</h4>
<p>ShadeImage</p>
</div>
<div class="sig">
<h3 id="shadow">shadow</h3>
<p><span class="arg">img</span>.shadow(<span class=
"arg">x_offset=4</span>, <span class="arg">y_offset=4</span>,
<span class="arg">sigma=4.0</span>, <span class=
"arg">opacity=1.0</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>Draws the shadow of opaque parts of the
image. This method only works when the image has opaque parts
and transparent parts. Note that the resulting image is just
the shadow. You must composite the original image over the
shadow to produce the shadowed results.
<h4>Arguments</h4>
<dl>
<dt>x_offset</dt>
<dd>The shadow x-offset</dd>
<dt>y_offset</dt>
<dd>The shadow y-offset</dd>
<dt>sigma</dt>
<dd>The standard deviation of the Gaussian operator used to
produce the shadow. The higher the number, the "blurrier" the
shadow, but the longer it takes to produce the shadow. Must
be > 0.0.</dd>
<dt>opacity</dt>
<dd>The percent opacity of the shadow. May be either a number
between 0.1 and 1.0, or a string in the form "NN%" between
"1%" and "100%". If the percentage is greater than 100 it is
reduced to 100.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('shadow.rb.html')">
<!-- This img tag displays the original image when the mouse is over -->
<img style="padding:8px; display:none" id="shadowless"
onmouseout=
"this.style.display='none';shadowed.style.display='';" src=
"ex/shadow_before.gif" alt="shadow example" title=
"Click to see the example script" /><!--
This img tag displays the shadowed image when the mouse is not over
--><img class="hide"
id="shadowed" onmouseover=
"this.style.display='none';shadowless.style.display='';" src=
"ex/shadow_after.gif" alt="shadow example" /></a> <img src=
"ex/images/spin.gif" alt="" style="margin-bottom: 120px" title=
"Mouse over the example to see the original image" /></p>
<h4>Magick API</h4>
<p>ShadowImage</p>
<h4>Notes</h4>
<p>The shadow image is 2×<span class="arg">sigma</span>
pixels larger on a side than the original image, as can be seen
in the example above.</p>
</div>
<div class="sig">
<h3 id="sharpen">sharpen</h3>
<p><span class="arg">img</span>.sharpen(<span class=
"arg">radius</span>=0.0, <span class="arg">sigma</span>=1.0)
-> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Sharpens an image. We convolve the image
with a Gaussian operator of the given <span class=
"arg">radius</span> and standard deviation (<span class=
"arg">sigma</span>). For reasonable results, <span class=
"arg">radius</span> should be larger than <span class=
"arg">sigma</span>. Use a radius of 0 and <code>sharpen</code>
selects a suitable radius for you.</p>
<h4>Arguments</h4>
<p>The radius and standard deviation of the Gaussian
operator.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Magick API</h4>
<p>SharpenImage</p>
<h4>See also</h4>
<p><a href=
"imageattrs.html#virtual_pixel_method">virtual_pixel_method</a></p>
</div>
<div class="sig">
<h3 id="sharpen_channel">sharpen_channel</h3>
<p><span class="arg">img</span>.sharpen_channel( <span class=
"arg">radius</span>, <span class="arg">sigma</span>
[,<span class="arg">channel</span>...] ) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Sharpens one or more image channels. We
convolve the image with a Gaussian operator of the given radius
and standard deviation (<span class="arg">sigma</span>) . For
reasonable results, <span class="arg">radius</span> should be
larger than <span class="arg">sigma</span>. Use a radius of 0
and <code>sharpen_channel</code> selects a suitable radius for
you.</p>
<h4>Arguments</h4>
<dl>
<dt>radius, sigma</dt>
<dd>The radius and standard deviation of the Gaussian
operator.</dd>
<dt>channel...</dt>
<dd>0 or more <a href=
"constants.html#ChannelType">ChannelType</a> arguments. If no
channels are specified, all the channels are sharpened.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>See also</h4>
<p><a href="#sharpen">sharpen</a></p>
<h4>Magick API</h4>
<p>SharpenImageChannel</p>
</div>
<div class="sig">
<h3 id="shave">shave</h3>
<p><span class="arg">img</span>.shave(<span class=
"arg">width</span>, <span class="arg">height</span>) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Removes pixels from the edges of the image, leaving the
center rectangle.</p>
<h4>Arguments</h4>
<dl>
<dt>width</dt>
<dd>The number of pixels to remove from each side of the
receiver, not to exceed half the original width.</dd>
<dt>height</dt>
<dd>The number of pixels to remove from the top and bottom of
the receiver, not to exceed half the original height.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('shave.rb.html')"><img src="ex/shave.jpg"
onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/shave.jpg'" alt="shave example" title=
"Click to see the example script" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="#shave_bang">shave!</a>, <a href=
"image1.html#crop">crop</a></p>
<h4>Magick API</h4>
<p>ShaveImage</p>
</div>
<div class="sig">
<h3 id="shave_bang">shave!</h3>
<p><span class="arg">img</span>.shave!(<span class=
"arg">width</span>, <span class="arg">height</span>) ->
<em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>In-place form of <a href="#shave">shave</a>.</p>
<h4>Returns</h4>
<p>self</p>
</div>
<div class="sig">
<h3 id="shear">shear</h3>
<p><span class="arg">img</span>.shear(<span class=
"arg">x_shear</span>, <span class="arg">y_shear</span>) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Shearing slides one edge of an image along
the X or Y axis, creating a parallelogram. An X direction shear
slides an edge along the X axis, while a Y direction shear
slides an edge along the Y axis. The amount of the shear is
controlled by a shear angle. For X direction shears,
<span class="arg">x_shear</span> is measured relative to the Y
axis, and similarly, for Y direction shears <span class=
"arg">y_shear</span> is measured relative to the X axis. Empty
triangles left over from shearing the image are filled with the
background color.</p>
<h4>Arguments</h4>
<p>The X and Y shear angles, measured in degrees. These values
must not be 180.0. If either value is 0, no shearing will
occur.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('shear.rb.html')"><!--
This img tag displays the original image when the mouse is over
--><img style="padding-top:34px; padding-bottom:33px; padding-left:49px; padding-right:49px; display:none"
id="noshear" onmouseout=
"this.style.display='none'; sheared.style.display='';" src=
"ex/images/Flower_Hat.jpg" alt="shear example" title=
"Click to see the example script" /> <!--
This img tag displays the sheared image when the mouse is not over
-->
<img id="sheared" onmouseover=
"this.style.display='none'; noshear.style.display='';" src=
"ex/shear.jpg" alt="shear example" /></a><img src=
"ex/images/spin.gif" alt="" class="spin" style=
"left: 253px; top: 34px" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="image1.html#affine_transform">affine_transform</a>,
<a href="#rotate">rotate</a></p>
<h4>Magick API</h4>
<p>ShearImage</p>
</div>
<div class="sig">
<h3 id="sigmoidal_contrast_channel">
sigmoidal_contrast_channel</h3>
<p><br />
<span class=
"arg">img</span>.sigmoidal_contrast_channel(<span class=
"arg">contrast</span>=3.0, <span class=
"arg">midpoint</span>=50.0, <span class=
"arg">sharpen</span>=false[,<span class=
"arg">channel</span>...]) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Adjusts the contrast of an image channel
with a non-linear sigmoidal contrast algorithm. Increases the
contrast of the image using a sigmoidal transfer function
without saturating highlights or shadows.</p>
<h4>Arguments</h4>
<dl>
<dt>contrast</dt>
<dd class="imquote">indicates how much to increase the
contrast (0 is none; 3 is typical; 20 is pushing it)</dd>
<dt>midpoint</dt>
<dd><span class="imquote">indicates where midtones fall in
the resultant image (0 is white; 50% is middle-gray; 100% is
black).</span> Note that "50%" means "50% of the quantum
range." This argument is a number between 0 and QuantumRange.
To specify "50%" use <code>QuantumRange * 0.50</code>.</dd>
<dt>sharpen</dt>
<dd class="imquote">Set <span class="arg">sharpen</span> to
<code>true</code> to increase the image contrast otherwise
the contrast is reduced.</dd>
<dt>channel...</dt>
<dd>0 or more <a href=
"constants.html#ChannelType">ChannelType</a> arguments. If no
channels are specified, all the channels are adjusted.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>See also</h4>
<p><a href="image1.html#contrast">contrast</a></p>
<h4>Magick API</h4>
<p>SigmoidalContrastImageChannel</p>
</div>
<div class="sig">
<h3 id="signature">signature</h3>
<p><span class="arg">img</span>.signature ->
<em>string</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Computes a message digest from an image
pixel stream with an implementation of the NIST SHA-256 Message
Digest algorithm. This signature uniquely identifies the image
and is convenient for determining if an image has been modified
or whether two images are identical.</p>
<p>ImageMagick adds the computed signature to the image's
properties.</p>
<h4>Returns</h4>
<p>The signature as a 64-character string.</p>
<h4>Example</h4>
<pre>
img = Image.read('ex/images/Flower_Hat.jpg').first »
ex/images/Flower_Hat.jpg JPEG 200x250 DirectClass 8-bit 9761b
img.properties »
{"comment"=>"File written by Adobe Photoshop\250 4.0"}
img.signature »
"485e01ecba1a1f47924d67b887cb07b474f695841733796dfa3c2876965c7e8b"
img.properties »
{"signature"=>"485e01ecba1a1f47924d67b887cb07b474f695841733796dfa3c2876965c7e8b",
"comment"=>"File written by Adobe Photoshop\250 4.0"}
</pre>
<h4>See also</h4>
<p><a href="image1.html#spaceship"><=></a>, <a href=
"image1.html#difference">difference</a></p>
<h4>Magick API</h4>
<p>SignatureImage</p>
</div>
<div class="sig">
<h3 id="sketch">sketch</h3>
<p><span class="arg">img</span>.sketch(<span class=
"arg">radius</span>=0.0, <span class="arg">sigma</span>=1.0,
<span class="arg">angle</span>=0.0) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Simulates a pencil sketch. For best results start with a
grayscale image.</p>
<h4>Arguments</h4>
<dl>
<dt>radius, sigma</dt>
<dd>The radius and sigma of the Gaussian operator</dd>
<dt>angle</dt>
<dd>The angle toward which the image is sketched.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('sketch.rb.html')"><img src="ex/sketch.jpg"
title="Click to see the example script" alt="sketch example"
onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/sketch.jpg'" /></a> <img src="ex/images/spin.gif"
alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>Magick API</h4>
<p>SketchImage</p>
</div>
<div class="sig">
<h3 id="solarize">solarize</h3>
<p><span class="arg">img</span>.solarize(<span class=
"arg">threshold</span>=50) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Applies a special effect to the image
similar to the effect achieved in a photo darkroom by
selectively exposing areas of photo sensitive paper to
light.</p>
<h4>Arguments</h4>
<p><span class="imquote">Ranges from 0 to QuantumRange and is a
measure of the extent of the solarization.</span> The default
is 50.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('solarize.rb.html')"><img src=
"ex/solarize.jpg" title="Click to see the example script" alt=
"solarize example" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/solarize.jpg'" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>Magick API</h4>
<p>SolarizeImage</p>
</div>
<div class="sig">
<h3 id="sparse_color">sparse_color</h3>
<p><span class="arg">img</span>.sparse_color(<span class=
"arg">method</span>, <span class="arg">x1</span>, <span class=
"arg">y1</span>, <span class="arg">color1</span>[, <span class=
"arg">x2</span>, <span class="arg">y2</span>, <span class=
"arg">color2</span>...][, <span class="arg">channel</span>...])
-> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Fills the image with the specified <span class=
"arg">color</span> or colors, starting at the <span class=
"arg">x</span>,<span class="arg">y</span> coordinates
associated with the color and using the specified interpolation
<span class="arg">method</span>.</p>
<p>For more information about this method see the ImageMagick
documentation for the -sparse-color option. Also see <a href=
"http://www.imagemagick.org/Usage/canvas/#sparse-color">Sparse
Points of Color</a> at <a href=
"http://www.imagemagick.org/Usage/">Examples of ImageMagick
Usage</a>.</p>
<h4>Arguments</h4>
<dl>
<dt>method</dt>
<dd>
One of the following interpolation methods:
<dl>
<dt>BarycentricColorInterpolate</dt>
<dd class="imquote">Three point triangle of color given 3
points. Giving only 2 points will form a linear gradient
between those points. Gradient is however not restricted
to just the triangle or line.</dd>
<dt>BilinearColorInterpolate</dt>
<dd class="imquote">Like barycentric but for 4 points.
Less than 4 points fall back to barycentric.</dd>
<dt>ShepardsColorInterpolate</dt>
<dd class="imquote">Colors points basied on the ratio of
inverse distance squared. Generating spots of color in a
sea of the average of colors.</dd>
<dt>VoronoiColorInterpolate</dt>
<dd class="imquote">Simply map each pixel to the to
nearest color point given. The result are polygonal
'cells' of solid color.</dd>
</dl>
</dd>
<dt>xn, yn, colorn</dt>
<dd>One or more <span class="arg">x</span>,<span class=
"arg">y</span>, <span class="arg">color</span> triplets.
<span class="arg">X</span> and <span class="arg">y</span> are
floating-point values. <span class="arg">Color</span> can be
either a <a href="imusage.html#color_names">color name</a> or
a <a href="struct.html#Pixel">pixel</a>.</dd>
<dt>channel...</dt>
<dd>0 or more <a href=
"constants.html#ChannelType">ChannelType</a> arguments. If no
channels are specified then DefaultChannels is used.</dd>
</dl>
<h4>Example</h4>
<p><a href="javascript:popup('sparse_color.rb.html')"><img src=
"ex/sparse_color.png" title="Click to see the example script"
alt="sparse_color example" /></a></p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Magick API</h4>
<p>SparseColorImage (available in 6.4.3)</p>
</div>
<div class="sig">
<h3 id="splice">splice</h3>
<p><span class="arg">img</span>.splice(<span class=
"arg">x</span>, <span class="arg">y</span>, <span class=
"arg">width</span>, <span class="arg">height</span>[,
<span class="arg">color</span>]) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Splice a solid color into the image as defined by the
<code>x</code>, <code>y</code>, <code>width</code>, and
<code>height</code> arguments. This method is the opposite of
<a href="image1.html#chop">chop</a>.</p>
<h4>Arguments</h4>
<dl>
<dt>x, y, width, height</dt>
<dd>Describe the rectangle to be spliced.</dd>
<dt>color</dt>
<dd>The color to be spliced. Either a <a href=
"imusage.html#color_names">color name</a> or a <a href=
"struct.html#Pixel">pixel</a>. If omitted, uses the image's
background color.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('splice.rb.html')">
<!-- This img tag displays the original image when the mouse is over -->
<img style=
"padding-left:8px;padding-right:8px;padding-bottom:10px;padding-bottom:10px; display:none"
id="nosplice" onmouseout=
"this.style.display='none';spliced.style.display='';" src=
"ex/images/Flower_Hat.jpg" alt="splice example" title=
"Click to see the example script" /><!--
This img tag displays the spliced image when the mouse is not over
--><img class="hide"
id="spliced" onmouseover=
"this.style.display='none';nosplice.style.display='';" src=
"ex/splice.jpg" alt="splice example" /></a> <img src=
"ex/images/spin.gif" alt="" style="margin-bottom: 250px" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href=
"image1.html#color_fill_to_border">color_fill_to_border</a>,
<a href="image1.html#color_floodfill">color_floodfill</a>,
<a href="image1.html#color_reset_bang">color_reset!</a>,
<a href="image2.html#erase_bang">erase!</a>, <a href=
"image2.html#opaque">opaque</a></p>
<h4>Magick API</h4>
<p>SpliceImage</p>
</div>
<div class="sig">
<h3 id="spread">spread</h3>
<p><span class="arg">img</span>.spread(<span class=
"arg">radius</span>=3) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Randomly displaces each pixel in a block
defined by the <span class="arg"><em>radius</em></span>
parameter.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('spread.rb.html')"><img src="ex/spread.jpg"
alt="spread example" title="Click to see the example script"
onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/spread.jpg'" /></a> <img src="ex/images/spin.gif"
alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>Magick API</h4>
<p>SpreadImage</p>
</div>
<div class="sig">
<h3 id="stegano">stegano</h3>
<p><span class="arg">img</span>.stegano(<span class=
"arg">watermark</span>, <span class="arg">offset</span>) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Hides a digital watermark in the receiver. You can retrieve
the watermark by reading the file with the
<code>stegano:</code> prefix, thereby proving the authenticity
of the file.</p>
<p>The watermarked image must be saved in a lossless RGB format
such as MIFF, or PNG. You cannot save a watermarked image in a
lossy format such as JPEG or a pseudocolor format such as GIF.
Once written, the file must not be modified or processed in any
way.</p>
<h4>Arguments</h4>
<dl>
<dt>watermark</dt>
<dd>An image or imagelist to be used as the watermark. The
watermark must be grayscale and should be substantially
smaller than the receiver. The recovery time is proportional
to the size of the watermark.</dd>
<dt>offset</dt>
<dd>The starting position within the receiver at which the
watermark will be hidden. When you retrieve the watermark
from the file, you must supply this value, along with the
width and height of the watermark, in the <a href=
"info.html#Info.size_eq">size</a> optional parameter to the
<a href="image1.html#read">read</a> method.</dd>
</dl>
<h4>Returns</h4>
<p>A copy of the image containing the embedded watermark.</p>
<h4>Example</h4>
<p><a href="javascript:popup('stegano.rb.html')"><img src=
"ex/stegano.gif" title="Click to see the example script" alt=
"stegano example" /></a></p>
<h4>Magick API</h4>
<p>SteganoImage</p>
<h4>See also</h4>
<p><a href="#watermark">watermark</a></p>
</div>
<div class="sig">
<h3 id="stereo">stereo</h3>
<p><span class="arg">img</span>.stereo(<span class=
"arg">offset_image</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Combines two images and produces a single
image that is the composite of a left and right image of a
stereo pair. Special red-green stereo glasses are required to
view this effect.</p>
<h4>Arguments</h4>
<p>Another image or imagelist. If the argument is an imagelist,
uses the current image.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Magick API</h4>
<p>StereoImage</p>
</div>
<div class="sig">
<h3 id="store_pixels">store_pixels</h3>
<p><span class="arg">img</span>.store_pixels(<span class=
"arg">x</span>, <span class="arg">y</span>, <span class=
"arg">columns</span>, <span class="arg">rows</span>,
<span class="arg">pixels</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Replace the pixels in the specified rectangle with the
pixels in the <em>pixels</em> array.</p>
<h4>Arguments</h4>
<dl>
<dt>x, y</dt>
<dd>The x- and y-offset of the rectangle to be replaced.</dd>
<dt>columns, rows</dt>
<dd>The number of rows and columns in the rectangle.</dd>
<dt>pixels</dt>
<dd>An array of <a href="struct.html#Pixel">pixels</a>. The
number of pixels in the array must be the same as the number
of pixels in the rectangle, that is,
<code>rows*columns</code>.</dd>
</dl>
<h4>Returns</h4>
<p>The image, with the rectangle suitably altered.</p>
<h4>Example</h4>
<p><a href="javascript:popup('smile.rb.html')"><img src=
"ex/smile.gif" title="Click to see the example script" alt=
"smile example" /></a></p>
<p>Also see the example for <a href=
"image2.html#get_pixels"><code>get_pixels</code></a>.</p>
<h4>See also</h4>
<p><a href="image1.html#constitute">constitute</a>, <a href=
"image2.html#get_pixels">get_pixels</a>, <a href=
"#view">view</a></p>
<h4>Magick API</h4>
<p>SetImagePixels, SyncImagePixels</p>
</div>
<div class="sig">
<h3 id="strip_bang">strip!</h3>
<p><span class="arg">img</span>.strip! -> <em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Strips an image of all profiles and
comments.</p>
<h4>Returns</h4>
<p>self</p>
<h4>Magick API</h4>
<p>StripImage</p>
</div>
<div class="sig">
<h3 id="swirl">swirl</h3>
<p><span class="arg">img</span>.swirl(<span class=
"arg">degrees</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Swirls the pixels about the center of the
image, where degrees indicates the sweep of the arc through
which each pixel is moved. You get a more dramatic effect as
the degrees move from 1 to 360.</p>
<h4>Arguments</h4>
<p>The number of degrees to swirl the image.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>This example is an animated image. Mouse over the image to
start the animation.</p>
<p class="rollover"><a href=
"javascript:popup('swirl.rb.html')"><img onmouseover=
"this.src='ex/swirl.gif'" onmouseout=
"this.src='ex/images/Flower_Hat.jpg'" src=
"ex/images/Flower_Hat.jpg" alt="swirl example" title=
"Click the image to see the example script" /></a><img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the animation" /></p>
<h4>Magick API</h4>
<p>SwirlImage</p>
</div>
<div class="sig">
<h3 id="sync_profiles">sync_profiles</h3>
<p><span class="arg">img</span>.sync_profiles ->
<code>true</code> or <code>false</code></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Synchronizes image properties with the image
profiles.</p>
<h4>Returns</h4>
<p><code>True</code> if everything went okay,
<code>false</code> if there was a problem with the profile.</p>
<h4>Notes</h4>
<p class="imquote">Currently we only support updating the EXIF
resolution and orientation.</p>
<h4>Magick API</h4>
<p>SyncImageProfiles</p>
</div>
<div class="sig">
<h3 id="texture_fill_to_border">texture_fill_to_border</h3>
<p><span class=
"arg">img</span>.texture_fill_to_border(<span class=
"arg">x</span>, <span class="arg">y</span>, <span class=
"arg">texture</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Replaces the target pixel at <span class="arg">x</span>,
<span class="arg">y</span> and its neighbors that are not the
border color with copies of the <span class=
"arg">texture</span> image. Use the <a href=
"imageattrs.html#fuzz">fuzz</a> attribute to specify how
closely a pixel must match the border color.</p>
<h4>Arguments</h4>
<dl>
<dt>x, y</dt>
<dd>The x- and y-offset of the target pixel.</dd>
<dt>texture</dt>
<dd>An image or imagelist. If an imagelist, uses the current
image.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>In this example the target is the pixel in the center of the
image. The texture - in this case a picture of a girl in a
flowered hat - replaces this pixel and its neighbors until
reaching a black pixel. Mouse over the image to see the
original image. Notice the plum-colored circles are replaced as
well. Compare this result with the result of
<code>texture_floodfill</code>, below.</p>
<p class="rollover"><a href=
"javascript:popup('texture_fill_to_border.rb.html')"><img src=
"ex/texture_fill_to_border_after.gif" alt=
"texture_fill_to_border example" onmouseover=
"this.src='ex/texture_fill_to_border_before.gif'" onmouseout=
"this.src='ex/texture_fill_to_border_after.gif'" title=
"Click to see the example script" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" style="left:206px;"
title="Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href=
"image1.html#color_fill_to_border">color_fill_to_border</a>,
<a href=
"image2.html#matte_fill_to_border">matte_fill_to_border</a></p>
<h4>Magick API</h4>
<p>ColorFloodfillImage</p>
</div>
<div class="sig">
<h3 id="texture_floodfill">texture_floodfill</h3>
<p><span class="arg">img</span>.texture_floodfill(<span class=
"arg">x</span>, <span class="arg">y</span>, <span class=
"arg">texture</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Replaces the target pixel at <span class="arg">x</span>,
<span class="arg">y</span> and its neighbors that are the same
color with the <span class="arg">texture</span> image. By
default, the neighbor pixels must be exactly the same color as
the target pixel. Use the <a href=
"imageattrs.html#fuzz">fuzz</a> attribute to specify how much
difference is acceptable.</p>
<h4>Arguments</h4>
<dl>
<dt>x, y</dt>
<dd>The x- and y-offset of the target pixel.</dd>
<dt>texture</dt>
<dd>An image or imagelist. If an imagelist, uses the current
image.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>In this example the target is the pixel in the center of the
image. The texture - in this case a picture of a girl in a
flowered hat - replaces this pixel and its same-colored
neighbors. Mouse over the image to see the original image.
Notice the plum-colored circles are not replaced. Compare this
result with the result of <code>texture_fill_to_border</code>,
above.</p>
<p class="rollover"><a href=
"javascript:popup('texture_floodfill.rb.html')"><img src=
"ex/texture_floodfill_after.gif" alt=
"texture_floodfill example" onmouseover=
"this.src='ex/texture_floodfill_before.gif'" onmouseout=
"this.src='ex/texture_floodfill_after.gif'" title=
"Click to see the example script" /></a><img src=
"ex/images/spin.gif" alt="" class="spin" style="left:206px;"
title="Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="image1.html#color_floodfill">color_floodfill</a>,
<a href="image2.html#matte_floodfill">matte_floodfill</a></p>
<h4>Magick API</h4>
<p>ColorFloodfillImage</p>
</div>
<div class="sig">
<h3 id="threshold">threshold</h3>
<p><span class="arg">img</span>.threshold(<span class=
"arg">threshold</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Changes the value of individual pixels based
on the intensity of each pixel compared to <span class=
"arg">threshold</span>. The result is a high-contrast, two
color image.</p>
<h4>Arguments</h4>
<p>A value between 0 and QuantumRange.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p><code>threshold(MaxRGB*0.55)</code></p>
<p class="rollover"><a href=
"javascript:popup('threshold.rb.html')"><img src=
"ex/threshold.jpg" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/threshold.jpg'" title=
"Click to see the example script" alt=
"threshold example" /></a><img src="ex/images/spin.gif" alt=""
class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href=
"image1.html#adaptive_threshold">adaptive_threshold</a>,
<a href="image1.html#bilevel_channel">bilevel_channel</a>,
<a href=
"#random_threshold_channel">random_threshold_channel</a></p>
<h4>Magick API</h4>
<p>ThresholdImage</p>
</div>
<div class="sig">
<h3 id="thumbnail">thumbnail</h3>
<p><span class="arg">img</span>.thumbnail(<span class=
"arg">new_width</span>, <span class="arg">new_height</span>)
-> <em>image</em><br />
<span class="arg">img</span>.thumbnail(<span class=
"arg">scale_factor</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>The <code>thumbnail</code> method is a fast resizing method
suitable for use when the size of the resulting image is <
10% of the original.</p>
<h4>Arguments</h4>
<p>You can call <code>thumbnail</code> with either the new
width and height or the scale factor.</p>
<dl>
<dt>new_width, new_height</dt>
<dd>The desired width and height in pixels.</dd>
<dt>scale_factor</dt>
<dd>The desired size represented as a floating-point number.
For example, to make a thumbnail that is 9.5% of the size of
the original image, use <code>0.095</code>.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<pre>
img = Image.read("images/Cheetah.jpg").first
thumbnail = img.thumbnail(img.columns*0.09, img.rows*0.09)
</pre>
<h4>See also</h4>
<p><a href="image2.html#minify">minify</a>, <a href=
"#resize">resize</a>, <a href="#sample">sample</a>, <a href=
"#scale">scale</a></p>
<h4>Magick API</h4>
<p>ThumbnailImage</p>
</div>
<div class="sig">
<h3 id="thumbnail_bang">thumbnail!</h3>
<p><span class="arg">img</span>.thumbnail!(<span class=
"arg">new_width</span>, <span class="arg">new_height</span>)
-> <em>self</em><br />
<span class="arg">img</span>.thumbnail!(<span class=
"arg">scale_factor</span>) -> <em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>In-place form of <a href="#thumbnail">thumbnail</a>.</p>
<h4>Returns</h4>
<p>self</p>
</div>
<div class="sig">
<h3 id="to_blob">to_blob</h3>
<p><span class="arg">img</span>.to_blob <span class="arg">[ {
optional arguments } ]</span>-> <em>string</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Creates a <em>B</em>inary <em>L</em>arge <em>OB</em>ject, a
direct-to-memory version of the image. The <a href=
"image1.html#from_blob">from_blob</a> method constructs an
image from a BLOB created by this method.</p>
<h4>Arguments</h4>
<p>No required arguments, however you can specify the image
format (such as JPEG, PNG, etc.) and depth by calling the
<a href="imageattrs.html#format">format</a> and <a href=
"imageattrs.html#Image.depth">depth</a> attributes, as well as
other <a href="info.html">Image::Info</a> attributes as
appropriate, in a block associated with the method.</p>
<h4>Returns</h4>
<p>A string containing the image data represented as a
BLOB.</p>
<h4>Example</h4>
<p><a href="javascript:popup('to_blob.rb.html')"><img src=
"ex/to_blob.gif" alt="to_blob example" title=
"Click to see the example script" /></a></p>
<h4>See also</h4>
<p><a href="image1.html#from_blob">from_blob</a></p>
<h4>Magick API</h4>
<p>ImageToBlob</p>
</div>
<div class="sig">
<h3 id="to_color">to_color</h3>
<p><span class="arg">img</span>.to_color(<span class=
"arg">pixel</span>) -> <em>string</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Returns the color name for a pixel. Unlike the
<code>Pixel#to_color</code> method, to_color uses the <a href=
"imageattrs.html#Image.depth">depth</a> and <a href=
"imageattrs.html#Image.matte">matte</a> attributes of the image
to determine the color name.</p>
<h4>Arguments</h4>
<p>A <a href="struct.html#Pixel">Pixel</a> object.</p>
<h4>Returns</h4>
<p>A <a href="imusage.html#color_names">color name</a>.</p>
<h4>Example</h4>
<pre>
img = Image.read('ex/images/Flower_Hat.jpg').first
» ex/images/Flower_Hat.jpg JPEG 200x250 DirectClass 8-bit 9761b
pixel = img.pixel_color(img.columns/2, img.rows/2)
» #<struct Pixel red=216, green=147, blue=106, opacity=0>
img.to_color(pixel)
» "#D8936A"
</pre>
<h4>See also</h4>
<p><a href="struct.html#Pixel">Pixel#to_color</a></p>
<h4>Magick API</h4>
<p>QueryColorname</p>
</div>
<div class="sig">
<h3 id="transparent">transparent</h3>
<p><span class="arg">img</span>.transparent(<span class=
"arg">color</span>, <span class=
"arg">opacity</span>=TransparentOpacity) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Changes the opacity value of all the pixels that match
<span class="arg">color</span> to the value specified by
<span class="arg">opacity</span>. By default the pixel must
match exactly, but you can specify a tolerance level by setting
the <a href="imageattrs.html#fuzz">fuzz</a> attribute on the
image.</p>
<h4>Arguments</h4>
<dl>
<dt>color</dt>
<dd>Either a <a href="imusage.html#color_names">color
name</a> or a <a href="struct.html#Pixel">pixel</a>.</dd>
<dt>opacity</dt>
<dd>The new opacity value, either an <a href=
"constants.html#Opacity">opacity</a> value or a number
between 0 and QuantumRange. The default is
TransparentOpacity.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>Mouse over the image to see the original. In this example,
all the black pixels are made transparent. The resulting image
has been composited over a plasma background, which shows
through the transparent pixels.</p>
<p class="rollover"><a href=
"javascript:popup('transparent.rb.html')"><img src=
"ex/transparent_after.gif" title=
"Click to see the example script" onmouseover=
"this.src='ex/transparent_before.gif'" onmouseout=
"this.src='ex/transparent_after.gif'" alt=
"transparent example" /></a><img src="ex/images/spin.gif" alt=
"" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="image2.html#matte_replace">matte_replace</a>,
<a href="draw.html#matte">Draw#matte</a>, <a href=
"#paint_transparent">paint_transparent</a>, <a href=
"#transparent_chroma">transparent_chroma</a></p>
<h4>Magick API</h4>
<p>TransparentPaintImage</p>
</div>
<div class="sig">
<h3 id="transparent_chroma">transparent_chroma</h3>
<p><span class="arg">img</span>.transparent_chroma(<span class=
"arg">low</span>, <span class="arg">high</span>, <span class=
"arg">opacity</span>=TransparentOpacity, <span class=
"arg">invert</span>=<code>false</code>) ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Changes the opacity value associated with any pixel between
<span class="arg">low</span> and <span class="arg">high</span>
to the value defined by <span class="arg">opacity</span>.</p>
<p class="imquote">As there is one fuzz value for the all the
channels, the <a href="#transparent">transparent</a> method is
not suitable for the operations like chroma, where the
tolerance for similarity of two color components (RGB) can be
different, Thus we define this method take two target pixels
(one low and one high) and all the pixels of an image which are
lying between these two pixels are made transparent.</p>
<h4>Arguments</h4>
<dl>
<dt>low, high</dt>
<dd>The low and high ends of the pixel range</dd>
<dt>opacity</dt>
<dd>The desired opacity. The default value is
transparent.</dd>
<dt>invert</dt>
<dd>If true, all pixels outside the range are set to
<span class="arg">opacity</span>.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Magick API</h4>
<p>TransparentPaintImageChroma (available in ImageMagick
6.4.5-6)</p>
</div>
<div class="sig">
<h3 id="transpose">transpose</h3>
<p><span class="arg">img</span>.transpose ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Creates a horizontal mirror image by
reflecting the pixels around the central y-axis while rotating
them by 90 degrees.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('transpose.rb.html')"><img src=
"ex/transpose.jpg" alt="transpose example" title=
"Click to see the example script" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/transpose.jpg'" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" style="left:252px;"
title="Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="image2.html#flip">flip</a>, <a href=
"image2.html#flop">flop</a>, <a href=
"image3.html#rotate">rotate</a>, <a href=
"#transpose_bang">transpose!</a>, <a href=
"image3.html#transverse">transverse</a></p>
<h4>Magick API</h4>
<p>TransposeImage</p>
</div>
<div class="sig">
<h3 id="transpose_bang">transpose!</h3>
<p><span class="arg">img</span>.transpose! ->
<em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>In-place form of <a href="#transpose">transpose</a>.</p>
<h4>Returns</h4>
<p>self</p>
</div>
<div class="sig">
<h3 id="transverse">transverse</h3>
<p><span class="arg">img</span>.transverse ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Creates a vertical mirror image by
reflecting the pixels around the central x-axis while rotating
them by 270 degrees</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('transverse.rb.html')"><img src=
"ex/transverse.jpg" alt="transverse example" title=
"Click to see the example script" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/transverse.jpg'" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" style="left:252px;"
title="Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="image2.html#flip">flip</a>, <a href=
"image2.html#flop">flop</a>, <a href=
"image3.html#rotate">rotate</a>, <a href=
"image3.html#transpose">transpose</a>, <a href=
"#transverse_bang">transverse!</a></p>
<h4>Magick API</h4>
<p>TransposeImage</p>
</div>
<div class="sig">
<h3 id="transverse_bang">transverse!</h3>
<p><span class="arg">img</span>.transverse! ->
<em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>In-place form of <a href="#transverse">transverse</a>.</p>
<h4>Returns</h4>
<p>self</p>
</div>
<div class="sig">
<h3 id="trim">trim</h3>
<p><span class="arg">img</span>.trim(<span class=
"arg">reset</span>=false) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Removes the edges that are exactly the same
color as the corner pixels. Use the <a href=
"imageattrs.html#fuzz">fuzz</a> attribute to make
<code>trim</code> remove edges that are nearly the same color
as the corner pixels.</p>
<h4>Arguments</h4>
<p>The trim method retains the offset information in the
cropped image. This may cause the image to appear to be
surrounded by blank or black space when viewed with an external
viewer. This only occurs when the image is saved in a format
(such as GIF) that saves offset information. To reset the
offset data, use true as the argument to trim. See also
<a href="image1.html#crop">crop</a>.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('trim.rb.html')"><img src="ex/trim_after.jpg"
onmouseover="this.src='ex/trim_before.jpg'" onmouseout=
"this.src='ex/trim_after.jpg'" alt="trim example" title=
"Click to see the example script" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the image to see the original image" /></p>
<h4>See also</h4>
<p><a href="image1.html#crop">crop</a></p>
<h4>Magick API</h4>
<p>CropImage</p>
</div>
<div class="sig">
<h3 id="trim_bang">trim!</h3>
<p><span class="arg">img</span>.trim!(<span class=
"arg">reset</span>=false) -> <em>self</em></p>
</div>
<div class="desc">
<p>In-place form of <a href="#trim">trim</a>.</p>
<h4>Returns</h4>
<p>self</p>
</div>
<div class="sig">
<h3 id="unique_colors">unique_colors</h3>
<p><span class="arg">img</span>.unique_colors ->
<em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Constructs a new image with one pixel for each unique color
in the image. The new image has 1 row. The row has 1 column for
each unique pixel in the image.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Magick API</h4>
<p>UniqueImageColors</p>
</div>
<div class="sig">
<h3 id="unsharp_mask">unsharp_mask</h3>
<p><span class="arg">img</span>.unsharp_mask(<span class=
"arg">radius=0.0</span>, <span class="arg">sigma=1.0</span>,
<span class="arg">amount=1.0</span>, <span class=
"arg">threshold=0.05</span>) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Sharpens an image. We convolve the image
with a Gaussian operator of the given <span class=
"arg">radius</span> and standard deviation (<span class=
"arg">sigma</span>). For reasonable results, <span class=
"arg">radius</span> should be larger than <span class=
"arg">sigma</span>. Use a radius of 0 and
<code>unsharp_mask</code> selects a suitable radius for
you.</p>
<h4>Arguments</h4>
<p>All arguments are optional.</p>
<dl>
<dt>radius</dt>
<dd>The radius of the Gaussian operator. The default is
0.0.</dd>
<dt>sigma</dt>
<dd>The standard deviation of the Gaussian operator. A good
starting value is 1.0, which is the default.</dd>
<dt>amount</dt>
<dd>The percentage of the blurred image to be added to the
receiver, specified as a fraction between 0 and 1.0. A good
starting value is 1.0, which is the default.</dd>
<dt>threshold</dt>
<dd>The threshold needed to apply the amount, specified as a
fraction between 0 and 1.0. A good starting value is 0.05,
which is the default.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p><a href=
"javascript:popup:('unsharp_mask.rb.html')"><img src="ex/unsharp_mask.jpg"
alt="unsharp_mask example" title=
"Click to see the example script" /></a></p>
<h4>See also</h4>
<p><a href="image2.html#enhance">enhance</a>, <a href=
"image2.html#median_filter">median_filter</a>, <a href=
"image3.html#reduce_noise">reduce_noise</a>, <a href=
"#unsharp_mask_channel">unsharp_mask_channel</a></p>
<h4>Magick API</h4>
<p>UnsharpMaskImage</p>
</div>
<div class="sig">
<h3 id="unsharp_mask_channel">unsharp_mask_channel</h3>
<p><span class=
"arg">img</span>.unsharp_mask_channel(<span class=
"arg">radius=0.0</span>, <span class="arg">sigma=1.0</span>,
<span class="arg">amount=1.0</span>, <span class=
"arg">threshold=0.05</span> [,<span class=
"arg">channel</span>...]) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Sharpens an image. We convolve the image
with a Gaussian operator of the given <span class=
"arg">radius</span> and standard deviation (<span class=
"arg">sigma</span>). For reasonable results, <span class=
"arg">radius</span> should be larger than <span class=
"arg">sigma</span>. Use a radius of 0 and
<code>unsharp_mask_channel</code> selects a suitable radius for
you.</p>
<p>Only the specified channels are sharpened.</p>
<h4>Arguments</h4>
<p>All arguments are optional.</p>
<dl>
<dt>radius</dt>
<dd>The radius of the Gaussian operator. The default is
0.0.</dd>
<dt>sigma</dt>
<dd>The standard deviation of the Gaussian operator. A good
starting value is 1.0, which is the default.</dd>
<dt>amount</dt>
<dd>The percentage of the blurred image to be added to the
receiver, specified as a fraction between 0 and 1.0. A good
starting value is 1.0, which is the default.</dd>
<dt>threshold</dt>
<dd>The threshold needed to apply the amount, specified as a
fraction between 0 and 1.0. A good starting value is 0.05,
which is the default.</dd>
<dt>channel...</dt>
<dd>0 or more <a href=
"constants.html#ChannelType">ChannelType</a> arguments. If no
channels are specified, all the channels are sharpened. This
is the equivalent of <a href=
"#unsharp_mask">unsharp_mask</a>.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>See also</h4>
<p><a href="image2.html#enhance">enhance</a>, <a href=
"image2.html#median_filter">median_filter</a>, <a href=
"image3.html#reduce_noise">reduce_noise</a>, <a href=
"#unsharp_mask">unsharp_mask</a></p>
<h4>Magick API</h4>
<p>UnsharpMaskImageChannel</p>
</div>
<div class="sig">
<h3 id="view">view</h3>
<p><span class="arg">img</span>.view(<span class=
"arg">x</span>, <span class="arg">y</span>, <span class=
"arg">width</span>, <span class="arg">height</span>) ->
<em>aView</em><br />
<span class="arg">img</span>.view(<span class="arg">x</span>,
<span class="arg">y</span>, <span class="arg">width</span>,
<span class="arg">height</span>) { |view|
<em>block</em> } -> <em>nil</em></p>
</div>
<div class="desc">
<h4>Description</h4><code>View</code> is a convenience method
that supports getting and setting individual image pixels by
<code>[i][j]</code> coordinates. With no associated block,
<code>view</code> returns an <a href=
"struct.html#view">Image::View</a> object. If the optional code
block is given, it will be passed the <code>Image::View</code>
object as an argument. The <a href=
"struct.html#view_sync">sync</a> method will be called
automatically when the block terminates. In this case,
<code>view</code> returns <code>nil</code>.
<h4>Arguments</h4>
<dl>
<dt>x, y</dt>
<dd>The offset of the view from the top-left corner of the
image. Within the view, pixels are relative to the top-left
corner of the view, <em>not</em> the image.</dd>
<dt>width, height</dt>
<dd>The width and height of the view. The view may not extend
past the boundaries of <span class="arg">img</span>.</dd>
</dl>
<h4>Returns</h4>
<p>If the optional code block is present, <code>view</code>
returns <code>nil</code>. If it is not present,
<code>view</code> returns an <code>Image::View</code>
object.</p>
<h4>See</h4>
<p><a href="struct.html#view">Image::View</a></p>
<h4>Examples</h4>
<p>The example image below has been scaled 500% for
clarity.</p>
<p><a href="javascript:popup('viewex.rb.html')"><img src=
"ex/viewex.gif" title="Click to see the example script" alt=
"view example" /></a></p>
<pre>
img = Image.new(40, 40) {self.background_color = 'lightcyan2'}
# The view is 400 pixels square, starting at
# column 10, row 5 from the top of the image.
img.view( 10, 5, 20, 20) do |view|
# Set all the pixels in the view to green.
view[][] = Pixel.new(0, QuantumRange)
# Change the top and bottom rows to red.
view[0][] = 'red'
view[-1,1][] = 'red'
# Set 6 pixels to black.
view[[13,15]][[12,14,16]] = 'black'
# Set 1 pixel to yellow.
view[5][7] = 'yellow'
# Change the green channel of all the
# pixels on row 8.
view[8][].green = QuantumRange/2
# Change the blue channel of 8 pixels
# on column 10.
view[4,8][10].blue = QuantumRange
end
</pre>
<h4>See also</h4>
<p><a href="image3.html#pixel_color">pixel_color</a>, <a href=
"image2.html#get_pixels">get_pixels</a>, <a href=
"#store_pixels">store_pixels</a></p>
<h4>Notes</h4>
<p>The <code>view</code> method introduces a relatively high
level of overhead to pixel manipulation compared to methods
that use the ImageMagick API to identify and change pixels. I
recommend that you use <code>view</code> only when the number
of pixels identified in the view is fairly small (a few
thousand to a few hundred thousand, depending on your patience
and the speed of your computer) and you need this degree of
control.</p>
</div>
<div class="sig">
<h3 id="vignette">vignette</h3>
<p><span class="arg">img</span>.vignette(<span class=
"arg">x</span>, <span class="arg">y</span>, <span class=
"arg">radius</span>=0.0, <span class="arg">sigma</span>=10.0)
-> <span class="arg">image</span></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Gradually shades the edges of the image by transforming the
pixels into the background color.</p>
<h4>Arguments</h4>
<dl>
<dt>x</dt>
<dd>Influences the amount of background color in the
horizontal dimension. Larger values of <span class=
"arg">x</span> make the vignette narrower. This argument
should be positive and less than image.columns / 2. This
argument is optional. If omitted, the default value is 0.10 *
<span class="arg">img</span>.columns.</dd>
<dt>y</dt>
<dd>Influences the amount of background color in the vertical
dimension. Larger values of <span class="arg">y</span> make
the vignette shorter. This argument should be positive and
less than image.rows / 2. This argument is optional. If
omitted, the default value is 0.10 * <span class=
"arg">img</span>.rows.</dd>
<dt>radius, sigma</dt>
<dd>Controls the amount of blurring. Larger values of
<span class="arg">sigma</span> increase the blurring at the
expense of increased execution time. In general, <span class=
"arg">radius</span> should be larger than <span class=
"arg">sigma</span>, although if <span class=
"arg">radius</span> is 0 then ImageMagick will choose a
suitable value. <span class="arg">Sigma</span> must be
non-zero. Choose a very small value for <span class=
"arg">sigma</span> to produce a "hard" edge.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href=
"javascript:popup('vignette.rb.html')"><img src=
"ex/vignette.jpg" alt="vignette example" title=
"Click to see the example script" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/vignette.jpg'" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>Magick API</h4>
<p>VignetteImage</p>
<h4>Notes</h4>
<p>The image produced by <code>vignette</code> is very similar
to the image produced by RMagick's vignette.rb example script.
However, the example script gives you more control over the
size, shape, and background color of the vignette.</p>
</div>
<div class="sig">
<h3 id="watermark">watermark</h3>
<p><span class="arg">img</span>.watermark(<span class=
"arg">mark</span>, <span class="arg">lightness</span>=1.0,
<span class="arg">saturation</span>=1.0, <span class=
"arg">x_offset</span>=0, <span class="arg">y_offset</span>=0)
-> <em>image</em><br />
<span class="arg">img</span>.watermark(<span class=
"arg">mark</span>, <span class="arg">lightness</span>=1.0,
<span class="arg">saturation</span>=1.0, <span class=
"arg">gravity</span>, <span class="arg">x_offset</span>=0,
<span class="arg">y_offset</span>=0) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Composites a watermark image on the target image using the
<a href="constants.html#CompositeOperator">Modulate</a>
composite operator. This composite operation operates in the
HSL colorspace and combines part of the lightness, part of the
saturation, and all of the hue of each pixel in the watermark
with the corresponding pixel in the target image</p>
<h4>Arguments</h4>
<dl>
<dt>mark</dt>
<dd>The watermark image. Either an imagelist or an image. If
an imagelist, uses the current image.</dd>
<dt>lightness</dt>
<dd>The fraction of the lightness component of the watermark
pixels to be composited onto the target image. Must be a
non-negative number or a string in the form "NN%". If
lightness is a number it is interpreted as a percentage. Both
0.25 and "25%" mean 25%. The default is 100%.</dd>
<dt>saturation</dt>
<dd>The fraction of the saturation component of the watermark
pixels to be composited onto the target image. Must be a
non-negative number or a string in the form "NN%". If
lightness is a number it is interpreted as a percentage. Both
0.25 and "25%" mean 25%. The default is 100%.</dd>
<dt>x_offset</dt>
<dd>The offset of the watermark, measured from the left-hand
side of the target image. The default is 0.</dd>
<dt>y_offset</dt>
<dd>The offset of the watermark, measured from the top of the
target image. The default is 0.</dd>
</dl>
<p>Watermark can be called with a <span class=
"arg">gravity</span> argument or without. When a <span class=
"arg">gravity</span> argument is specified but the <span class=
"arg">x-</span> and <span class="arg">y-offsets</span> are
omitted, the watermark is positioned based on the value of the
<span class="arg">gravity</span> argument:</p>
<dl>
<dt>NorthWestGravity</dt>
<dd>The watermark abuts the top and left sides of the
image.</dd>
<dt>NorthGravity</dt>
<dd>The watermark is centered left-to-right and abuts the top
of the image.</dd>
<dt>NorthEastGravity</dt>
<dd>The watermark abuts the top and right sides of the
image.</dd>
<dt>EastGravity</dt>
<dd>The watermark is centered top-to-bottom and abuts the
right side of the image.</dd>
<dt>SouthEastGravity</dt>
<dd>The watermark abuts the bottom and right sides of the
image.</dd>
<dt>SouthGravity</dt>
<dd>The watermark is centered left-to-right and abuts the
bottom of the image.</dd>
<dt>SouthWestGravity</dt>
<dd>The watermark abuts the bottom and left sides of the
image.</dd>
<dt>WestGravity</dt>
<dd>The watermark is centered top-to-bottom and abuts the
left side of the image.</dd>
<dt>CenterGravity</dt>
<dd>The watermark is centered left-to-right and
top-to-bottom.</dd>
</dl>
<p>When the <span class="arg">gravity</span> argument is
present and the <span class="arg">x-offset</span> (and
optionally the <span class="arg">y-offset</span>) is present,
the <span class="arg">x-</span> and <span class=
"arg">y-offset</span> are measured from the right and/or bottom
edges of the target image based on the value of <span class=
"arg">gravity</span>. If the argument is NorthEastGravity,
EastGravity, or SouthEastGravity, the <span class=
"arg">x-offset</span> is measured from the right side of the
image. If the argument is SouthEastGravity, SouthGravity, or
SouthWestGravity, the <span class="arg">y-offset</span> is
measured from the bottom of the image. All other values are
ignored and the <span class="arg">x-</span> and <span class=
"arg">y-offset</span> are measured from the upper-left corner
of the image.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>See <a href=
"http://www.cit.gu.edu.au/~anthony/graphics/imagick6/annotating/#wmark_image">
"Watermarking with Images"</a> in Anthony Thyssen's <a href=
"http://www.cit.gu.edu.au/~anthony/graphics/imagick6/"><cite>Examples
of ImageMagick Usage</cite></a>.</p>
<p class="rollover"><a href=
"javascript:popup('watermark.rb.html')"><img src=
"ex/watermark.jpg" alt="watermark example" title=
"Click to see the example script" onmouseover=
"this.src='ex/images/Flower_Hat.jpg'" onmouseout=
"this.src='ex/watermark.jpg'" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>See also</h4>
<p><a href="image1.html#composite">composite</a>, <a href=
"#stegano">stegano</a></p>
</div>
<div class="sig">
<h3 id="wave">wave</h3>
<p><span class="arg">img</span>.wave(<span class=
"arg">amplitude</span>=25.0, <span class=
"arg">wavelength</span>=150.0) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Creates a "ripple" effect in the image by
shifting the pixels vertically along a sine wave whose
<span class="arg">amplitude</span> and <span class=
"arg">wavelength</span> is specified by the given
parameters.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p class="rollover"><a href="javascript:popup('wave.rb.html')">
<!-- This img tag displays the original image when the mouse is over -->
<img style=
"padding-top:25px; padding-bottom:25px; display:none" id=
"nowave" title="Click to see the example script" onmouseout=
"this.style.display='none'; waved.style.display='';" src=
"ex/images/Flower_Hat.jpg" alt="wave example" /> <!--
This img tag displays the framed image when the mouse is not over
--><img class="hide"
id="waved" onmouseover=
"this.style.display='none'; nowave.style.display='';" src=
"ex/wave.jpg" alt="wave example" /></a> <img src=
"ex/images/spin.gif" alt="" class="spin" title=
"Mouse over the example to see the original image" /></p>
<h4>Magick API</h4>
<p>WaveImage</p>
<h4>See also</h4>
<p><a href=
"imageattrs.html#virtual_pixel_method">virtual_pixel_method</a></p>
</div>
<div class="sig">
<h3 id="wet_floor">wet_floor</h3>
<p><span class="arg">img</span>.wet_floor(<span class=
"arg">initial=0.5</span>, <span class="arg">rate=1.0</span>)
-> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Creates a <a href=
"http://en.wikipedia.org/wiki/Wet_floor_effect">"wet floor"</a>
reflection. The reflection is an inverted copy of the image
that changes from partially transparent to entirely
transparent. By default only the bottom third of the image
appears in the reflection.</p>
<p>Note that the output image is just the reflection. This
makes it easy to apply further transformations to the
reflection before combining it with the original image.</p>
<h4>Arguments</h4>
<dl>
<dt>initial</dt>
<dd>A value between 0.0 and 1.0 that specifies the initial
percentage of transparency. Higher values cause the top of
the reflection to be more transparent, lower values less
transparent. The default is 0.5, which means that the top of
the reflection is 50% transparent.</dd>
<dt>rate</dt>
<dd>A non-negative value that specifies how rapidly the
reflection transitions from the initial level of transparency
to entirely transparent. The default value is 1.0, which
means that the transition occurs in 1/3 the image height.
Values greater than 1.0 speed up the transition (the
reflection will have fewer rows), values lower than 1.0 slow
down the transition (the reflection will have more rows). A
value of 0.0 means that the level of transparency will not
change.</dd>
</dl>
<h4>Returns</h4>
<p>A new image</p>
<h4>Example</h4>
<p>Here are four examples of <code>wet_floor</code>. The top
image shows the result of appending the default reflection to
the original image. The second image shows the result of
decreasing the initial transparency to 0.25 and using 0.5 as
the <span class="arg">rate</span> argument. The third image
uses the same reflection as the second image but has a slant
added. The bottom image is the same as the third image but with
a ripple effect.</p>
<p><a href="javascript:popup('wet_floor.rb.html')"><img src=
"ex/wet_floor.gif" title="Click to see the example script" alt=
"wet floor example" /></a></p>
</div>
<div class="sig">
<h3 id="white_threshold">white_threshold</h3>
<p><span class="arg">img</span>.white_threshold(<span class=
"arg">red_channel</span> [, <span class=
"arg">green_channel</span>[, <span class=
"arg">blue_channel</span>[, <span class=
"arg">opacity_channel</span>]]]) -> <em>image</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p class="imquote">Forces all pixels above the threshold into
white while leaving all pixels below the threshold
unchanged.</p>
<h4>Arguments</h4>
<p>Each channel argument is a number between 0 and
QuantumRange. All arguments except the first may be omitted. If
the <span class="arg">green_channel</span> or <span class=
"arg">blue_channel</span> argument is omitted, the default
value is the <span class="arg">red_channel</span> value. If the
<span class="arg">opacity_channel</span> argument is omitted,
the default value is <a href=
"constants.html#Opacity">OpaqueOpacity</a>.</p>
<h4>Returns</h4>
<p>A new image</p>
<h4>See also</h4>
<p><a href="image1.html#black_threshold">black_threshold</a>,
<a href="image1.html#bilevel_channel">bilevel_channel</a></p>
<h4>Magick API</h4>
<p>WhiteThresholdImage</p>
</div>
<div class="sig">
<h3 id="write">write</h3>
<p><span class="arg">img</span>.write(<span class=
"arg">filename</span>) <span class="arg">[ { optional arguments
} ]</span> -> <em>self</em><br />
<span class="arg">img</span>.write(<span class=
"arg">file</span>) <span class="arg">[ { optional arguments }
]</span> -> <em>self</em></p>
</div>
<div class="desc">
<h4>Description</h4>
<p>Writes the image to the specified file. ImageMagick
determines image format from the <a href=
"imusage.html#formats">prefix or extension</a>.</p>
<p>If the argument is an open file, ImageMagick will write the
image in its current format. You can force a different format
by setting the image's <a href=
"imageattrs.html#Image.format">format</a> attribute.</p>
<h4>Arguments</h4>
<p>A file name or open file object. You may also specify
optional arguments by setting <a href=
"info.html">Image::Info</a> attributes in an associated
block.</p>
<h4>Returns</h4>
<p><code>self</code>, or <code>nil</code> if the image format
cannot be determined.</p>
<h4>Example</h4>
<p>Almost all of the examples call <code>write</code>.</p>
<h4>Notes</h4>
<p>When the argument is a filename, specify the output format
via the filename extension (for example ".jpg" or ".gif") or by
prefixing the filename with the desired format (for example,
"jpeg:myfile"), not via <code>format=</code>.</p>
<p><em>Do not</em> use a StringIO object or a Tempfile object
as the argument. Neither of these work. Use
<code>to_blob</code> to write to a String. Instead of a
tempfile, get the path of the tempfile from the
<code>path</code> method. Prefix the path with the desired
image format. For example,</p>
<pre>
temp = Tempfile.new("image")
img.write("jpeg:"+ temp.path)
</pre>
<h4>See also</h4>
<p><a href="ilist.html#write">ImageList#write</a></p>
<h4>Magick API</h4>
<p>WriteImage</p>
</div>
<p class="spacer"> </p>
<div class="nav">
« <a href="image2.html">Prev</a> | <a href=
"index.html">Contents</a> | <a href=
"draw.html">Next</a> »
</div>
</body>
</html>
|