PHP Classes

File: demo2_cropping.php

Recommend this page to a friend!
  Classes of Jakob Riedle   Imagedit Pro   demo2_cropping.php   Download  
File: demo2_cropping.php
Role: Example script
Content type: text/plain
Description: Demo 2: Cropping
Class: Imagedit Pro
Image manipulation operations and face detection
Author: By
Last change: None
Date: 13 years ago
Size: 1,070 bytes
 

Contents

Class file image Download
<?php
   
include("class.imagedit.php");
    function
crop1($url)
    {
       
$image = new imagedit($url);
       
$image->crop(
           
40 /* x */
           
, 80 /* y */
           
, 400 /* width */
           
, 100 /* height */
       
);
       
        return
$image->getPNG();
    }
    function
crop2($url)
    {
       
$image = new imagedit($url);
       
$image->cropBorder(
           
40 /* left */
           
, 40 /* top */
           
, 200 /* right */
           
, 100 /* bottom */
       
);
       
        return
$image->getPNG();
    }
    function
crop3($url)
    {
       
$image = new imagedit($url);
        if(
$image->hasFace() )
           
$image->cropFace(
               
true /* Optional: Preserve Aspect Ratio */
           
);
       
        return
$image->getJPG();
    }
?>
<body style="background: yellow;">
    <h1>Imagedit Demo 2: Cropping</h1>
    <img style="border: 1px solid black;" src="data:image/png;base64,<?=base64_encode(crop1("test.png"))?>"></img>
    <img style="border: 1px solid black;"src="data:image/png;base64,<?=base64_encode(crop2("test.png"))?>"></img>
    <img style="border: 1px solid black;"src="data:image/jpg;base64,<?=base64_encode(crop3("portrait.png"))?>"></img>
</body>