Пример #1
0
<?php

/*
  Run on console: php image.php
*/
require_once '../src/PLib.php';
PLib\import('image');
$img1 = new PLib\Image('assets/feet.jpg');
// Copy the image
// Scale it to max width 700 or max height 700
// Crop it around the center to a size of 500x500 pixels
$img2 = $img1->copy('feet2.jpg')->scale(700, 700)->crop_center(500, 500);
// Now lets manipulate the image outside of the object with some standalone
// PHP image functions.
// Grab the image resource handler from the object
$ih = $img2->resource();
/*
    Manipulate the image as you see fit
*/
$font = PLib\combine_path(dirname(__FILE__), 'assets/Ubuntu-B.ttf');
$text = 'Summertime';
$white = imagecolorallocate($ih, 255, 255, 255);
$black = imagecolorallocate($ih, 0, 0, 0);
imagettftext($ih, 24.0, 0.0, 21, 51, $black, $font, $text);
imagettftext($ih, 24.0, 0.0, 20, 50, $white, $font, $text);
// And while we're at it, make it sepia and save it all
$img2->sepia()->save();
Пример #2
0
Файл: net.php Проект: poppa/PLib
 /**
  * Constructor
  *
  * @throws Exception
  *
  * @param string $name
  *  The name of the cookie file to use
  * @param string $path
  *  The path where to save the cookie file
  */
 public function __construct($name, $path = null)
 {
     $this->name = $name;
     if ($path) {
         $this->path = $path;
     }
     if (!is_writable($this->path)) {
         throw new Exception("The path \"{$this->path}\" is not writable so " . "cookies can not be saved");
     }
     $this->cookiejar = \PLib\combine_path($this->path, $this->name);
 }
Пример #3
0
Файл: io.php Проект: poppa/PLib
 /**
  * Rename the file
  *
  * @api
  * @param string $new_name
  * @return string
  *  Returns the new full path to the file
  */
 public function rename($new_name)
 {
     $nn = PLib\combine_path(dirname($this->file), $new_name);
     rename($this->path, $nn);
     $this->init_file($nn);
     return $this->path;
 }