Generate thumbnail
@param array $thumbnailInfo
@param array|null $thumbnailParams
@return array
187531
protected function generateThumbnail($thumbnailInfo, $thumbnailParams = null)
    {
        $tempFilePath = null;
        $fullThumbnailPath = null;
        $thumbnailPath = null;
        $markup = null;

        try {
            /*
             * Get and validate input data
             */
            $path = $thumbnailInfo['path'];
            $width = $thumbnailInfo['width'];
            $height = $thumbnailInfo['height'];
            $lastModified = $thumbnailInfo['lastModified'];

            if (!is_numeric($width) || !is_numeric($height) || !is_numeric($lastModified)) {
                throw new ApplicationException('Invalid input data');
            }

            if (!$thumbnailParams) {
                $thumbnailParams = $this->getThumbnailParams();
                $thumbnailParams['width'] = $width;
                $thumbnailParams['height'] = $height;
            }

            $thumbnailPath = $this->getThumbnailImagePath($thumbnailParams, $path, $lastModified);
            $fullThumbnailPath = temp_path(ltrim($thumbnailPath, '/'));

            /*
             * Save the file locally
             */
            $library = MediaLibrary::instance();
            $tempFilePath = $this->getLocalTempFilePath($path);

            if (!@File::put($tempFilePath, $library->get($path))) {
                throw new SystemException('Error saving remote file to a temporary location');
            }

            /*
             * Resize the thumbnail and save to the thumbnails directory
             */
            $this->resizeImage($fullThumbnailPath, $thumbnailParams, $tempFilePath);

            /*
             * Delete the temporary file
             */
            File::delete($tempFilePath);
            $markup = $this->makePartial('thumbnail-image', [
                'isError' => false,
                'imageUrl' => $this->getThumbnailImageUrl($thumbnailPath)
            ]);
        }
        catch (Exception $ex) {
            if ($tempFilePath) {
                File::delete($tempFilePath);
            }

            if ($fullThumbnailPath) {
                $this->copyBrokenImage($fullThumbnailPath);
            }

            $markup = $this->makePartial('thumbnail-image', ['isError' => true]);

            /*
             * @todo We need to log all types of exceptions here
             */
            traceLog($ex->getMessage());
        }

        if ($markup && ($id = $thumbnailInfo['id'])) {
            return [
                'id' => $id,
                'markup' => $markup
            ];
        }
    }
488834
public function generateThumbnail(MediaInterface $media)
    {
        $fileName = $media->getFilesystemName();
        $thumbnailName = '';

        $extractedImagePath = $this->imageManager->extractImageFromPdf(
            $this->tmpDir . DIRECTORY_SEPARATOR . $fileName
        );

        $thumbnailPath = $this->imageManager->generateAlternative($extractedImagePath, $this->thumbnailFormat);

        if ($thumbnailPath != '') {
            $thumbnailName = self::THUMBNAIL_PREFIX . '-' . str_replace('.pdf', '.jpg', $fileName);
            $this->mediaStorageManager->uploadFile($thumbnailName, $thumbnailPath);
        }

        if (trim($extractedImagePath, DIRECTORY_SEPARATOR) != trim($this->tmpDir, DIRECTORY_SEPARATOR)) {
            $this->fileSystem->remove(array($extractedImagePath));
        }

        $media->setThumbnail($thumbnailName);
    }
1323013
public function thumbnail($type = 'auto')
    {
        if ($type !== 'auto' && !\in_array($type, $this->thumbnailTypes, true)) {
            return $this;
        }

        if ($this->thumbnailType !== $type) {
            $this->_thumbnail = null;
        }

        $this->thumbnailType = $type;

        return $this;
    }
1214646
private function organizeQueryParameters($inParameters = null)
    {
        $ctypeParameters = [];
        $metaParameters = [];
        if (is_array($inParameters)) {
            foreach ($inParameters as $key => $value) {
                if (in_array($key, ['page', 'limit', 'offset', 'returnsingle', 'printquery', 'paging', 'order'])) {
                    $metaParameters[$key] = $value;
                } else {
                    $ctypeParameters[$key] = $value;
                }
            }
        }

        return [$metaParameters, $ctypeParameters];
    }
238475
protected function resizeImage($fullThumbnailPath, $thumbnailParams, $tempFilePath)
    {
        $thumbnailDir = dirname($fullThumbnailPath);
        if (
            !File::isDirectory($thumbnailDir)
            && File::makeDirectory($thumbnailDir, 0777, true) === false
        ) {
            throw new SystemException('Error creating thumbnail directory');
        }

        $targetDimensions = $this->getTargetDimensions($thumbnailParams['width'], $thumbnailParams['height'], $tempFilePath);

        $targetWidth = $targetDimensions[0];
        $targetHeight = $targetDimensions[1];

        Resizer::open($tempFilePath)
            ->resize($targetWidth, $targetHeight, [
                'mode'   => $thumbnailParams['mode'],
                'offset' => [0, 0]
            ])
            ->save($fullThumbnailPath)
        ;

        File::chmod($fullThumbnailPath);
    }
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
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
612605
private function getThumbnailUri(Thumbnail $thumb)
    {
        $fileName = $thumb->getFileName();
        if ($fileName === null || $fileName === '') {
            return false;
        }

        return $this->urlGenerator->generate(
            'thumb',
            [
                'width'  => $thumb->getWidth(),
                'height' => $thumb->getHeight(),
                'action' => $thumb->getScale(),
                'file'   => $thumb->getFileName(),
            ]
        );
    }
147863
protected function buildThumbnails($files)
    {
        $thumbnails = [];

        foreach ($files as $file) {
            if (file_can_have_thumbnail($file)) {
                $thumbnails[$file] = (string) $this->image
                    ->make(Storage::get($file))
                    ->resize(20, 20)->encode('data-url');
            }
        }

        return $thumbnails;
    }
410050
public function processThumbnails()
    {
        foreach ($this->findFiles(['is_hidden' => false, 'is_deleted' => false]) as $file) {
            if ($file->isImage) {
                // create tiny thumbnail
                $this->createImage($file->id, $this->getFilterId(TinyCrop::identifier()));
                $this->createImage($file->id, $this->getFilterId(MediumThumbnail::identifier()));
            }
        }

        // force auto fix
        $this->autoFixMissingImageSources = true;

        foreach ($this->findImages() as $image) {
            if (!empty($image->file) && !$image->file->isHidden && !$image->file->isDeleted) {
                $image->source; // which forces to recreate missing sources.
            }
        }

        return true;
    }
1230517
public function setThumbnail(string $imageContents) : void
    {
        $parameters = [
            [
                'name' => 'threadThumbnail',
                'contents' => $imageContents,
                'headers' => [
                    'Content-Type' => 'image/jpeg',
                    'Content-Transfer-Encoding' => 'binary',
                ]
            ]
        ];

        $this->putMultiPart(sprintf(MessageThread::MESSAGE_THREAD_ENDPOINT . 'threads/%s/thumbnail', $this->messageThreadId), $parameters);
    }
703720
public static function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale)
    {
        $newImageWidth = ceil($width * $scale);
        $newImageHeight = ceil($height * $scale);
        $newImage = imagecreatetruecolor($newImageWidth, $newImageHeight);
        $source = imagecreatefromjpeg($image);
        imagecopyresampled($newImage, $source, 0, 0, $start_width, $start_height, $newImageWidth, $newImageHeight, $width, $height);
        imagejpeg($newImage, $thumb_image_name, 90);
        chmod($thumb_image_name, 0777);

        return $thumb_image_name;
    }
631997
public function getDetailThumbnailImage()
    {
        if ($this->fvHasDetailThumbnail) {
            $app = Application::getFacadeApplication();
            $config = $app->make('config');
            $type = ThumbnailType::getByHandle($config->get('concrete.icons.file_manager_detail.handle'));
            $result = '<img src="' . $this->getThumbnailURL($type->getBaseVersion()) . '"';
            if ($config->get('concrete.file_manager.images.create_high_dpi_thumbnails')) {
                $result .= ' data-at2x="' . $this->getThumbnailURL($type->getDoubledVersion()) . '"';
            }
            $result .= ' />';
        } else {
            $result = $this->getTypeObject()->getThumbnail();
        }

        return $result;
    }
1170577
public function refresh(Thumbnail $thumbnail)
    {
        $generatorClassNames = static::getThumbnailGeneratorClassNames($this->objectManager);
        foreach ($generatorClassNames as $generator) {
            $generator = $this->objectManager->get($generator['className']);
            if (!$generator->canRefresh($thumbnail)) {
                continue;
            }
            $generator->refresh($thumbnail);
            return;
        }
    }
187279
public function setThumbnail($thumbnail, $height = null, $weight = null)
    {
        self::$xml['thumbnail'] = '<media:thumbnail';
        $this->setThumbnailUrl($thumbnail);

        if (null !== $height) {
            $this->setThumbnailHeight($height);
        }

        if (null !== $weight) {
            $this->setThumbnailWidth($weight);
        }

        self::$xml['thumbnail'] .= '/>';

        return $this;
    }
13526
def generateThumbnail(self):
        """"""
        image = pilImage.open(ROOT / self.source.name)
        box, width, height = cropBox(self.width, self.height)

        # Resize
        image.thumbnail((width, height), pilImage.ANTIALIAS)
        # Crop from center
        box = cropBox(*image.size)[0]
        image = image.crop(box)
        # save
        self.thumbnail = self.source.name.replace(self.hash, '__{}'.format(self.hash))
        image.save(ROOT / self.thumbnail.name)
573341
public function thumbnailAction(Thumbnail $thumbnail)
    {
        if ($thumbnail->getResource() === null && $thumbnail->getStaticResource() === null) {
            $this->thumbnailService->refreshThumbnail($thumbnail);
        }
        $this->redirectToUri($this->thumbnailService->getUriForThumbnail($thumbnail), 0, 302);
    }