예제 #1
0
 public function testhandleDuplicates()
 {
     try {
         $eImage = new eImage(['Source' => 'tests/assets/r_image.jpeg', 'ReturnType' => 'bool', 'PadColor' => '#FFFFFF']);
         $this->assertTrue($eImage->resize(200, 300));
         $eImage->set(['Duplicates' => 'u']);
         $this->assertTrue($eImage->crop(100, 150, -50, 50));
         $this->assertTrue(file_exists('tests/assets/r_image_0.jpeg'));
         $eImage->set(['Source' => 'tests/assets/c_image.jpeg', 'Duplicates' => 'e', 'ScaleUp' => true]);
         $eImage->resize(500, 500);
     } catch (eImageException $e) {
         $this->assertEquals(eImageException::IMAGE_EXIST, $e->getMessage());
     }
     $this->assertTrue(isset($e));
 }
예제 #2
0
파일: Crop.php 프로젝트: falmar/eImage
 * Project: eImage
 * Date: 12/22/15
 * Time: 1:19 PM
 *
 * @link      https://github.com/falmar/eImage
 * @author    David Lavieri (falmar) <*****@*****.**>
 * @copyright 2015 David Lavieri
 * @license   http://opensource.org/licenses/MIT The MIT License (MIT)
 */
use Falmar\eImage\eImage;
use Falmar\eImage\eImageException;
/** Upload your image **/
$File = isset($_FILES['img']) ? $_FILES['img'] : null;
require_once '../vendor/autoload.php';
try {
    /**
     * Crop from upload
     */
    $Image = new eImage();
    $Image->upload($File);
    $Image->crop(250, 250, -50, -75);
    /** -------------------------------------------------- */
    /**
     * Crop from source file
     */
    $Image->set(['Source' => 'path_to_your_file.jpg', 'Prefix' => 'AfterCrop-']);
    $Image->crop(250, 250, -50, -75);
} catch (eImageException $e) {
    echo $e->getMessage();
    /** do something else **/
}
예제 #3
0
파일: Resize.php 프로젝트: falmar/eImage
 * Project: eImage
 * Date: 12/23/15
 * Time: 20:15 PM
 *
 * @link      https://github.com/falmar/eImage
 * @author    David Lavieri (falmar) <*****@*****.**>
 * @copyright 2015 David Lavieri
 * @license   http://opensource.org/licenses/MIT The MIT License (MIT)
 */
use Falmar\eImage\eImage;
use Falmar\eImage\eImageException;
/** Upload your image **/
$File = isset($_FILES['img']) ? $_FILES['img'] : null;
require_once '../vendor/autoload.php';
try {
    /**
     * Resize from upload
     */
    $Image = new eImage();
    $Image->upload($File);
    $Image->resize(600, 450);
    /** -------------------------------------------------- */
    /**
     * Resize from source file
     */
    $Image->set(['Source' => 'my_source_image.jpg', 'Prefix' => 'AfterResize-', 'AspectRatio' => false, 'ScaleUp' => true]);
    $Image->resize(600, 205);
} catch (eImageException $e) {
    echo $e->getMessage();
    /** do something else **/
}
예제 #4
0
파일: Upload.php 프로젝트: falmar/eImage
 *
 * @link      https://github.com/falmar/eImage
 * @author    David Lavieri (falmar) <*****@*****.**>
 * @copyright 2015 David Lavieri
 * @license   http://opensource.org/licenses/MIT The MIT License (MIT)
 */
use Falmar\eImage\eImage;
use Falmar\eImage\eImageException;
/** Upload your image **/
$File = isset($_FILES['img']) ? $_FILES['img'] : null;
require_once '../vendor/autoload.php';
try {
    /**
     * Simple Upload
     */
    $Image = new eImage();
    $Image->upload($File);
    /** ---------- run one or another but not both --------- */
    /**
     * the next code will do the following:
     * Rename the image to my_new_image.
     * Place the uploaded image into base_dir/Images/
     * Create a new unique image if find an existing one.
     * return an array with the new image properties.
     */
    $Image = new eImage(['NewName' => 'my_new_name.bmp', 'UploadTo' => 'Images/', 'Duplicates' => 'u', 'ReturnType' => 'array']);
    $Image->upload($File);
} catch (eImageException $e) {
    echo $e->getMessage();
    /** do something else **/
}