"Fossies" - the Fresh Open Source Software Archive

Member "grav/vendor/gregwar/image/Gregwar/Image/Adapter/AdapterInterface.php" (8 Jun 2020, 8527 Bytes) of package /linux/www/grav-v1.6.26.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AdapterInterface.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Gregwar\Image\Adapter;
    4 
    5 use Gregwar\Image\Image;
    6 use Gregwar\Image\Source\Source;
    7 
    8 /**
    9  * all the functions / methods to work on images.
   10  *
   11  * if changing anything please also add it to \Gregwar\Image\Image
   12  *
   13  * @author wodka <michael.schramm@gmail.com>
   14  */
   15 interface AdapterInterface
   16 {
   17     /**
   18      * set the image source for the adapter.
   19      *
   20      * @param Source $source
   21      *
   22      * @return $this
   23      */
   24     public function setSource(Source $source);
   25 
   26     /**
   27      * get the raw resource.
   28      *
   29      * @return resource
   30      */
   31     public function getResource();
   32 
   33     /**
   34      * Gets the name of the adapter.
   35      *
   36      * @return string
   37      */
   38     public function getName();
   39 
   40     /**
   41      * Image width.
   42      *
   43      * @return int
   44      */
   45     public function width();
   46 
   47     /**
   48      * Image height.
   49      *
   50      * @return int
   51      */
   52     public function height();
   53 
   54     /**
   55      * Init the resource.
   56      *
   57      * @return $this
   58      */
   59     public function init();
   60 
   61     /**
   62      * Unload the resource
   63      */
   64     public function deinit();
   65 
   66     /**
   67      * Save the image as a gif.
   68      *
   69      * @return $this
   70      */
   71     public function saveGif($file);
   72 
   73     /**
   74      * Save the image as a png.
   75      *
   76      * @return $this
   77      */
   78     public function savePng($file);
   79 
   80     /**
   81      * Save the image as a Webp.
   82      *
   83      * @return $this
   84      */
   85     public function saveWebp($file, $quality);
   86 
   87     /**
   88      * Save the image as a jpeg.
   89      *
   90      * @return $this
   91      */
   92     public function saveJpeg($file, $quality);
   93 
   94     /**
   95      * Works as resize() excepts that the layout will be cropped.
   96      *
   97      * @param int $width      the width
   98      * @param int $height     the height
   99      * @param int $background the background
  100      *
  101      * @return $this
  102      */
  103     public function cropResize($width = null, $height = null, $background = 0xffffff);
  104 
  105     /**
  106      * Resize the image preserving scale. Can enlarge it.
  107      *
  108      * @param int  $width      the width
  109      * @param int  $height     the height
  110      * @param int  $background the background
  111      * @param bool $crop
  112      *
  113      * @return $this
  114      */
  115     public function scaleResize($width = null, $height = null, $background = 0xffffff, $crop = false);
  116 
  117     /**
  118      * Resizes the image. It will never be enlarged.
  119      *
  120      * @param int  $width      the width
  121      * @param int  $height     the height
  122      * @param int  $background the background
  123      * @param bool $force
  124      * @param bool $rescale
  125      * @param bool $crop
  126      *
  127      * @return $this
  128      */
  129     public function resize($width = null, $height = null, $background = 0xffffff, $force = false, $rescale = false, $crop = false);
  130 
  131     /**
  132      * Crops the image.
  133      *
  134      * @param int $x      the top-left x position of the crop box
  135      * @param int $y      the top-left y position of the crop box
  136      * @param int $width  the width of the crop box
  137      * @param int $height the height of the crop box
  138      *
  139      * @return $this
  140      */
  141     public function crop($x, $y, $width, $height);
  142 
  143     /**
  144      * enable progressive image loading.
  145      *
  146      * @return $this
  147      */
  148     public function enableProgressive();
  149 
  150     /**
  151      * Resizes the image forcing the destination to have exactly the
  152      * given width and the height.
  153      *
  154      * @param int $width      the width
  155      * @param int $height     the height
  156      * @param int $background the background
  157      *
  158      * @return $this
  159      */
  160     public function forceResize($width = null, $height = null, $background = 0xffffff);
  161 
  162     /**
  163      * Perform a zoom crop of the image to desired width and height.
  164      *
  165      * @param int $width      Desired width
  166      * @param int $height     Desired height
  167      * @param int $background
  168      *
  169      * @return $this
  170      */
  171     public function zoomCrop($width, $height, $background = 0xffffff);
  172 
  173     /**
  174      * Fills the image background to $bg if the image is transparent.
  175      *
  176      * @param int $background background color
  177      *
  178      * @return $this
  179      */
  180     public function fillBackground($background = 0xffffff);
  181 
  182     /**
  183      * Negates the image.
  184      *
  185      * @return $this
  186      */
  187     public function negate();
  188 
  189     /**
  190      * Changes the brightness of the image.
  191      *
  192      * @param int $brightness the brightness
  193      *
  194      * @return $this
  195      */
  196     public function brightness($brightness);
  197 
  198     /**
  199      * Contrasts the image.
  200      *
  201      * @param int $contrast the contrast [-100, 100]
  202      *
  203      * @return $this
  204      */
  205     public function contrast($contrast);
  206 
  207     /**
  208      * Apply a grayscale level effect on the image.
  209      *
  210      * @return $this
  211      */
  212     public function grayscale();
  213 
  214     /**
  215      * Emboss the image.
  216      *
  217      * @return $this
  218      */
  219     public function emboss();
  220 
  221     /**
  222      * Smooth the image.
  223      *
  224      * @param int $p value between [-10,10]
  225      *
  226      * @return $this
  227      */
  228     public function smooth($p);
  229 
  230     /**
  231      * Sharps the image.
  232      *
  233      * @return $this
  234      */
  235     public function sharp();
  236 
  237     /**
  238      * Edges the image.
  239      *
  240      * @return $this
  241      */
  242     public function edge();
  243 
  244     /**
  245      * Colorize the image.
  246      *
  247      * @param int $red   value in range [-255, 255]
  248      * @param int $green value in range [-255, 255]
  249      * @param int $blue  value in range [-255, 255]
  250      *
  251      * @return $this
  252      */
  253     public function colorize($red, $green, $blue);
  254 
  255     /**
  256      * apply sepia to the image.
  257      *
  258      * @return $this
  259      */
  260     public function sepia();
  261 
  262     /**
  263      * Merge with another image.
  264      *
  265      * @param Image $other
  266      * @param int   $x
  267      * @param int   $y
  268      * @param int   $width
  269      * @param int   $height
  270      *
  271      * @return $this
  272      */
  273     public function merge(Image $other, $x = 0, $y = 0, $width = null, $height = null);
  274 
  275     /**
  276      * Rotate the image.
  277      *
  278      * @param float $angle
  279      * @param int   $background
  280      *
  281      * @return $this
  282      */
  283     public function rotate($angle, $background = 0xffffff);
  284 
  285     /**
  286      * Fills the image.
  287      *
  288      * @param int $color
  289      * @param int $x
  290      * @param int $y
  291      *
  292      * @return $this
  293      */
  294     public function fill($color = 0xffffff, $x = 0, $y = 0);
  295 
  296     /**
  297      * write text to the image.
  298      *
  299      * @param string $font
  300      * @param string $text
  301      * @param int    $x
  302      * @param int    $y
  303      * @param int    $size
  304      * @param int    $angle
  305      * @param int    $color
  306      * @param string $align
  307      */
  308     public function write($font, $text, $x = 0, $y = 0, $size = 12, $angle = 0, $color = 0x000000, $align = 'left');
  309 
  310     /**
  311      * Draws a rectangle.
  312      *
  313      * @param int  $x1
  314      * @param int  $y1
  315      * @param int  $x2
  316      * @param int  $y2
  317      * @param int  $color
  318      * @param bool $filled
  319      *
  320      * @return $this
  321      */
  322     public function rectangle($x1, $y1, $x2, $y2, $color, $filled = false);
  323 
  324     /**
  325      * Draws a rounded rectangle.
  326      *
  327      * @param int  $x1
  328      * @param int  $y1
  329      * @param int  $x2
  330      * @param int  $y2
  331      * @param int  $radius
  332      * @param int  $color
  333      * @param bool $filled
  334      *
  335      * @return $this
  336      */
  337     public function roundedRectangle($x1, $y1, $x2, $y2, $radius, $color, $filled = false);
  338 
  339     /**
  340      * Draws a line.
  341      *
  342      * @param int $x1
  343      * @param int $y1
  344      * @param int $x2
  345      * @param int $y2
  346      * @param int $color
  347      *
  348      * @return $this
  349      */
  350     public function line($x1, $y1, $x2, $y2, $color = 0x000000);
  351 
  352     /**
  353      * Draws an ellipse.
  354      *
  355      * @param int  $cx
  356      * @param int  $cy
  357      * @param int  $width
  358      * @param int  $height
  359      * @param int  $color
  360      * @param bool $filled
  361      *
  362      * @return $this
  363      */
  364     public function ellipse($cx, $cy, $width, $height, $color = 0x000000, $filled = false);
  365 
  366     /**
  367      * Draws a circle.
  368      *
  369      * @param int  $cx
  370      * @param int  $cy
  371      * @param int  $r
  372      * @param int  $color
  373      * @param bool $filled
  374      *
  375      * @return $this
  376      */
  377     public function circle($cx, $cy, $r, $color = 0x000000, $filled = false);
  378 
  379     /**
  380      * Draws a polygon.
  381      *
  382      * @param array $points
  383      * @param int   $color
  384      * @param bool  $filled
  385      *
  386      * @return $this
  387      */
  388     public function polygon(array $points, $color, $filled = false);
  389 
  390     /**
  391      * Flips the image.
  392      *
  393      * @param int $flipVertical
  394      * @param int $flipHorizontal
  395      *
  396      * @return $this
  397      */
  398     public function flip($flipVertical, $flipHorizontal);
  399 }