PHP code example of falmar / eimage

1. Go to this page and download the library: Download falmar/eimage library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

falmar / eimage example snippets


use eImage\eImage;
use eImage\eImageException;

/** Upload your image **/
$File = (isset($_FILES['img'])) ? $_FILES['img'] : null;

--------------- */

  /**
   * 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',
      'UploadTo'   => 'Images/',
      'Duplicates' => 'u',
      'ReturnType' => 'array'
  ]);
  $Image->upload($File);
  
} catch (eImageException $e){
  /** do something **/
}


use eImage\eImage;
use eImage\eImageException;

/** Upload your image **/
$File = (isset($_FILES['img'])) ? $_FILES['img'] : null;

);

   /** -------------------------------------------------- */

   /**
    * Crop from source file
    */
   $Image->set([
       'Source' => 'path_to_your_file.jpg',
       'Prefix' => 'AfterCrop-'
   ]);
   $Image->crop(250, 250, -50, -75);
  
} catch (eImageException $e){
  /** do something **/
}


use eImage\eImage;
use eImage\eImageException;

/** Upload your image **/
$File = (isset($_FILES['img'])) ? $_FILES['img'] : null;

 /** -------------------------------------------------- */


   /**
    * Resize from source file
    */
   $Image->set([
       'Source' => 'my_source_image.jpg',
       'Prefix' => 'AfterResize-',
       'AspectRatio' => false,
       'ScaleUp' => true
   ]);
   $Image->resize(600, 205);
  
} catch (eImageException $e){
  /** do something **/
}


public $NewName;

public $UploadTo;

public $ReturnType = 'full_path';

public $SafeRename = true;

public $Duplicates = 'o';

private $EnableMIMEs = [
    '.jpe'  => 'image/jpeg',
    '.jpg'  => 'image/jpg',
    '.jpeg' => 'image/jpeg',
    '.gif'  => 'image/gif',
    '.png'  => 'image/png',
    '.bmp'  => 'image/bmp',
    '.ico'  => 'image/x-icon',
];
private $DisabledMIMEs = [];

public $CreateDir = false;

public $Source;

public $ImageQuality = 90;

public $NewExtension;

public $Prefix;

public $NewPath;

public $AspectRatio = true;

public $Oversize = false;

public $ScaleUp = false;

public $Position = 'cc';

public $FitPad = true;

public $PadColor = 'transparent';

['.jpg' => 'image/jpg']