1<?xml version="1.0" encoding="utf-8" ?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 4<head> 5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6<title>Magick++ API: Geometry</title> 7<link rel="stylesheet" href="magick.css" type="text/css" /> 8</head> 9<body> 10<div class="doc-section"> 11<h1 align="center">Magick::Geometry</h1> 12<p>Geometry provides a convenient means to specify a geometry 13argument. The object may be initialized from a C string or C++ string 14containing a geometry specification. It may also be initialized by 15more efficient parameterized constructors. 16</p> 17<h3><a name="GeometrySpecifications"></a>Geometry 18Specifications</h3> 19<p>Geometry specifications are in the form 20<kbd>"<width>x<height>{+-}<xoffset>{+-}<yoffset>"</kbd> 21(where <i>width</i>, <i>height</i>, <i>xoffset</i>, and <i>yoffset</i> 22are numbers) for specifying the size and placement location for an 23object. 24</p> 25<p style="margin-bottom: 0in">The <i>width</i> and <i>height</i> 26parts of the geometry specification are measured in pixels. The 27<i>xoffset</i> and <i>yoffset</i> parts are also measured in pixels 28and are used to specify the distance of the placement coordinate from 29the left and top and edges of the image, respectively. Both types of 30offsets are measured from the indicated edge of the object to the 31corresponding edge of the image. The X offset may be specified in the 32following ways: 33</p> 34 <table width="90%" border="1" cellpadding="2" cellspacing="3"> 35 <col width="21*" /> 36 <col width="235*" /> 37 <tr> 38 <td width="8%"> 39 <p>+<i>xoffset</i></p> 40 </td> 41 <td width="92%"> 42 <p>The left edge of the object is to be placed <i>xoffset</i> 43 pixels in from the <em>left edge </em>of the image.</p> 44 </td> 45 </tr> 46 <tr> 47 <td width="8%"> 48 <p>-<i>xoffset</i></p> 49 </td> 50 <td width="92%"> 51 <p>The left edge of the object is to be placed outside the image, 52 <i>xoffset</i> pixels out from the <em>left edge </em>of the image.</p> 53 </td> 54 </tr> 55 </table> 56<p style="margin-bottom: 0in">The Y offset has similar meanings: 57</p> 58 <table width="90%" border="1" cellpadding="2" cellspacing="3"> 59 <col width="27*" /> 60 <col width="229*" /> 61 <tr> 62 <td width="11%"> 63 <p>+<i>yoffset</i></p> 64 </td> 65 <td width="89%"> 66 <p>The top edge of the object is to be <i>yoffset</i> pixels 67 <em>below</em> the <em>top edge </em>of the image.</p> 68 </td> 69 </tr> 70 <tr> 71 <td width="11%"> 72 <p>-<i>yoffset</i></p> 73 </td> 74 <td width="89%"> 75 <p>The top edge of the object is to be <i>yoffset</i> pixels 76 <em>above</em> the <em>top edge</em> of the image.</p> 77 </td> 78 </tr> 79 </table> 80<p>Offsets must be given as pairs; in other words, in order to 81specify either <i>xoffset</i> or <i>yoffset</i> both must be present. 82</p> 83<h3><a name="ExtendedGeometrySpecifications"></a>ImageMagick 84Extensions To Geometry Specifications</h3> 85<p style="margin-bottom: 0in">ImageMagick has added a number of 86qualifiers to the standard geometry string for use when resizing 87images. The form of an extended geometry string is 88"<kbd><width>x<height>{+-}<xoffset>{+-}<yoffset>{%}{!}{<}{>}"</kbd>. 89Extended geometry strings should <em>only</em> be used <em>when resizing 90an image</em>. Using an extended geometry string for other 91applications may cause the API call to fail. The available 92qualifiers are shown in the following table: 93</p> 94<p align="center" STYLE="margin-bottom: 0in"><b>ImageMagick Geometry 95Qualifiers</b></p> 96 <table width="90%" border="1" cellpadding="2" cellspacing="3"> 97 <col width="36*" /> 98 <col width="220*" /> 99 <tr> 100 <td width="14%"> 101 <p align="center"><b>Qualifier</b></p> 102 </td> 103 <td width="86%"> 104 <p align="center"><b>Description</b></p> 105 </td> 106 </tr> 107 <tr> 108 <td width="14%"> 109 <p align="center"><b>%</b></p> 110 </td> 111 <td width="86%"> 112 <p>Interpret width and height as a <b>percentage</b> of the 113 current size.</p> 114 </td> 115 </tr> 116 <tr> 117 <td width="14%"> 118 <p align="center"><b>!</b></p> 119 </td> 120 <td width="86%"> 121 <p>Resize to width and height <b>exactly</b>, loosing original 122 aspect ratio.</p> 123 </td> 124 </tr> 125 <tr> 126 <td width="14%"> 127 <p align="center"><b><</b></p> 128 </td> 129 <td width="86%"> 130 <p>Resize only if the image is <b>smaller</b> than the geometry 131 specification.</p> 132 </td> 133 </tr> 134 <tr> 135 <td width="14%"> 136 <p align="center"><b>></b></p> 137 </td> 138 <td width="86%"> 139 <p>Resize only if the image is <b>greater</b> than the geometry 140 specification.</p> 141 </td> 142 </tr> 143 </table> 144<h3><a name="PostscriptPageSize"></a>Postscript Page Size Extension 145To Geometry Specifications</h3> 146<p>Any geometry string specification supplied to the Geometry 147constructor is considered to be a Postscript page size nickname if 148the first character is not numeric. The Geometry constructor converts 149these page size specifications into the equivalent numeric geometry 150string specification (preserving any offset component) prior to 151conversion to the internal object format. Postscript page size 152specifications are short-hand for the pixel geometry required to fill 153a page of that size. Since the 11x17 inch page size used in the US 154starts with a digit, it is not supported as a Postscript page size 155nickname. Instead, substitute the geometry specification "<kbd>792x1224>"</kbd> 156when 11x17 output is desired. 157</p> 158<p style="margin-bottom: 0in">An example of a Postscript page size 159specification is <kbd>"letter+43+43>"</kbd>. 160</p> 161<p align="center" style="margin-bottom: 0in"><b>Postscript Page Size 162Nicknames</b></p> 163 <table width="70%" border="1" cellpadding="2" cellspacing="3"> 164 <col width="105*" /> 165 <col width="151*" /> 166 <tr> 167 <td width="41%"> 168 <p align="center"><b>Postscript Page Size Nickname</b></p> 169 </td> 170 <td width="59%"> 171 <p align="center"><b>Equivalent Extended Geometry Specification</b></p> 172 </td> 173 </tr> 174 <tr> 175 <td width="41%"> 176 <p align="center"><font size="2">Ledger</font></p> 177 </td> 178 <td width="59%"> 179 <p align="center"><font size="2">1224x792></font></p> 180 </td> 181 </tr> 182 <tr> 183 <td width="41%"> 184 <p align="center"><font size="2">Legal</font></p> 185 </td> 186 <td width="59%"> 187 <p align="center"><font size="2">612x1008></font></p> 188 </td> 189 </tr> 190 <tr> 191 <td width="41%"> 192 <p align="center"><font size="2">Letter</font></p> 193 </td> 194 <td width="59%"> 195 <p align="center"><font size="2">612x792></font></p> 196 </td> 197 </tr> 198 <tr> 199 <td width="41%"> 200 <p align="center"><font size="2">LetterSmall</font></p> 201 </td> 202 <td width="59%"> 203 <p align="center"><font size="2">612x792></font></p> 204 </td> 205 </tr> 206 <tr> 207 <td width="41%"> 208 <p align="center"><font size="2">ArchE</font></p> 209 </td> 210 <td width="59%"> 211 <p align="center"><font size="2">2592x3456></font></p> 212 </td> 213 </tr> 214 <tr> 215 <td width="41%"> 216 <p align="center"><font size="2">ArchD</font></p> 217 </td> 218 <td width="59%"> 219 <p align="center"><font size="2">1728x2592></font></p> 220 </td> 221 </tr> 222 <tr> 223 <td width="41%"> 224 <p align="center"><font size="2">ArchC</font></p> 225 </td> 226 <td width="59%"> 227 <p align="center"><font size="2">1296x1728></font></p> 228 </td> 229 </tr> 230 <tr> 231 <td width="41%"> 232 <p align="center"><font size="2">ArchB</font></p> 233 </td> 234 <td width="59%"> 235 <p align="center"><font size="2">864x1296></font></p> 236 </td> 237 </tr> 238 <tr> 239 <td width="41%"> 240 <p align="center"><font size="2">ArchA</font></p> 241 </td> 242 <td width="59%"> 243 <p align="center"><font size="2">648x864></font></p> 244 </td> 245 </tr> 246 <tr> 247 <td width="41%"> 248 <p align="center"><font size="2">A0</font></p> 249 </td> 250 <td width="59%"> 251 <p align="center"><font size="2">2380x3368></font></p> 252 </td> 253 </tr> 254 <tr> 255 <td width="41%"> 256 <p align="center"><font size="2">A1</font></p> 257 </td> 258 <td width="59%"> 259 <p align="center"><font size="2">1684x2380></font></p> 260 </td> 261 </tr> 262 <tr> 263 <td width="41%"> 264 <p align="center"><font size="2">A2</font></p> 265 </td> 266 <td width="59%"> 267 <p align="center"><font size="2">1190x1684></font></p> 268 </td> 269 </tr> 270 <tr> 271 <td width="41%"> 272 <p align="center"><font size="2">A3</font></p> 273 </td> 274 <td width="59%"> 275 <p align="center"><font size="2">842x1190></font></p> 276 </td> 277 </tr> 278 <tr> 279 <td width="41%"> 280 <p align="center"><font size="2">A4</font></p> 281 </td> 282 <td width="59%"> 283 <p align="center"><font size="2">595x842></font></p> 284 </td> 285 </tr> 286 <tr> 287 <td width="41%"> 288 <p align="center"><font size="2">A4Small</font></p> 289 </td> 290 <td width="59%"> 291 <p align="center"><font size="2">595x842></font></p> 292 </td> 293 </tr> 294 <tr> 295 <td width="41%"> 296 <p align="center"><font size="2">A5</font></p> 297 </td> 298 <td width="59%"> 299 <p align="center"><font size="2">421x595></font></p> 300 </td> 301 </tr> 302 <tr> 303 <td width="41%"> 304 <p align="center"><font size="2">A6</font></p> 305 </td> 306 <td width="59%"> 307 <p align="center"><font size="2">297x421></font></p> 308 </td> 309 </tr> 310 <tr> 311 <td width="41%"> 312 <p align="center"><font size="2">A7</font></p> 313 </td> 314 <td width="59%"> 315 <p align="center"><font size="2">210x297></font></p> 316 </td> 317 </tr> 318 <tr> 319 <td width="41%"> 320 <p align="center"><font size="2">A8</font></p> 321 </td> 322 <td width="59%"> 323 <p align="center"><font size="2">148x210></font></p> 324 </td> 325 </tr> 326 <tr> 327 <td width="41%"> 328 <p align="center"><font size="2">A9</font></p> 329 </td> 330 <td width="59%"> 331 <p align="center"><font size="2">105x148></font></p> 332 </td> 333 </tr> 334 <tr> 335 <td width="41%"> 336 <p align="center"><font size="2">A10</font></p> 337 </td> 338 <td width="59%"> 339 <p align="center"><font size="2">74x105></font></p> 340 </td> 341 </tr> 342 <tr> 343 <td width="41%"> 344 <p align="center"><font size="2">B0</font></p> 345 </td> 346 <td width="59%"> 347 <p align="center"><font size="2">2836x4008></font></p> 348 </td> 349 </tr> 350 <tr> 351 <td width="41%"> 352 <p align="center"><font size="2">B1</font></p> 353 </td> 354 <td width="59%"> 355 <p align="center"><font size="2">2004x2836></font></p> 356 </td> 357 </tr> 358 <tr> 359 <td width="41%"> 360 <p align="center"><font size="2">B2</font></p> 361 </td> 362 <td width="59%"> 363 <p align="center"><font size="2">1418x2004></font></p> 364 </td> 365 </tr> 366 <tr> 367 <td width="41%"> 368 <p align="center"><font size="2">B3</font></p> 369 </td> 370 <td width="59%"> 371 <p align="center"><font size="2">1002x1418></font></p> 372 </td> 373 </tr> 374 <tr> 375 <td width="41%"> 376 <p align="center"><font size="2">B4</font></p> 377 </td> 378 <td width="59%"> 379 <p align="center"><font size="2">709x1002></font></p> 380 </td> 381 </tr> 382 <tr> 383 <td width="41%"> 384 <p align="center"><font size="2">B5</font></p> 385 </td> 386 <td width="59%"> 387 <p align="center"><font size="2">501x709></font></p> 388 </td> 389 </tr> 390 <tr> 391 <td width="41%"> 392 <p align="center"><font size="2">C0</font></p> 393 </td> 394 <td width="59%"> 395 <p align="center"><font size="2">2600x3677></font></p> 396 </td> 397 </tr> 398 <tr> 399 <td width="41%"> 400 <p align="center"><font size="2">C1</font></p> 401 </td> 402 <td width="59%"> 403 <p align="center"><font size="2">1837x2600></font></p> 404 </td> 405 </tr> 406 <tr> 407 <td width="41%"> 408 <p align="center"><font size="2">C2</font></p> 409 </td> 410 <td width="59%"> 411 <p align="center"><font size="2">1298x1837></font></p> 412 </td> 413 </tr> 414 <tr> 415 <td width="41%"> 416 <p align="center"><font size="2">C3</font></p> 417 </td> 418 <td width="59%"> 419 <p align="center"><font size="2">918x1298></font></p> 420 </td> 421 </tr> 422 <tr> 423 <td width="41%"> 424 <p align="center"><font size="2">C4</font></p> 425 </td> 426 <td width="59%"> 427 <p align="center"><font size="2">649x918></font></p> 428 </td> 429 </tr> 430 <tr> 431 <td width="41%"> 432 <p align="center"><font size="2">C5</font></p> 433 </td> 434 <td width="59%"> 435 <p align="center"><font size="2">459x649></font></p> 436 </td> 437 </tr> 438 <tr> 439 <td width="41%"> 440 <p align="center"><font size="2">C6</font></p> 441 </td> 442 <td width="59%"> 443 <p align="center"><font size="2">323x459></font></p> 444 </td> 445 </tr> 446 <tr> 447 <td width="41%"> 448 <p align="center"><font size="2">Flsa</font></p> 449 </td> 450 <td width="59%"> 451 <p align="center"><font size="2">612x936></font></p> 452 </td> 453 </tr> 454 <tr> 455 <td width="41%"> 456 <p align="center"><font size="2">Flse</font></p> 457 </td> 458 <td width="59%"> 459 <p align="center"><font size="2">612x936></font></p> 460 </td> 461 </tr> 462 <tr> 463 <td width="41%"> 464 <p align="center"><font size="2">HalfLetter</font></p> 465 </td> 466 <td width="59%"> 467 <p align="center"><font size="2">396x612></font></p> 468 </td> 469 </tr> 470 </table> 471<H3 align="center">Geometry Methods</H3> 472<p style="margin-bottom: 0in">Geometry provides methods to initialize 473its value from strings, from a set of parameters, or via attributes. 474The methods available for use in Geometry are shown in the following 475table: 476</p> 477<p align="center" style="margin-bottom: 0in"><b>Geometry Methods</b></p> 478<table width="100%" border="1" cellpadding="2" cellspacing="3"> 479 <col width="25*" /> 480 <col width="26*" /> 481 <col width="111*" /> 482 <col width="94*" /> 483 <tr> 484 <td width="10%"> 485 <p align="center"><b>Method</b></p> 486 </td> 487 <td width="10%"> 488 <p align="center"><b>Return Type</b></p> 489 </td> 490 <td width="44%"> 491 <p align="center"><b>Signature(s)</b></p> 492 </td> 493 <td width="37%"> 494 <p align="center"><b>Description</b></p> 495 </td> 496 </tr> 497 <tr> 498 <td rowspan="3" width="10%"> 499 <p>Geometry</p> 500 </td> 501 <td rowspan="3" width="10%" bgcolor="#666666"> 502 <p> </p> 503 </td> 504 <td width="44%"> 505 <p>size_t width_, size_t height_, ssize_t xOff_ = 506 0, ssize_t yOff_ = 0, bool xNegative_ = false, bool 507 yNegative_ = false</p> 508 </td> 509 <td width="37%"> 510 <p>Construct geometry via explicit parameters.</p> 511 </td> 512 </tr> 513 <tr> 514 <td width="44%"> 515 <p>const string geometry_</p> 516 </td> 517 <td width="37%"> 518 <p>Construct geometry from C++ string</p> 519 </td> 520 </tr> 521 <tr> 522 <td width="44%"> 523 <p>const char * geometry_</p> 524 </td> 525 <td width="37%"> 526 <p>Construct geometry from C string</p> 527 </td> 528 </tr> 529 <tr> 530 <td rowspan="2" width="10%"> 531 <p>width</p> 532 </td> 533 <td width="10%"> 534 <p>void</p> 535 </td> 536 <td width="44%"> 537 <p>size_t width_</p> 538 </td> 539 <td rowspan="2" width="37%"> 540 <p>Width</p> 541 </td> 542 </tr> 543 <tr> 544 <td width="10%"> 545 <p>size_t</p> 546 </td> 547 <td width="44%"> 548 <p>void</p> 549 </td> 550 </tr> 551 <tr> 552 <td rowspan="2" width="10%"> 553 <p>height</p> 554 </td> 555 <td width="10%"> 556 <p>void</p> 557 </td> 558 <td width="44%"> 559 <p>size_t height_</p> 560 </td> 561 <td rowspan="2" width="37%"> 562 <p>Height</p> 563 </td> 564 </tr> 565 <tr> 566 <td width="10%"> 567 <p>size_t</p> 568 </td> 569 <td width="44%"> 570 <p>void</p> 571 </td> 572 </tr> 573 <tr> 574 <td rowspan="2" width="10%"> 575 <p>xOff</p> 576 </td> 577 <td width="10%"> 578 <p>void</p> 579 </td> 580 <td width="44%"> 581 <p>ssize_t xOff_</p> 582 </td> 583 <td rowspan="2" width="37%"> 584 <p>X offset from origin</p> 585 </td> 586 </tr> 587 <tr> 588 <td width="10%"> 589 <p>ssize_t</p> 590 </td> 591 <td width="44%"> 592 <p>void</p> 593 </td> 594 </tr> 595 <tr> 596 <td rowspan="2" width="10%"> 597 <p>yOff</p> 598 </td> 599 <td width="10%"> 600 <p>void</p> 601 </td> 602 <td width="44%"> 603 <p>ssize_t yOff_</p> 604 </td> 605 <td rowspan="2" width="37%"> 606 <p>Y offset from origin</p> 607 </td> 608 </tr> 609 <tr> 610 <td width="10%"> 611 <p>size_t</p> 612 </td> 613 <td width="44%"> 614 <p>void</p> 615 </td> 616 </tr> 617 <tr> 618 <td rowspan="2" width="10%"> 619 <p>xNegative</p> 620 </td> 621 <td width="10%"> 622 <p>void</p> 623 </td> 624 <td width="44%"> 625 <p>bool xNegative_</p> 626 </td> 627 <td rowspan="2" width="37%"> 628 <p>Sign of X offset negative? (X origin at right)</p> 629 </td> 630 </tr> 631 <tr> 632 <td width="10%"> 633 <p>bool</p> 634 </td> 635 <td width="44%"> 636 <p>void</p> 637 </td> 638 </tr> 639 <tr> 640 <td rowspan="2" width="10%"> 641 <p>yNegative</p> 642 </td> 643 <td width="10%"> 644 <p>void</p> 645 </td> 646 <td width="44%"> 647 <p>bool yNegative_</p> 648 </td> 649 <td rowspan="2" width="37%"> 650 <p>Sign of Y offset negative? (Y origin at bottom)</p> 651 </td> 652 </tr> 653 <tr> 654 <td width="10%"> 655 <p>bool</p> 656 </td> 657 <td width="44%"> 658 <p>void</p> 659 </td> 660 </tr> 661 <tr> 662 <td rowspan="2" width="10%"> 663 <p>percent</p> 664 </td> 665 <td width="10%"> 666 <p>void</p> 667 </td> 668 <td width="44%"> 669 <p>bool percent_</p> 670 </td> 671 <td rowspan="2" width="37%"> 672 <p>Width and height are expressed as percentages</p> 673 </td> 674 </tr> 675 <tr> 676 <td width="10%"> 677 <p>bool</p> 678 </td> 679 <td width="44%"> 680 <p>void</p> 681 </td> 682 </tr> 683 <tr> 684 <td rowspan="2" width="10%"> 685 <p>aspect</p> 686 </td> 687 <td width="10%"> 688 <p>void</p> 689 </td> 690 <td width="44%"> 691 <p>bool aspect_</p> 692 </td> 693 <td rowspan="2" width="37%"> 694 <p>Resize without preserving aspect ratio (!)</p> 695 </td> 696 </tr> 697 <tr> 698 <td width="10%"> 699 <p>bool</p> 700 </td> 701 <td width="44%"> 702 <p>void</p> 703 </td> 704 </tr> 705 <tr> 706 <td rowspan="2" width="10%"> 707 <p>greater</p> 708 </td> 709 <td width="10%"> 710 <p>void</p> 711 </td> 712 <td width="44%"> 713 <p>bool greater_</p> 714 </td> 715 <td rowspan="2" width="37%"> 716 <p>Resize if image is greater than size (>)</p> 717 </td> 718 </tr> 719 <tr> 720 <td width="10%"> 721 <p>bool</p> 722 </td> 723 <td width="44%"> 724 <p>void</p> 725 </td> 726 </tr> 727 <tr> 728 <td rowspan="2" width="10%"> 729 <p>less</p> 730 </td> 731 <td width="10%"> 732 <p>void</p> 733 </td> 734 <td width="44%"> 735 <p>bool less_</p> 736 </td> 737 <td rowspan="2" width="37%"> 738 <p>Resize if image is less than size (<)</p> 739 </td> 740 </tr> 741 <tr> 742 <td width="10%"> 743 <p>bool</p> 744 </td> 745 <td width="44%"> 746 <p>void</p> 747 </td> 748 </tr> 749 <tr> 750 <td rowspan="2" width="10%"> 751 <p>isValid</p> 752 </td> 753 <td width="10%"> 754 <p>void</p> 755 </td> 756 <td width="44%"> 757 <p>bool isValid_</p> 758 </td> 759 <td rowspan="2" width="37%"> 760 <p>Does object contain a valid geometry? May be set to <i>false</i> 761 in order to invalidate an existing geometry object.</p> 762 </td> 763 </tr> 764 <tr> 765 <td width="10%"> 766 <p>bool</p> 767 </td> 768 <td width="44%"> 769 <p>void</p> 770 </td> 771 </tr> 772 <tr> 773 <td width="10%"> 774 <p>operator =</p> 775 </td> 776 <td width="10%"> 777 <p>const Geometry&</p> 778 </td> 779 <td width="44%"> 780 <p>const string geometry_</p> 781 </td> 782 <td width="37%"> 783 <p>Set geometry via C++ string</p> 784 </td> 785 </tr> 786 <tr> 787 <td width="10%"> 788 <p>operator =</p> 789 </td> 790 <td width="10%"> 791 <p>const Geometry&</p> 792 </td> 793 <td width="44%"> 794 <p>const char * geometry_</p> 795 </td> 796 <td width="37%"> 797 <p>Set geometry via C string</p> 798 </td> 799 </tr> 800 <tr> 801 <td width="10%"> 802 <p>operator string</p> 803 </td> 804 <td width="10%"> 805 <p>string</p> 806 </td> 807 <td width="44%"> 808 <p>Geometry&</p> 809 </td> 810 <td width="37%"> 811 <p>Obtain C++ string representation of geometry</p> 812 </td> 813 </tr> 814</table> 815<p>In addition, we support these yet to be documented geometry flags: the fill area flag ('^') and the pixel area count limit flag ('@').</p> 816<p><br /><br /> 817</p> 818</div> 819</body> 820</html> 821