SimpleImage::create PHP Method

create() public method

Create an image from scratch
public create ( integer $width, integer | null $height = null, null | string $color = null ) : SimpleImage
$width integer Image width
$height integer | null If omitted - assumed equal to $width
$color null | string Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127
return SimpleImage
    function create($width, $height = null, $color = null)
    {
        $height = $height ?: $width;
        $this->width = $width;
        $this->height = $height;
        $this->image = imagecreatetruecolor($width, $height);
        $this->original_info = array('width' => $width, 'height' => $height, 'orientation' => $this->get_orientation(), 'exif' => null, 'format' => 'png', 'mime' => 'image/png');
        if ($color) {
            $this->fill($color);
        }
        return $this;
    }

Usage Example

Example #1
0
         case 1:
             echo '<b>' . $content->getValue("dodaj", "niewypelniono") . '</b><br/><a href="dodaj.php">&laquo; ' . $content->getValue("global", "powrot") . '</a>';
             exit;
             break;
     }
 }
 $tresc = @htmlspecialchars(mysqli_real_escape_string($db, $_POST['tresc']));
 $tytul = @htmlspecialchars(mysqli_real_escape_string($db, $_POST['tytul']));
 $zrodlo = @htmlspecialchars(mysqli_real_escape_string($db, $_POST['zrodlo']));
 $autor = $user->userInfo("id");
 $data = date('Y-m-d H:i:s');
 $image = new SimpleImage();
 $imageType = "";
 switch ($_POST['type']) {
     case 'tekst':
         if (!$image->create($tresc)) {
             echo '<b>' . $content->getValue("dodaj", "zadlugiText") . '</b><br/><a href="dodaj.php">&laquo; ' . $content->getValue("global", "powrot") . '</a>';
             exit;
         }
         $imageType = "wiedza";
         break;
     case 'tekst_obrazek':
         $data_img = date("YmdHis");
         $sp1 = pathinfo($_FILES['obrazek']['name']);
         $tmp_file = 'img/upload/tmp/' . $data_img . '.' . $sp1['extension'];
         if (filesize($_FILES['obrazek']['tmp_name']) / 1024 >= $conf->pobierz('max_file_size')) {
             echo '<b>' . sprintf($content->getValue("dodaj", "obrazekZaduzy"), $conf->pobierz('max_file_size')) . "KB" . '</b><br/><a href="dodaj.php">&laquo; ' . $content->getValue("global", "powrot") . '</a>';
             exit;
         }
         switch (uploadFile('obrazek', 'img/upload/tmp/', array(1 => 'jpg', 'jpeg', 'gif', 'png', 'JPG', 'JPEG', 'GIF', 'PNG'), 0, $data_img)) {
             case 0: