| | 521 | |
| | 522 | =head2 MT::Image->inscribe_square( %arg ) |
| | 523 | |
| | 524 | Calculates a square of dimensions that are capable of holding an image |
| | 525 | of the height and width indicated. This method receives I<%arg>, which |
| | 526 | may contain: |
| | 527 | |
| | 528 | =over 4 |
| | 529 | |
| | 530 | =item * Height |
| | 531 | |
| | 532 | =item * Width |
| | 533 | |
| | 534 | =back |
| | 535 | |
| | 536 | The square will be the smaller value of the Height and Width parameter. |
| | 537 | |
| | 538 | The method returns a hash containing the following information: |
| | 539 | |
| | 540 | =over 4 |
| | 541 | |
| | 542 | =item * Size |
| | 543 | |
| | 544 | The size of the calculated square, in pixels. |
| | 545 | |
| | 546 | =item * X |
| | 547 | |
| | 548 | The horizontal space to crop from the image, in pixels. |
| | 549 | |
| | 550 | =item * Y |
| | 551 | |
| | 552 | The vertical space to crop from the image, in pixels. |
| | 553 | |
| | 554 | =back |
| | 555 | |
| | 556 | This information is suited for the L<crop> method. |
| | 557 | |
| | 558 | =head2 $img->make_square() |
| | 559 | |
| | 560 | Takes an image which may or may not be a square in dimension and forces |
| | 561 | it into a square shape (trimming the longer side, as necesary). |
| | 572 | =head2 MT::Image->check_upload( %arg ) |
| | 573 | |
| | 574 | Utility method used to handle image upload and storage, along with some |
| | 575 | constraining factors. The I<%arg> hash may contain the following elements: |
| | 576 | |
| | 577 | =over 4 |
| | 578 | |
| | 579 | =item * Fh |
| | 580 | |
| | 581 | A filehandle for the uploaded file. |
| | 582 | |
| | 583 | =item * Fmgr |
| | 584 | |
| | 585 | A handle to a L<MT::FileMgr> object that will be used for writing the |
| | 586 | file into place. |
| | 587 | |
| | 588 | =item * Local |
| | 589 | |
| | 590 | A path and filename for the location to write the uploaded file. |
| | 591 | |
| | 592 | =item * Max (optional) |
| | 593 | |
| | 594 | A number that specifies the maximum physical file size for the uploaded |
| | 595 | image (specified in bytes). |
| | 596 | |
| | 597 | =item * MaxDim (optional) |
| | 598 | |
| | 599 | A number that specifies the maximum dimension allowed for the uploaded |
| | 600 | image (specified in pixels). |
| | 601 | |
| | 602 | =back |
| | 603 | |
| | 604 | If the uploaded image is valid and passes the file size and image |
| | 605 | dimension requirements (assuming those parameters are given), |
| | 606 | the return value is a list consisting of the following elements: |
| | 607 | |
| | 608 | =over 4 |
| | 609 | |
| | 610 | =item * $width |
| | 611 | |
| | 612 | The width of the uploaded image, in pixels. |
| | 613 | |
| | 614 | =item * $height |
| | 615 | |
| | 616 | The height of the uploaded image, in pixels. |
| | 617 | |
| | 618 | =item * $id |
| | 619 | |
| | 620 | A string identifying the type of image file (returned by L<Image::Size>, |
| | 621 | so typically "GIF", "JPG", "PNG"). |
| | 622 | |
| | 623 | =item * $write_coderef |
| | 624 | |
| | 625 | A Perl coderef that, when invoked writes the image to the specified |
| | 626 | location. |
| | 627 | |
| | 628 | =back |
| | 629 | |
| | 630 | If any error occurs from this routine, it will return 'undef', and |
| | 631 | assign the error message, accessible using the L<errstr> class method. |
| | 632 | |