ManipulatorInterface::THUMBNAIL_INSET
ManipulatorInterface::THUMBNAIL_OUTBOUND
330056
public static function thumbnail($filename, $width, $height, $mode = ManipulatorInterface::THUMBNAIL_INSET)
    {
        $img = static::getImagine()->open(Yii::getAlias($filename));
        $sourceBox = $img->getSize();
        $thumbnailBox = static::getThumbnailBox($sourceBox, $width, $height);
        if (($sourceBox->getWidth() <= $thumbnailBox->getWidth() && $sourceBox->getHeight() <= $thumbnailBox->getHeight()) || (!$thumbnailBox->getWidth() && !$thumbnailBox->getHeight())) {
            return $img->copy();
        }
        $img = $img->thumbnail($thumbnailBox, $mode);
        // create empty image to preserve aspect ratio of thumbnail
        $thumb = static::getImagine()->create($thumbnailBox, new Color(static::$thumbnailBackgroundColor, static::$thumbnailBackgroundAlpha));
        // calculate points
        $startX = 0;
        $startY = 0;
        if ($sourceBox->getWidth() < $width) {
            $startX = ceil($width - $sourceBox->getWidth()) / 2;
        }
        if ($sourceBox->getHeight() < $height) {
            $startY = ceil($height - $sourceBox->getHeight()) / 2;
        }
        $thumb->paste($img, new Point($startX, $startY));
        return $thumb;
    }
172099
function CGIFIMAGE()
	{
		unSet($this->m_disp);
		unSet($this->m_bUser);
		unSet($this->m_bTrans);
		unSet($this->m_nDelay);
		unSet($this->m_nTrans);
		unSet($this->m_lpComm);
		unSet($this->m_data);
		$this->m_gih = new CGIFIMAGEHEADER();
		$this->m_lzw = new CGIFLZW();
	}
12720
function() {
            if (!this._image instanceof IMSoftcrop.Image || !this._image.ready) {
                return;
            }

            var _this = this,
                imageData = this.getImageData();

            this._waitForWorkers++;

            if (window.Worker) {
                // If workers are available, thread detection of faces
                var detectWorker = new Worker(this._detectWorkerUrl);

                detectWorker.postMessage([
                    'details',
                    imageData,
                    this._image.w,
                    this._image.h,
                    this._detectThreshold
                ]);

                detectWorker.onmessage = function(e) {
                    _this.addDetectedDetails(e.data);
                    _this._waitForWorkers--;
                    _this.autocropImages();
                };
            }
            else {
                // Fallback to non threaded
                var data = tracking.Fast.findCorners(
                    tracking.Image.grayscale(
                        imageData.data,
                        this._image.w,
                        this._image.h
                    ),
                    this._image.w,
                    this._image.h,
                    this._detectThreshold
                );

                this.addDetectedDetails(data);
                this._waitForWorkers--;
                this.autocropImages();
            }
        }
1266820
def _set_thumbnail(self, instance=None, **kwargs):
        
        image_field = getattr(instance, self.name)
        if image_field:
            thumbnail_filename = _get_thumbnail_filename(image_field.name)

            thumbnail_field = ThumbnailField(thumbnail_filename, self.storage)
            setattr(image_field, 'thumbnail', thumbnail_field)
493147
function () {
            if (!this._image instanceof IMSoftcrop.Image || !this._image.ready) {
                return;
            }

            this._waitForWorkers++;
            var _this = this;

            if (window.Worker) {
                // If workers are available, thread it
                var featureWorker = new Worker(this._detectWorkerUrl);

                featureWorker.postMessage([
                    'features',
                    this.getImageData(),
                    this._image.w,
                    this._image.h,
                    this._detectStepSize
                ]);

                featureWorker.onmessage = function(e) {
                    for(var n = 0; n < e.data.length; n++) {
                        _this.addDetectedFeature(e.data[n]);
                    }
                    _this._waitForWorkers--;
                    _this.autocropImages();
                };
            }
            else {
                //
                // Add function to tracking.js in order to track corners directly
                // on image data so that we do not need to access ui.
                //
                tracking.trackData = function(tracker, imageData, width, height) {
                    var task = new tracking.TrackerTask(tracker);
                    task.on('run', function() {
                        tracker.track(imageData.data, width, height);
                    });
                    return task.run();
                };

                var tracker = new tracking.ObjectTracker(['face']);
                tracker.setStepSize(this._detectStepSize);
                tracker.on('track', function (event) {
                    event.data.forEach(function (rect) {
                        _this.addDetectedFeature(rect);
                    });
                    _this._waitForWorkers--;
                    _this.autocropImages();
                });

                tracking.trackData(tracker, this.getImageData(), this._image.w, this._image.h);
            }
        }
16446
public function getPossessive() : Manipulator
    {
        $modifiedString = $this->trimEnd();

        if (mb_substr($modifiedString, -1) === 's') {
            $modifiedString .= '\'';
        } else {
            $modifiedString .= '\'s';
        }

        return new static($modifiedString);
    }
194149
def clear_thumbnails(self):
        ''''''
        state = self.state
        for l in state.layers:
            keys = state.layers[l].keys()[:]
            for key in keys:
                if (isinstance(state.layers[l][key], SlipThumbnail)
                    and not isinstance(state.layers[l][key], SlipIcon)):
                    state.layers[l].pop(key)
393219
def img(self):
        ''''''
        SlipThumbnail.img(self)

        if self.rotation:
            # rotate the image
            mat = cv2.getRotationMatrix2D((self.height//2, self.width//2), -self.rotation, 1.0)
            self._rotated = cv2.warpAffine(self._img, mat, (self.height, self.width))
        else:
            self._rotated = self._img
        return self._rotated
559892
private function _calcThumbSize($imgWidth, $imgHeight, $thumbWidth, $thumbHeight, $thumbType)
    {
        //初始化缩略图尺寸
        $w = $thumbWidth;
        $h = $thumbHeight;

        //初始化原图尺寸
        $oldThumbWidth = $imgWidth;
        $oldThumbHeight = $imgHeight;

        // 原图比需要的缩略图还小
        if ($imgWidth <= $thumbWidth && $imgHeight <= $thumbHeight) {
            return [$imgWidth, $imgHeight, $oldThumbWidth, $oldThumbHeight];
        }

        switch ($thumbType) {
            case 1 :
                //固定宽度  高度自增
                $h = $thumbWidth / $imgWidth * $imgHeight;
                break;
            case 2 :
                //固定高度  宽度自增
                $w = $thumbHeight / $imgHeight * $imgWidth;
                break;
            case 3 :
                //固定宽度  高度裁切
                $oldThumbHeight = $imgWidth / $thumbWidth * $thumbHeight;
                break;
            case 4 :
                //固定高度  宽度裁切
                $oldThumbWidth = $imgHeight / $thumbHeight * $thumbWidth;
                break;
            case 5 :
                //缩放最大边 原图不裁切
                if (($imgWidth / $thumbWidth) > ($imgHeight / $thumbHeight)) {
                    $h = $thumbWidth / $imgWidth * $imgHeight;
                } else if (($imgWidth / $thumbWidth) < ($imgHeight / $thumbHeight)) {
                    $w = $thumbHeight / $imgHeight * $imgWidth;
                } else {
                    $w = $thumbWidth;
                    $h = $thumbHeight;
                }
                break;
            default:
                //缩略图尺寸不变，自动裁切图片
                if (($imgHeight / $thumbHeight) < ($imgWidth / $thumbWidth)) {
                    $oldThumbWidth = $imgHeight / $thumbHeight * $thumbWidth;
                } else if (($imgHeight / $thumbHeight) > ($imgWidth / $thumbWidth)) {
                    $oldThumbHeight = $imgWidth / $thumbWidth * $thumbHeight;
                }
        }

        return [$w, $h, $oldThumbWidth, $oldThumbHeight];
    }
1006580
public static function getManipulationsForFile($file_path)
    {
        if (!isset(self::$manipulators[$file_path])) {
            return [];
        }

        $file_manipulations = [];

        foreach (self::$ordered_manipulators[$file_path] as $manipulator) {
            if ($manipulator->new_php_return_type) {
                if ($manipulator->return_typehint_start && $manipulator->return_typehint_end) {
                    $file_manipulations[$manipulator->return_typehint_start] = new FileManipulation(
                        $manipulator->return_typehint_start,
                        $manipulator->return_typehint_end,
                        $manipulator->new_php_return_type
                    );
                } else {
                    $file_manipulations[$manipulator->return_typehint_area_start] = new FileManipulation(
                        $manipulator->return_typehint_area_start,
                        $manipulator->return_typehint_area_start,
                        ': ' . $manipulator->new_php_return_type
                    );
                }
            } elseif ($manipulator->return_typehint_colon_start
                && $manipulator->new_phpdoc_return_type
                && $manipulator->return_typehint_start
                && $manipulator->return_typehint_end
            ) {
                $file_manipulations[$manipulator->return_typehint_start] = new FileManipulation(
                    $manipulator->return_typehint_colon_start,
                    $manipulator->return_typehint_end,
                    ''
                );
            }

            if (!$manipulator->new_php_return_type
                || !$manipulator->return_type_is_php_compatible
                || $manipulator->docblock_start !== $manipulator->docblock_end
            ) {
                $file_manipulations[$manipulator->docblock_start] = new FileManipulation(
                    $manipulator->docblock_start,
                    $manipulator->docblock_end,
                    $manipulator->getDocblock()
                );
            }
        }

        return $file_manipulations;
    }
836369
def __make_thumbnail(self, width, height):
        
        (w, h) = self.size
        factor = max(
            (float(w) / width),
            (float(h) / height)
        )
        w /= factor
        h /= factor
        return self.get_image((round(w), round(h)))
369009
private function hookupUI()
    {
        // TODO: Still need to hook up the edit attachment page

        add_filter('media_row_actions',function($actions,$post){
            $newaction['ilab_crop_image'] = '<a class="ilab-thickbox" href="'.$this->cropPageURL($post->ID).'" title="Crop Image">' . __('Crop Image') . '</a>';
            return array_merge($actions,$newaction);
        },10,2);

        add_filter('admin_post_thumbnail_html', function($content,$id){
            if (!has_post_thumbnail($id))
                return $content;

            $image_id = get_post_thumbnail_id($id);
            if (!current_user_can('edit_post',$image_id))
                return $content;

            $content.='<a class="ilab-thickbox" href="'.$this->cropPageURL($image_id).'">'.__('Crop Image').'</a>';
            return $content;
        },10,2);

        add_action( 'wp_enqueue_media', function () {
            remove_action('admin_footer', 'wp_print_media_templates');

            add_action('admin_footer', function(){
                ob_start();
                wp_print_media_templates();
                $result=ob_get_clean();
                echo $result;


                $sizes=ilab_get_image_sizes();
                $sizeKeys=array_keys($sizes);

                ?>
                <script>
                    jQuery(document).ready(function() {
                        jQuery('input[type="button"]')
                            .filter(function() {
                                return this.id.match(/imgedit-open-btn-[0-9]+/);
                            })
                            .each(function(){
                                var image_id=this.id.match(/imgedit-open-btn-([0-9]+)/)[1];
                                var button=jQuery('<input type="button" class="button" style="margin-left:5px;" value="Crop Image">');
                                jQuery(this).after(button);

                                button.on('click',function(e){
                                    e.preventDefault();

                                    ILabModal.loadURL("<?php echo get_admin_url(null, 'admin-ajax.php')?>?action=ilab_crop_image_page&size=<?php echo $sizeKeys[0]?>&post="+image_id,false,null);

                                    return false;
                                });
                            });

                        attachTemplate=jQuery('#tmpl-image-details');
                        if (attachTemplate)
                            attachTemplate.text(attachTemplate.text().replace(/(<input type="button" class="replace-attachment button")/,'<a href="<?php echo $this->cropPageURL('{{data.attachment.id}}')?>" class="ilab-thickbox button"><?php echo __('Crop Image') ?></a>&nbsp;$1'));

                        attachTemplate=jQuery('#tmpl-attachment-details-two-column');
                        if (attachTemplate)
                        {
                            attachTemplate.text(attachTemplate.text().replace(/(<button(?:.*)class="(?:.*)edit-attachment(?:.*)"[^>]*[^<]+<\/button>)/,'$1&nbsp;<a href="<?php echo $this->cropPageURL('{{data.id}}')?>" class="ilab-thickbox button"><?php echo __('Crop Image') ?></a>'));
                            attachTemplate.text(attachTemplate.text().replace(/(<a(?:.*)class="(?:.*)edit-imgix(?:.*)"[^>]*[^<]+<\/a>)/,'$1&nbsp;<a href="<?php echo $this->cropPageURL('{{data.id}}')?>" class="ilab-thickbox button"><?php echo __('Crop Image') ?></a>'));
                            attachTemplate.text(attachTemplate.text().replace(/(<a class="(?:.*)edit-attachment(?:.*)"[^>]+[^<]+<\/a>)/,'$1&nbsp;<a href="<?php echo $this->cropPageURL('{{data.id}}')?>" class="ilab-thickbox button"><?php echo __('Crop Image') ?></a>'));
                            attachTemplate.text(attachTemplate.text().replace(/(<a class="(?:.*)view-attachment(?:.*)"[^>]+[^<]+<\/a>)/,'$1 | <a class="ilab-thickbox" href="<?php echo $this->cropPageURL('{{data.id}}')?>"><?php echo __('Crop Image') ?></a>'));
                        }

                        attachTemplate=jQuery('#tmpl-attachment-details');
                        if (attachTemplate)
                        {
                            attachTemplate.text(attachTemplate.text().replace(/(<a(?:.*)class="(?:.*)edit-imgix(?:.*)"[^>]*[^<]+<\/a>)/, '$1<br><a class="ilab-thickbox" href="<?php echo $this->cropPageURL('{{data.id}}')?>"><?php echo __('Crop Image') ?></a>'));
                            attachTemplate.text(attachTemplate.text().replace(/(<a class="(?:.*)edit-attachment(?:.*)"[^>]+[^<]+<\/a>)/, '$1\n<a class="ilab-thickbox" href="<?php echo $this->cropPageURL('{{data.id}}')?>"><?php echo __('Crop Image') ?></a>'));
                        }
                    });
                </script>
                <?php
            },1000);
        } );
    }
146015
public static void tileStretchPaint(Graphics g, 
                JComponent comp,
                BufferedImage img,
                Insets ins) {
        
        int left = ins.left;
        int right = ins.right;
        int top = ins.top;
        int bottom = ins.bottom;
        
        // top
        g.drawImage(img,
                    0,0,left,top,
                    0,0,left,top,
                    null);
        g.drawImage(img,
                    left,                 0, 
                    comp.getWidth() - right, top, 
                    left,                 0, 
                    img.getWidth()  - right, top, 
                    null);
        g.drawImage(img,
                    comp.getWidth() - right, 0, 
                    comp.getWidth(),         top, 
                    img.getWidth()  - right, 0, 
                    img.getWidth(),          top, 
                    null);
    
        // middle
        g.drawImage(img,
                    0,    top, 
                    left, comp.getHeight()-bottom,
                    0,    top,   
                    left, img.getHeight()-bottom,
                    null);
        
        g.drawImage(img,
                    left,                  top, 
                    comp.getWidth()-right,      comp.getHeight()-bottom,
                    left,                  top,   
                    img.getWidth()-right,  img.getHeight()-bottom,
                    null);
         
        g.drawImage(img,
                    comp.getWidth()-right,     top, 
                    comp.getWidth(),           comp.getHeight()-bottom,
                    img.getWidth()-right, top,   
                    img.getWidth(),       img.getHeight()-bottom,
                    null);
        
        // bottom
        g.drawImage(img,
                    0,comp.getHeight()-bottom, 
                    left, comp.getHeight(),
                    0,img.getHeight()-bottom,   
                    left,img.getHeight(),
                    null);
        g.drawImage(img,
                    left,                    comp.getHeight()-bottom, 
                    comp.getWidth()-right,        comp.getHeight(),
                    left,                    img.getHeight()-bottom,   
                    img.getWidth()-right,    img.getHeight(),
                    null);
        g.drawImage(img,
                    comp.getWidth()-right,     comp.getHeight()-bottom, 
                    comp.getWidth(),           comp.getHeight(),
                    img.getWidth()-right, img.getHeight()-bottom,   
                    img.getWidth(),       img.getHeight(),
                    null);
    }
864345
def bind
      mark_bind
      bind=self.binds
      mark=self
      begin
        binds.image = mark._image
      end while(!binds.image and (mark==mark.proto))
    end
32315
def cursor_end
    blen = @buffer.rstrip.length
    if blen < @width
      set_form_col blen
    else
      # there is a problem here FIXME. 
      @pcol = blen-@width
      #set_form_col @width-1
      set_form_col blen
    end
    @curpos = blen # this is position in array where editing or motion is to happen regardless of what you see
                   # regardless of pcol (panning)
    #  $log.debug " crusor END cp:#{@curpos} pcol:#{@pcol} b.l:#{@buffer.length} d_l:#{@width} fc:#{@form.col}"
    #set_form_col @buffer.length
  end
1030828
public function thumb($output, $thumbWidth = 0, $thumbHeight = 0, $auto = true){
		$width = $this->getWidth();
		$height = $this->getHeight();
		if ($thumbWidth <= 0) {
			$thumbWidth = $auto ? ($thumbHeight / $height * $width) : $width;
		} elseif ($thumbHeight <= 0) {
			$thumbHeight = $auto ? ($thumbWidth / $width * $height) : $height;
		} elseif($auto) {
			$rate = min($height / $thumbHeight, $width / $thumbWidth);
			$width = $thumbWidth * $rate;
			$height = $thumbHeight * $rate;
		}
		
		$thumb = new Image();
		$thumb->create($thumbWidth, $thumbHeight);
		$thumb->copyFromWithResize($this, 0, 0, 0, 0, $width, $height);
		$thumb->saveAs($output);
		$thumb->close();
		return $output;
	}
390048
public function actionIndex()
    {
        if ($this->identifier === null) {
            $this->identifier = Inflector::variablize($this->prompt('Enter the filter identifier: (e.g. profilePicture)', ['required' => true, 'pattern' => '/^[a-zA-Z0-9]+$/i', 'error' => 'The filter identifer can only contain a-z,A-Z,0-9']));
        }
        
        if ($this->chain === null) {
            $select = $this->select('Select the Effect', [Filter::EFFECT_THUMBNAIL => 'Thumbnail', Filter::EFFECT_CROP => 'Crop']);
            
            if ($select == Filter::EFFECT_THUMBNAIL) {
                $dimension = $this->prompt('Enter thumbnail dimensions (width x height):', ['required' => true, 'default' => '600xnull']);
            } else {
                $dimension = $this->prompt('Enter crop dimensions (width x height):', ['required' => true, 'default' => '600xnull']);
            }
            
            if ($select == Filter::EFFECT_THUMBNAIL) {
                $namedSelect = 'self::EFFECT_THUMBNAIL';
            } else {
                $namedSelect = 'self::EFFECT_CROP';
            }
            
            $xp = explode("x", $dimension);
            $this->chain[$namedSelect] = ['width' => $xp[0], 'height' => $xp[1]];
            

            $tempName = $select == Filter::EFFECT_THUMBNAIL ? 'Thumbnail '. $dimension : 'Crop '.$dimension;
            $tempName.= ' ' . Inflector::camel2words($this->identifier);
        }
        
        if ($this->name === null) {
            if (!$tempName) {
                $tempName = Inflector::camel2words($this->identifier);
            }
            
            $this->name = ucfirst($this->prompt('Enter a self-explanatory Name:', ['required' => false, 'default' => $tempName]));
        }
        
        $folder = Yii::$app->basePath . DIRECTORY_SEPARATOR . 'filters';
        $className = Inflector::camelize($this->identifier) . 'Filter';
        $content = $this->generateClassView($this->identifier, $this->name, $this->chain, $className);
        $filePath = $folder . DIRECTORY_SEPARATOR . $className . '.php';
        
        if (FileHelper::createDirectory($folder) && FileHelper::writeFile($filePath, $content)) {
            return $this->outputSuccess('Successfully generated ' . $filePath);
        }
    }