├── .gitignore ├── README ├── tests ├── README └── DdImageBasicTest.php ├── LICENSE └── lib └── dd_image_ImageResizer.php /.gitignore: -------------------------------------------------------------------------------- 1 | .buildpath 2 | .project 3 | .settings 4 | ._* 5 | build 6 | dist 7 | repos 8 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Dragonfly Development PHP Image Library 2 | http://dflydev.com/d2code/php/dd-image-php/ 3 | 4 | 5 | dd-image is useful for doing simple image manipulation operations. 6 | -------------------------------------------------------------------------------- /tests/README: -------------------------------------------------------------------------------- 1 | Testing with PHPUnit (http://www.phpunit.de/) 2 | 3 | To run an individual test: 4 | 5 | phpunit SpecificTest.php 6 | 7 | To run all tests it is best to execute the Phing build script 8 | which has the appropriate filters setup to ensure that only 9 | the tests that need to be run will be run. 10 | 11 | phing test 12 | -------------------------------------------------------------------------------- /tests/DdImageBasicTest.php: -------------------------------------------------------------------------------- 1 | 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Dragonfly Development Inc 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Dragonfly Development Inc nor the names of its 13 | contributors may be used to endorse or promote products derived from 14 | this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /lib/dd_image_ImageResizer.php: -------------------------------------------------------------------------------- 1 | $widthRatio ) ? $heightRatio : $widthRatio; 381 | 382 | $dstW = $origWidth * $overallRatio; 383 | $dstH = $origHeight * $overallRatio; 384 | 385 | //echo " [ ( ($dstW > $origWidth) or ($dstH > $origHeight) ) ]\n"; 386 | if ( ($dstW > $origWidth) or ($dstH > $origHeight) ) { 387 | if ( $shrinkOnly ) { 388 | $dstW = $origWidth; 389 | $dstH = $origHeight; 390 | } 391 | } 392 | 393 | $targetWidth = $dstW > $maxWidth ? $maxWidth : $dstW; 394 | $targetHeight = $dstH > $maxHeight ? $maxHeight : $dstH; 395 | 396 | if ( $targetWidth < $dstW ) 397 | { 398 | $dstX = ( ($dstW - $targetWidth) / 2 ) * -1; 399 | } 400 | 401 | if ( $targetHeight < $dstH ) 402 | { 403 | $dstY = ( ($dstH - $targetHeight) / 2 ) * -1; 404 | } 405 | 406 | } 407 | 408 | return array($targetWidth, $targetHeight, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH); 409 | 410 | } 411 | 412 | } 413 | 414 | ?> 415 | --------------------------------------------------------------------------------