actually generated the thumbnail
973513
public function execute() {
		// if source is not specified
		if(!$this->Source) {
			// add an error
			$this->Error = 'No source image provided';	
			// return false already
			return(false);
		}
		// check if the source file exists
		if(!file_exists($this->Source)) {
			// add an error
			$this->Error = 'Source image does not exist';	
			// return false already
			return(false);
		}
		// if no destination
		if(!$this->Destination) {
			// add an error
			$this->Error = 'No destination provided';	
			// return false already
			return(false);
		}
		// if the destination is not a folder and already exists
		if(!is_dir($this->Destination) && file_exists($this->Destination)) {
			// throw an exception
			$this->Error = 'Destination image already exists';	
			// return false
			return(false);
		}
		// if the destination is not a directory
		elseif(!is_dir($this->Destination)) {
			// try to explode by slash to find the file name
			$exploded = explode('/',$this->Destination);
			// get the last element wich is the file name
			$this->Name = $exploded[count($exploded)-1];
			// set the directory as being the path minus the name
			$this->Destination = str_replace($this->Name,'',$this->Destination);
		}
		// the destination if a folder without name
		elseif(is_dir($this->Destination)) {
			// if the trailing slash is ommited
			if(substr($this->Destination,-1) != '/') {
				// add it to the path
				$this->Destination .= '/';	
			}
			// generate a name being sha1(file) +sha1(microtime)
			$this->Name = sha1_file($this->Source);
		}
		// destination unknown !
		else {
			// add an error
			$this->Error = 'Destination is unkown or incorrect';
			// return an error
			return(false);
		}
		// check if the destination is writable
		if(!is_writable($this->Destination)) {
			// add an error
			$this->Error = 'Destination is not writable';
			// return an error
			return(false);
		}
		// compute filesize
		$this->Size = filesize($this->Source);
		// get the type of the source image
		$this->Type = Filesystem::type($this->Source, true);
		// if failed to get a type
		if(!$this->Type) {
			// add an error
			$this->Error = 'Failed to get mimetype';
			// return an error
			return(false);		
		}
		// if the source type is not allowed
		if(!in_array($this->Type, $this->Allowed)) {
			// add an error
			$this->Error = 'This image is not in the list of allowed formats : ' . implode(',',$this->Allowed);
			// return an error
			return(false);
		}
		// if we have a png
		if($this->Type == 'image/png') {
			// create image
			$this->Image = imagecreatefrompng($this->Source);
		}
		// if we have a jpg
		elseif($this->Type == 'image/jpeg') {
			// create image
			$this->Image = imagecreatefromjpeg($this->Source);
		}		// get the width
		$this->OriginalWidth = imageSX($this->Image);
		// get the height
		$this->OriginalHeight = imageSY($this->Image);
		// if the picture is horizontal
		if($this->OriginalHeight < $this->OriginalWidth) {
			// set the height
			$this->Height 	= round($this->Maximum * $this->OriginalHeight / $this->OriginalWidth , 0);
			// set the width
			$this->Width 	= $this->Maximum;
		}
		// else the picture is vertical or cubic
		else {
			// set the width
			$this->Width = round($this->Maximum * $this->OriginalWidth / $this->OriginalHeight , 0);
			// set the height
			$this->Height = $this->Maximum;
		}
		// create a canvas for the resized image
		$this->Sized = ImageCreateTrueColor($this->Width,$this->Height);
		// resize and inject into the canvas
		imagecopyresampled(
			$this->Sized, $this->Image,
			0, 0, 0, 0,
			$this->Width, $this->Height,
			$this->OriginalWidth, $this->OriginalHeight
		);
		// destroy the source handler
		imagedestroy($this->Image);
		// if output is png
		if($this->Output == 'image/png') {
			// roof
			$this->Quality = $this->Quality > 90 ? '90' : $this->Quality;
			// convert the jpeg quality index to a png quality index
			$this->Quality = round(abs(-0.1 * $this->Quality + 10));
			// create png image
			$status = imagepng($this->Sized,$this->Destination.$this->Name,$this->Quality);
		}
		elseif($this->Output == 'image/jpeg') {
			// create jpeg image
			$status = imagejpeg($this->Sized,$this->Destination.$this->Name,$this->Quality);
		}
		// destroy the sized handler
		imagedestroy($this->Sized);
		
		// if everything went well
		if($status) {
			// get the size of the generated thumbnail
			$this->Size = filesize($this->Destination . $this->Name);
			// creation succeeded
			return(true);
		}
		// failed somewhere
		else {
			// add an error
			$this->Error = 'Failed to write thumbnail to the disk';
			// and return false
			return(false);	
		}
	}
1106975
def thumbnail(options = {})
      options = { geometry: nil, strip: false }.merge(options)
      geometry = convert_to_geometry(options[:geometry])
      thumbnail = image
      thumbnail = thumbnail.thumb(geometry) if geometry
      thumbnail = thumbnail.strip if options[:strip]
      thumbnail
    end
1324385
def set_current_thumbnail(self, thumbnail):
        """"""
        self.current_thumbnail = thumbnail
        self.figure_viewer.load_figure(
                thumbnail.canvas.fig, thumbnail.canvas.fmt)
        for thumbnail in self._thumbnails:
            thumbnail.highlight_canvas(thumbnail == self.current_thumbnail)
695763
def thumbnail(self):
        
        if 'THUMBNAIL_RESOURCE' in self.image_resources:
            return pil_io.convert_thumbnail_to_pil(
                self.image_resources.get_data('THUMBNAIL_RESOURCE')
            )
        elif 'THUMBNAIL_RESOURCE_PS4' in self.image_resources:
            return pil_io.convert_thumbnail_to_pil(
                self.image_resources.get_data('THUMBNAIL_RESOURCE_PS4'), 'BGR'
            )
        return None
827030
def create_thumbnail(img, width, height):
    
    size = (width, height)
    img.thumbnail(size)
    return img
1238535
public function onGenerateThumbnails()
    {
        $batch = Input::get('batch');
        if (!is_array($batch)) {
            return;
        }

        $result = [];
        foreach ($batch as $thumbnailInfo) {
            $result[] = $this->generateThumbnail($thumbnailInfo);
        }

        return [
            'generatedThumbnails'=>$result
        ];
    }
718140
def thumbnail_options(request):
    
    response_data = [{'id': opt.pk, 'name': opt.name} for opt in ThumbnailOption.objects.all()]
    return http.HttpResponse(json.dumps(response_data), content_type="application/json")
1193952
def write(self, image, options, thumbnail):
        
        format_ = options['format']
        quality = options['quality']
        image_info = options.get('image_info', {})
        # additional non-default-value options:
        progressive = options.get('progressive', settings.THUMBNAIL_PROGRESSIVE)
        raw_data = self._get_raw_data(
            image, format_, quality,
            image_info=image_info,
            progressive=progressive
        )
        thumbnail.write(raw_data)
1197645
function(size, callback) {
      var ratio = size.width / size.height;
      var cropPosition = {};
      var resizeWidth = width || Math.round(height * ratio);
      var resizeHeight = height || Math.round(width / ratio);

      if (crop && width && height) {
        if (ratio < width / height) {
          resizeHeight = Math.round(width / ratio);
          cropPosition = {x: 0, y: Math.round((resizeHeight - height) / 2)};
          crop = resizeHeight > height;
        } else {
          resizeWidth = Math.round(height * ratio);
          cropPosition = {x: Math.round((resizeWidth - width) / 2), y: 0};
          crop = resizeWidth > width;
        }
      }

      image
        .noProfile()
        .quality(quality)
        .resizeExact(resizeWidth, resizeHeight);

      if (crop)
        image.crop(width, height, cropPosition.x, cropPosition.y);

      image.write(thumbnailPath, callback);
    }
36982
def default(thumbnailer, prepared_options, source_filename,
            thumbnail_extension, **kwargs):
    
    filename_parts = [source_filename]
    if ('%(opts)s' in thumbnailer.thumbnail_basedir or
            '%(opts)s' in thumbnailer.thumbnail_subdir):
        if thumbnail_extension != os.path.splitext(source_filename)[1][1:]:
            filename_parts.append(thumbnail_extension)
    else:
        filename_parts += ['_'.join(prepared_options), thumbnail_extension]
    return '.'.join(filename_parts)
380201
def _create_thumbnail(self, source_image, geometry_string, options,
                          thumbnail):
        
        logger.debug('Creating thumbnail file [%s] at [%s] with [%s]',
                     thumbnail.name, geometry_string, options)
        ratio = default.engine.get_image_ratio(source_image, options)
        geometry = parse_geometry(geometry_string, ratio)
        image = default.engine.create(source_image, geometry, options)
        default.engine.write(image, options, thumbnail)
        # It's much cheaper to set the size here
        size = default.engine.get_image_size(image)
        thumbnail.set_size(size)
681289
protected function getThumbnail()
    {
        if (!$this->_thumbnail) {
            $types = $this->thumbnailTypes;

            if ($this->thumbnailType !== 'auto') {
                array_unshift($types, $this->thumbnailType);
            }

            foreach ($types as $type) {
                $thumb = $this->get('thumbnails.' . $type, false);

                if ($thumb) {
                    $thumb = $thumb instanceof ThumbnailImageMedium ? $thumb : MediumFactory::fromFile($thumb, ['type' => 'thumbnail']);
                    $thumb->parent = $this;
                }

                if ($thumb) {
                    $this->_thumbnail = $thumb;
                    break;
                }
            }
        }

        return $this->_thumbnail;
    }
728126
public function makeThumbnailsForBookCover() {

		$post = $this->getMetaPost();
		if ( $post ) {

			$pb_cover_image = get_post_meta( $post->ID, 'pb_cover_image', true );
			if ( $pb_cover_image && ! \Pressbooks\Image\is_default_cover( $pb_cover_image ) ) {

				$path = \Pressbooks\Utility\get_media_path( $pb_cover_image );
				$type = wp_check_filetype( $path );
				$type = $type['type'];

				// Insert new image, create thumbnails
				$args = [
					'post_mime_type' => $type,
					'post_title' => __( 'Cover Image', 'pressbooks' ),
					'post_content' => '',
					'post_status' => 'inherit',
				];

				include_once( ABSPATH . 'wp-admin/includes/image.php' );
				$id = wp_insert_attachment( $args, $path, $post->ID );
				wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $path ) );
				Book::deleteBookObjectCache();
			}
		}
	}
936866
public function generateThumbnail(ThumbnailTypeVersion $type)
    {
        $app = Application::getFacadeApplication();
        $config = $app->make('config');
        $image = $this->getImagineImage();
        $imageSize = $image->getSize();
        $bitmapFormat = $app->make(BitmapFormat::class);
        $inplaceOperations = false;
        $inplacePixelsLimit = (float) $config->get('concrete.misc.inplace_image_operations_limit');
        if ($inplacePixelsLimit >= 1) {
            $totalImagePixels = $imageSize->getWidth() * $imageSize->getHeight() * max($image->layers()->count(), 1);
            if ($totalImagePixels > $inplacePixelsLimit) {
                $inplaceOperations = true;
                $this->releaseImagineImage();
            }
        }

        $filesystem = $this->getFile()
            ->getFileStorageLocationObject()
            ->getFileSystemObject();

        $height = $type->getHeight();
        $width = $type->getWidth();
        if ($height && $width) {
            $size = new Box($width, $height);
        } elseif ($width) {
            $size = $imageSize->widen($width);
        } else {
            $size = $imageSize->heighten($height);
        }

        // isCropped only exists on the CustomThumbnail type
        if (method_exists($type, 'isCropped') && $type->isCropped()) {
            $thumbnailMode = ImageInterface::THUMBNAIL_OUTBOUND;
        } else {
            switch ($type->getSizingMode()) {
                case ThumbnailType::RESIZE_EXACT:
                    $thumbnailMode = ImageInterface::THUMBNAIL_OUTBOUND;
                    break;
                case ThumbnailType::RESIZE_PROPORTIONAL:
                default:
                    $thumbnailMode = ImageInterface::THUMBNAIL_INSET;
                    break;
            }
        }
        if ($inplaceOperations) {
            $thumbnailMode |= ImageInterface::THUMBNAIL_FLAG_NOCLONE;
        }
        if ($type->isUpscalingEnabled()) {
            $thumbnailMode |= ImageInterface::THUMBNAIL_FLAG_UPSCALE;
        }

        $thumbnail = $image->thumbnail($size, $thumbnailMode);
        unset($image);
        $thumbnailPath = $type->getFilePath($this);
        if ($type->isKeepAnimations() && $thumbnail->layers()->count() > 1) {
            $isAnimation = true;
            $thumbnailFormat = BitmapFormat::FORMAT_GIF;
        } else {
            $thumbnailFormat = $app->make(ThumbnailFormatService::class)->getFormatForFile($this);
            $isAnimation = false;
        }

        $mimetype = $bitmapFormat->getFormatMimeType($thumbnailFormat);
        $thumbnailOptions = $bitmapFormat->getFormatImagineSaveOptions($thumbnailFormat);
        if ($isAnimation) {
            $thumbnailOptions['animated'] = true;
        }

        $filesystem->write(
            $thumbnailPath,
            $thumbnail->get($thumbnailFormat, $thumbnailOptions),
            [
                'visibility' => AdapterInterface::VISIBILITY_PUBLIC,
                'mimetype' => $mimetype,
            ]
        );
        unset($thumbnail);
        gc_collect_cycles();

        $app['director']->dispatch('on_thumbnail_generate',
            new \Concrete\Core\File\Event\ThumbnailGenerate($thumbnailPath, $type)
        );

        if ($type->getHandle() == $config->get('concrete.icons.file_manager_listing.handle') && !$this->fvHasListingThumbnail) {
            $this->fvHasListingThumbnail = true;
            $this->save();
        }
        if ($type->getHandle() == $config->get('concrete.icons.file_manager_detail.handle') && !$this->fvHasDetailThumbnail) {
            $this->fvHasDetailThumbnail = true;
            $this->save();
        }
    }
621711
public void genImage() {
		if (image == null) {
			ImageBuffer buffer = new ImageBuffer(128,16);
			for (int i=0;i<128;i++) {
				Color col = getColorAt(i / 128.0f);
				for (int j=0;j<16;j++) {
					buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte());
				}
			}
			image = buffer.getImage();
		}
	}
426209
def set_thumbnail(self, thumbnail):
        
        self.thumbnail = thumbnail
        if isinstance(self.thumbnail, str):
            from .files import ThumbnailFile
            self.thumbnail = ThumbnailFile(path=self.thumbnail)

        if self.thumbnail:
            self.add_file(self.thumbnail)
899726
def generate_thumb(self, image):
        
        image_file = image.file
        picture = Image.open(image_file).convert('RGB')
        picture.thumbnail((10, 10))
        picture.filter(ImageFilter.GaussianBlur(radius=4))
        absolute_path = self.build_thumb_path(image)
        self.save_thumb(picture, absolute_path)