Type to search...

Resizing and cropping images

Some short examples in resizing and cropping topics.

Examples

  • resizing the width to 150 px, maintaining the aspect ratio:
    w:150
w:150
width:150
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(150);
  • resizing the height to 50 px, maintaining the aspect ratio:
    h:50
h:50
height:50
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->height(50);
  • 300x80 px cropping the image still maintaining the aspect ratio:
    w:300_h:80
w:300_h:80
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(300)->height(80);
  • highlighting 300x80 px strip from the image:
    1. resizing width of the original image to 300px w:300
    2. adding slightly blur effect e:blur:250 (w:300_e:blur:250)
    3. add lighten effect to the image (white background + opacity) w:300_e:blur:250_e:o:30
    4. adding the original picture as a layer to a new transformation group w:300_h:80_l:lo:steve

w:300_e:blur:250_e:o:30/w:300_h:80_l:lo:steve

w:300_e:blur:250_e:o:30/w:300_h:80_l:lo:steve
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(300)->blur(250)->opacity(30)->group()->width(300)->height(80)->overlay('steve');
  • 100x100px resizing without maintaining aspect ratio:
    w:100_h:100_c:scale
w:100_h:100_c:scale
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(100)->height(100)->scale();
  • 200x200px image with focusing on face round the corners
    1. focusing on face g:face
    2. resizing to 200x200px wh:200 (g:face/wh:200)
    3. rounding the corners with max radius ro:max (g:face/wh:200_ro:max)

g:face/wh:200_ro:max

g:face/wh:200_ro:max
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->gFace()->group()->size(200)->roundMax();
  • Resizing the image width to 200px, without cropping and filling to 200x200px:

    1. resizing to 200px w:200
    2. new group / (w:200/)
    3. resizing to 200x200px wh:200 (w:200/wh:200)
    4. cropping with padding mode c:pad (w:200/wh:200_c:pad)
    5. addig green background to the new image area bg:green (w:200/wh:200_c:pad_bg:green)

g:face/wh:200_ro:max

w:200/wh:200_c:pad_bg:green
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(200)->group()->size(200)->pad()->background('green');
Table of contents