Creates thumbnail from the original image
@param $imagePath
@param $thumbnailPath
421878
protected function createThumbnail($imagePath, $thumbnailPath) {
        if ($this->config['images']['thumbnail']['enabled'] === true) {
            Log::info('generating thumbnail "' . $thumbnailPath . '"');

            // create folder if it does not exist
            if (!file_exists(dirname($thumbnailPath))) {
                mkdir(dirname($thumbnailPath), 0755, true);
            }

            $this->initUploader([
                'upload_dir' => dirname($imagePath) . '/',
            ])->create_thumbnail_image($imagePath);
        }
    }
847131
protected function postCopy(
        string $filePath
    ): void {
        $this->fileCreationTransaction::setPathCreated($filePath);
        $this->findAndReplaceHelper->replaceName(
            $this->codeHelper->classy($this->className),
            $filePath,
            FieldGenerator::FIND_ENTITY_FIELD_NAME
        );
        $this->findAndReplaceHelper->findReplace(
            $this->codeHelper->consty(FieldGenerator::FIND_ENTITY_FIELD_NAME),
            $this->codeHelper->consty($this->className),
            $filePath
        );
        $this->codeHelper->tidyNamespacesInFile($filePath);
        $this->setGetterToIsForBools($filePath);
    }
269984
public function initFromPath($path)
    {
        $core = new \Imagick;

        try {

            $core->setBackgroundColor(new \ImagickPixel('transparent'));
            $core->readImage($path);
            $core->setImageType(defined('\Imagick::IMGTYPE_TRUECOLORALPHA') ? \Imagick::IMGTYPE_TRUECOLORALPHA : \Imagick::IMGTYPE_TRUECOLORMATTE);

        } catch (\ImagickException $e) {
            throw new \Hail\Image\Exception\NotReadableException(
                "Unable to read image from path ({$path}).",
                0,
                $e
            );
        }

        // build image
        $image = $this->initFromImagick($core);
        $image->setFileInfoFromPath($path);

        return $image;
    }
287394
protected function storeImage($imagePath)
    {
        /**
         * @var \Elcodi\Component\Media\Services\ImageManager                 $imageManager
         * @var \Gaufrette\Filesystem                                         $filesystem
         * @var \Elcodi\Component\Media\Transformer\FileIdentifierTransformer $fileIdentifierTransformer
         * @var \Doctrine\Common\Persistence\ObjectManager                    $imageObjectManager
         */
        $imageManager = $this->get('elcodi.manager.media_image');
        $imageObjectManager = $this->get('elcodi.object_manager.image');
        $filesystem = $this->get('elcodi.media_filesystem');
        $fileIdentifierTransformer = $this->get('elcodi.transformer.media_file_identifier');

        $image = $imageManager->createImage(new \Symfony\Component\HttpFoundation\File\File($imagePath));
        $imageObjectManager->persist($image);
        $imageObjectManager->flush($image);

        $filesystem->write(
            $fileIdentifierTransformer->transform($image),
            file_get_contents($imagePath),
            true
        );

        return $image;
    }
579240
protected function createThumbnail()
    {
		$this->thumbnail = $this->thumbnailName();

    	if (! $this->validFile($this->thumbnailPath())) {
    		$img = $this->intervention
				->make($this->imagePath())
				->resize($this->width(), $this->height(), function ($constraint) {
            		$constraint->aspectRatio();
            		$constraint->upsize();
        		});

        	$img->save($this->thumbnailPath());
    	}
    }
1242449
private function sendCachingHeaders(string $imagePath = ''): void
    {
        $ifModifiedSince = '';
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
            $ifModifiedSince = \preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
        }

        $mdate = \gmdate('D, d M Y H:i:s', \filemtime($imagePath)).' GMT';
        if ($ifModifiedSince == $mdate) {
            \header($this->serverProtocol.' 304 Not Modified', true, 304);
            die();
        }

        \header($this->serverProtocol.' 200 OK', true, 200);
        \header('Last-Modified: '.$mdate);

        $maxAge = $this->baseClass->Image->Server->cacheTime;
        $maxAgeHeader = 'Cache-Control: no-transform,public,max-age='.$maxAge;
        if ($maxAge == 0) {
            $maxAgeHeader = 'Cache-Control: max-age=0, no-cache, no-store';
        }

        \header($maxAgeHeader);
        \header('Expires: '.\gmdate('D, d M Y H:i:s', \time() + $maxAge).' GMT');
    }
63011
public function saveImage($savePath, $imageQuality = "100")
		# Author:     Jarrod Oberto
		# Date:       27-02-08
		# Purpose:    Saves the image
		# Param in:   $savePath: Where to save the image including filename:
		#             $imageQuality: image quality you want the image saved at 0-100
		# Param out:  n/a
		# Reference:
		# Notes:    * gif doesn't have a quality parameter
		#       * jpg has a quality setting 0-100 (100 being the best)
		#       * png has a quality setting 0-9 (0 being the best)
		#
		#             * bmp files have no native support for bmp files. We use a
		#       third party class to save as bmp.
	{

		// *** Perform a check or two.
		if ( ! is_resource($this->imageResized))
		{
			if ($this->debug)
			{
				throw new Exception('saveImage: This is not a resource.');
			}
			else
			{
				throw new Exception();
			}
		}
		$fileInfoArray = pathInfo($savePath);
		clearstatcache();
		if ( ! is_writable($fileInfoArray['dirname']))
		{
			if ($this->debug)
			{
				throw new Exception('The path is not writable. Please check your permissions.');
			}
			else
			{
				throw new Exception();
			}
		}

		// *** Get extension
		$extension = strrchr($savePath, '.');
		$extension = fix_strtolower($extension);

		$error = '';

		switch ($extension)
		{
			case '.jpg':
			case '.jpeg':
				$this->checkInterlaceImage($this->isInterlace);
				if (imagetypes() & IMG_JPG)
				{
					imagejpeg($this->imageResized, $savePath, $imageQuality);
				}
				else
				{
					$error = 'jpg';
				}
				break;

			case '.gif':
				$this->checkInterlaceImage($this->isInterlace);
				if (imagetypes() & IMG_GIF)
				{
					imagegif($this->imageResized, $savePath);
				}
				else
				{
					$error = 'gif';
				}
				break;

			case '.png':
				// *** Scale quality from 0-100 to 0-9
				$scaleQuality = round(($imageQuality / 100) * 9);

				// *** Invert qualit setting as 0 is best, not 9
				$invertScaleQuality = 9 - $scaleQuality;

				$this->checkInterlaceImage($this->isInterlace);
				if (imagetypes() & IMG_PNG)
				{
					imagepng($this->imageResized, $savePath, $invertScaleQuality);
				}
				else
				{
					$error = 'png';
				}
				break;

			case '.bmp':
				file_put_contents($savePath, $this->GD2BMPstring($this->imageResized));
				break;


			// ... etc

			default:
				// *** No extension - No save.
				$this->errorArray[] = 'This file type (' . $extension . ') is not supported. File not saved.';
				break;
		}

		//imagedestroy($this->imageResized);

		// *** Display error if a file type is not supported.
		if ($error != '')
		{
			$this->errorArray[] = $error . ' support is NOT enabled. File not saved.';
		}
	}
145730
private function createImageFrom($path)
    {

        $this->gdExtensionCheck();
        switch ($this->getExt()) {
            case 'jpg':
                return imagecreatefromjpeg($path);
                break;
            case 'png':
                return imagecreatefrompng($path);
                break;
            case 'gif':
                return imagecreatefromgif($path);
                break;

            default:
                return imagecreatefrompng($path);
                break;
        }

    }
264099
private static function createFromFileByMime($path)
    {
        $mime = File::getMimeType($path);
        switch ($mime) {
            case 'image/jpeg':
                $img = imagecreatefromjpeg($path);
                break;
            case 'image/gif':
                $img = imagecreatefromgif($path);
                break;
            case 'image/png':
                $img = imagecreatefrompng($path);
                break;
            default:
                throw new \Exception('can`t create thumbnail: unknown image type');
        }

        if ( ! $img) {
            throw new \Exception('can`t create thumbnail: can`t create image handle from file ' . $path);
        }

        return $img;
    }
855048
public function save($filePath, $size = null, $compression = -1, $filters = -1)
    {
        return imagepng($this->getImage($size), $filePath, $compression, $filters);
    }
1363545
def make_thumbnail(self, imgfilename_inrst):
        
        builddir = self.env.app.outdir

        imgfilename_src = os.path.join(DOC_PATH, imgfilename_inrst)

        thumbfilename = self.thumbfilename(imgfilename_inrst)
        thumbfilename_inhtml = os.path.join('_images', thumbfilename)
        thumbfilename_dest = os.path.join(builddir, '_images', thumbfilename)

        im = Image.open(imgfilename_src)
        im.thumbnail(thumbnail_size)
        im.save(thumbfilename_dest)
        return thumbfilename_inhtml
1114747
public static function make($filePath) {
		$variableProcessor = new VariableProcessor();

		$fileSaver = new FileSaver($variableProcessor);
		$fileLoader = new FileLoader($variableProcessor);

		return new Repository($fileLoader, $fileSaver, $filePath);
	}
246020
public function setThumbnailsFormat($thumbnailsFormat)
    {
        $thumbnailsFormat = strtolower(trim((string) $thumbnailsFormat));
        if ($thumbnailsFormat !== ThumbnailFormatService::FORMAT_AUTO) {
            if (!$this->app->make(BitmapFormat::class)->isFormatValid($thumbnailsFormat)) {
                $thumbnailsFormat = BitmapFormat::FORMAT_JPEG;
            }
        }
        $this->thumbnailsFormat = $thumbnailsFormat;

        return $this;
    }
680468
public function create($image, $thumbnailWidth = 100, $thumbnailHeight = 100)
    {
        $this->setupTargetPath($image);
        $this->setupTargetImage($image);

        $this->transformation->thumbnail(new Image\Box($thumbnailWidth, $thumbnailHeight))
                             ->apply($this->imagine->open($image))
                             ->save($this->thumbnailImage);

        $this->imageSize = getimagesize($this->thumbnailImage);
    }
479957
public function createFromFile($filePath, $baseMime, Workspace $workspace = null)
    {
        $ds = DIRECTORY_SEPARATOR;

        $newPath = $this->pdir.$ds.$this->fu->getActiveDirectoryName().$ds.$this->ut->generateGuid().'.png';

        $thumbnailPath = null;

        if ('video' === $baseMime) {
            try {
                $thumbnailPath = $this->creator->fromVideo($filePath, $newPath, 100, 100);
            } catch (\Exception $e) {
                //ffmpege extension might be missing
                $thumbnailPath = null;
            }
        }

        if ('image' === $baseMime) {
            try {
                $thumbnailPath = $this->creator->fromImage($filePath, $newPath, 100, 100);
            } catch (\Exception $e) {
                $thumbnailPath = null;
                //error handling ? $thumbnailPath = null
            }
        }

        if ($thumbnailPath) {
            return $this->fu->createFile(new File($thumbnailPath));
        }
    }
244309
public function save($imageTargetFilePath, $quality = 100)
    {
        $resampleImageResource =& $this->getResampleImageResource();
        $resampleImageResource->setCompressionQuality($quality);
        $resampleImageResource->stripimage();

        $extension = pathinfo($imageTargetFilePath, PATHINFO_EXTENSION);

        switch ($extension) {
            case 'jpg':
            case 'jpeg':
                $resampleImageResource->setImageFormat('jpg');
                break;

            case 'gif':
                $resampleImageResource->setImageFormat('gif');
                break;

            case 'png':
                $resampleImageResource->setImageFormat('png');
                $resampleImageResource->setImageAlphaChannel(\Gmagick::ALPHACHANNEL_ACTIVATE);
                $resampleImageResource->setBackgroundColor(new \GmagickPixel('transparent'));
                break;

            case 'webp':
                $resampleImageResource->setImageFormat('webp');
                $resampleImageResource->setImageAlphaChannel(\Gmagick::ALPHACHANNEL_ACTIVATE);
                $resampleImageResource->setBackgroundColor(new \GmagickPixel('transparent'));
                break;
        }

        try {

            $resampleImageResource->writeimage($imageTargetFilePath);

            return true;

        } catch (\GmagickException $e) {

            $this->errors[ $e->getCode() ] = $e->getMessage();

        }

        return false;
    }
93921
def saveThumbnail(self,fileName,filePath):
        
        if self._thumbnail is None:
            self.__init()
        param_dict = {}
        if  self._thumbnail is not None:
            imgUrl = self.root + "/info/" + self._thumbnail
            onlineFileName, file_ext = splitext(self._thumbnail)
            fileNameSafe = "".join(x for x in fileName if x.isalnum()) + file_ext
            result = self._get(url=imgUrl,
                               param_dict=param_dict,
                               securityHandler=self._securityHandler,
                               proxy_url=self._proxy_url,
                               proxy_port=self._proxy_port,
                               out_folder=filePath,
                               file_name=fileNameSafe)
            return result
        else:
            return None