Create new image

@param string $path = NULL

@return string
340785
public function create(String $path = NULL) : String
    {
        if( isset($this->sets['filePath']) )
        {
            $path = $this->sets['filePath'];
        }

        # It keeps the used filters belonging to the GD class.
        # [5.7.8]added
        $this->sets['filters'] = $this->filters;

        $settings = $this->sets;
        
        $this->sets = [];

        return $this->image->thumb($path, $settings);
    }
1049612
public function image($path, $imagestyle_id = null, $absolute = false)
    {
        return $this->image->getUrl($path, $imagestyle_id, $absolute);
    }
402932
public static function get($path)
    {
        if (is_dir($path)) {
            return new filesystem\Directory($path);
        }
        return new filesystem\File($path);
    }
1308797
public static Image newActionImage (String path, ClickHandler onClick)
    {
        return newActionImage(path, null, onClick);
    }
549688
public function watermark($path = null)
    {
        if (is_null($path)) {
            $this->watermarkPath(config('images.watermark_path'));
        }
        $this->watermarkPath($path);
        $this->todo('watermark');

        return $this;
    }
500268
private function getImagePath($path)
    {
        if ($path && file_exists($this->filesystem->getRootDir() . $path)) {
            return $path;
        }

        return $this->noImagePath;
    }
1350910
public function save($path)
    {

        switch ( $this->imageType ) {
            case IMAGETYPE_GIF:
                $returnData = imagegif( $this->image, $path );
                break;

            case IMAGETYPE_PNG:
                $returnData = imagepng( $this->image, $path );
                break;

            case IMAGETYPE_JPEG:
                $returnData = imagejpeg( $this->image, $path );
                break;

            case IMAGETYPE_BMP:
                $returnData = imagewbmp( $this->image, $path );
                break;

            // If the image is not one of the previous mimetype
            // We throw an exception
            default:
                throw new Exception( sprintf( 'This MimeType is not supported: %s. Image processed: %s', image_type_to_mime_type( $this->imageType ), $this->originalImagePath ) );
                break;
        }

        // Return this for chaning
        return $this;
    }
1256
public static function _Load ($path)
	{
		
		// Check file exists
		
		if (!parent::_Exists ($path))
		{
			return FALSE;
		}
		
		// Set image resource
		
		$image	= FALSE;
		
		// Switch image type and load
		
		switch (self::_getMIME ($path))
		{
			
			// gif
			
			case IMAGETYPE_GIF:
				$image		= imagecreatefromgif ($path);
				break;
				
			// png	
			
			case IMAGETYPE_PNG:
				$resImg		= imagecreatefrompng ($path);
				break;
				
			// jpeg / default	
			
			default:
				$image		= imagecreatefromjpeg ($path);
				break;			
			
		}
		
		// Return image resource
		
		return $image;
		
	}
962814
public function svg( $path = null )
	{
		if( file_exists( $this->imagePath( $path ))) {
			return file_get_contents( $this->imagePath( $path ));
		}
	}
96060
public function makeFileFromPath($path)
    {
        $upchuck_path = app('upchuck')->path($path);
        $absolute_path = config('upchuck.disk.path').'/'.$upchuck_path;
        return new UploadedFile(
            $absolute_path, basename($absolute_path),
            null, null, // Default mime and error
            true); // Enable test mode so local file will be pass as uploaded
    }
53151
public function getImage($path, $throwException = true)
    {
        if ($path instanceof ImageInterface) {
            return $path;
        }

        $file = $this->getFile($path, $throwException);
        if ($file) {
            return $this->filesystem->getImage($file->getFullPath());
        }

        return null;
    }
853832
public static function create_from_path($path) {
		$project = DNProject::create();
		$project->Name = $path;
		$project->write();

		// add the administrators group as the viewers of the new project
		$adminGroup = Group::get()->filter('Code', 'administrators')->first();
		if($adminGroup && $adminGroup->exists()) {
			$project->Viewers()->add($adminGroup);
		}
		return $project;
	}
1117103
public static function createThumbnail($path, $width = 100, $height = 100, $resizeType = self::RESIZE_FILLED, $bgColor = 0xfff5ee)
    {
        $img = self::createFromFileByMime($path);

        // Build the thumbnail
        $new_img = imagecreatetruecolor($width, $height);

        if ($resizeType == self::RESIZE_FILLED) {
            // Fill the image gray
            if ( ! imagefilledrectangle($new_img, 0, 0, $width - 1, $height - 1, $bgColor)) {
                throw new \Exception('can`t create thumbnail: can`t fill new image by bg-color');
            }
        }

        // Resize and copy to the new image
        list(
            $src_x, $src_y, $src_w, $src_h,
            $dst_x, $dst_y, $dst_w, $dst_h
            )
            = self::calcResizeParams($resizeType, $img, $width, $height);
        if ( ! imagecopyresampled($new_img, $img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)) {
            throw new \Exception('can`t create thumbnail: can`t resize image');
        }

        return self::getJpegToVar($new_img);
    }
242321
public function write($path = null)
  {
    $image = $this->applyFilters();

    if ($this->extension == self::IMAGE_TYPE_JPG) {
      if ($path) {
        imagejpeg($image, $path, $this->jpgQuality);
      } else if ($this->path) {
        imagejpeg($image, $this->path, $this->jpgQuality);
      } else {
        throw new \Exception('Aucun fichier de sortie configuré.');
      }
    } else if ($this->extension == self::IMAGE_TYPE_PNG) {
      if ($path) {
        imagepng($image, $path, $this->pngCompression);
      } else if ($this->path) {
        imagepng($image, $this->path, $this->pngCompression);
      } else {
        throw new \Exception('Aucun fichier de sortie configuré.');
      }
    } else {
      throw new \Exception('Impossible de générer l\'image : extension non supportée');
    }
  }
1183943
private function get_thumbnail($path) {
	$thumbnail_fullpath = $this->get_thumbnail_path($path);
	// echo $thumbnail_fullpath.'<br>';
	// if thumbnail does not exist we generate it
	if(!file_exists($thumbnail_fullpath)) {
		// create folder if it does not exist
		if(!file_exists(dirname($thumbnail_fullpath))) {
			mkdir(dirname($thumbnail_fullpath), 0755, true);
		}
		$image = Image::make($path);
		$resized = $image->fit($this->thumbnail_width, $this->thumbnail_height);
		$resized->save($thumbnail_fullpath);
		$this->__log(__METHOD__ . ' - generating thumbnail :  '. $thumbnail_fullpath);
	}
	return $thumbnail_fullpath;
}
890265
protected function createTmb($path, $stat) {
		if (!$stat || !$this->canCreateTmb($path, $stat)) {
			return false;
		}
	
		$name = $this->tmbname($stat);
		$tmb  = $this->tmbPath.DIRECTORY_SEPARATOR.$name;
	
		// copy image into tmbPath so some drivers does not store files on local fs
		if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) {
			return false;
		}
		if (! file_put_contents($tmb, $data)) {
			return false;
		}
	
		$result = false;
	
		$tmbSize = $this->tmbSize;
	
		if (($s = getimagesize($tmb)) == false) {
			return false;
		}
	
		/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
		if ($s[0] <= $tmbSize && $s[1]  <= $tmbSize) {
			$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
	
		} else {
	
			if ($this->options['tmbCrop']) {
	
				/* Resize and crop if image bigger than thumbnail */
				if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize) ) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
					$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
				}
	
				if (($s = getimagesize($tmb)) != false) {
					$x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize)/2) : 0;
					$y = $s[1] > $tmbSize ? intval(($s[1] - $tmbSize)/2) : 0;
					$result = $this->imgCrop($tmb, $tmbSize, $tmbSize, $x, $y, 'png');
				}
	
			} else {
				$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, $this->imgLib, 'png');
				$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png' );
			}
	
		}
		if (!$result) {
			unlink($tmb);
			return false;
		}
	
		return $name;
	}
797870
public static function createFromPath($path)
    {
        if (!file_exists($path)) {
            throw new Exception\FactoryException(sprintf('Unable to open file %s', $path));
        }
        $file = new \SplFileInfo($path);
        return static::createFromSplFileInfo($file);
    }