Create a crop for this asset.
513379
def create_crop(self, name, x, x2, y, y2):
        
        if self._can_crop():
            spec = get_image_cropper().create_crop(name, self.file, x=x,
                                                   x2=x2, y=y, y2=y2)
            ImageDetail.save_crop_spec(self, spec)
1092743
def crop(size, crop_from = nil, crop_size = nil, upsample = false)
      raise "No size given!" if size.empty?
      render_to = sizes_from_string(size)
      if crop_from && crop_size
        top_left = point_from_string(crop_from)
        crop_dimensions = sizes_from_string(crop_size)
        xy_crop_resize(render_to, top_left, crop_dimensions, upsample)
      else
        center_crop(render_to, upsample)
      end
    end
988920
function() {
            if (this._image instanceof IMSoftcrop.Image == false || !this._image.ready) {
                return;
            }

            // Always make sure all crops are added
            for(var n = 0; n < this._crops.length; n++) {
                var crop = this._image.getSoftcrop(this._crops[n].id);

                if (crop == null) {
                    var crop = this._image.addSoftcrop(
                        this._crops[n].id,
                        this._crops[n].setAsCurrent,
                        this._crops[n].hRatio,
                        this._crops[n].vRatio,
                        this._crops[n].x,
                        this._crops[n].y,
                        this._crops[n].exact,
                        this._crops[n].usable
                    );

                    if (this._autocrop) {
                        this._image.autocrop();
                    }

                    this._renderNewCropPreview(crop, this._crops[n].setAsCurrent);
                }


                if (this._crops[n].setAsCurrent) {
                    this.setActiveCrop(crop);
                }
            }
        }
1252789
def crop_resize(img, size):
   """"""
   if img.shape[0] < img.shape[1]:
       img = img.T
   # we crop image from center
   short_egde = min(img.shape[:2])
   yy = int((img.shape[0] - short_egde) / 2)
   xx = int((img.shape[1] - short_egde) / 2)
   crop_img = img[yy : yy + short_egde, xx : xx + short_egde]
   # resize to 64, 64
   resized_img = transform.resize(crop_img, (size, size))
   resized_img *= 255
   return resized_img.astype("uint8")
867981
def crop_to_seg_extents(img, seg, padding):
    """"""

    beg_coords, end_coords = crop_coords(seg, padding)

    img = crop_3dimage(img, beg_coords, end_coords)
    seg = crop_3dimage(seg, beg_coords, end_coords)

    return img, seg
712065
def random_crop(src, size):
    """"""
    h, w, _ = src.shape
    new_w, new_h = scale_down((w, h), size)

    x0 = random.randint(0, w - new_w)
    y0 = random.randint(0, h - new_h)

    out = fixed_crop(src, x0, y0, new_w, new_h, size)
    return out, (x0, y0, new_w, new_h)
1347850
public function crop($x, $y, $x2, $y2) {
		$width = $x2 - $x;
		$height = $y2 - $y;
		$image = imagecreatetruecolor($width, $height);
		imagealphablending($image, false);
		imagesavealpha($image, true);
		imagecopyresampled($image, $this->_image, 0, 0, $x, $y, $width, $height);
		imagedestroy($this->_image);
		$this->_image = $image;

		return $this;
	}
443343
def crop_resized(image, size, gravity = "Center")
      size =~ /(\d+)x(\d+)/
      width = $1.to_i
      height = $2.to_i

      # Grab the width and height of the current image in one go.
      cols, rows = image[:dimensions]

      # Only do anything if needs be. Who knows, maybe it's already the exact
      # dimensions we're looking for.
      if(width != cols && height != rows)
        image.combine_options do |c|
          # Scale the image down to the widest dimension.
          if(width != cols || height != rows)
            scale = [width / cols.to_f, height / rows.to_f].max * 100
            c.resize("#{scale}%")
          end

          # Align how things will be cropped.
          c.gravity(gravity)

          # Crop the image to size.
          c.crop("#{width}x#{height}+0+0")
        end
      end
    end
42679
def make_rendition(self, width, height):
        '''
        '''
        image = Image.open(self.master)
        format = image.format

        target_w = float(width)
        target_h = float(height)

        if (target_w == 0):
            target_w = self.master_width

        if (target_h == 0):
            target_h = self.master_height

        rendition_key = '%dx%d' % (target_w, target_h)

        if rendition_key in self.renditions:
            return self.renditions[rendition_key]

        if (target_w != self.master_width or target_h != self.master_height):
            r = target_w / target_h
            R = float(self.master_width) / self.master_height
            if r != R:
                if r > R:
                    crop_w = self.master_width
                    crop_h = crop_w / r
                    x = 0
                    y = int(self.master_height - crop_h) >> 1
                else:
                    crop_h = self.master_height
                    crop_w = crop_h * r
                    x = int(self.master_width - crop_w) >> 1
                    y = 0
                image = image.crop((x, y, int(crop_w + x), int(crop_h + y)))

            image.thumbnail((int(target_w), int(target_h)), Image.ANTIALIAS)

            filename, ext = os.path.splitext(self.get_master_filename())
            rendition_name = '%s/%s_%s%s' % (
                IMAGE_DIRECTORY,
                filename,
                rendition_key,
                ext
            )
            fd = BytesIO()
            image.save(fd, format)
            default_storage.save(rendition_name, fd)

            self.renditions[rendition_key] = rendition_name
            self.save()

            return rendition_name

        return self.master.name
723659
public function crop($w, $h, $x = 0, $y = 0, $width = null, $height = null){
        $this->img->crop($w, $h, $x, $y, $width, $height);
        return $this;
    }
809291
def no_crop(im, min_sz=None, interpolation=cv2.INTER_AREA):
    
    r,c,*_ = im.shape
    if min_sz is None: min_sz = min(r,c)
    return cv2.resize(im, (min_sz, min_sz), interpolation=interpolation)
510919
def fixed_crop(src, x0, y0, w, h, size=None, interpolation=cv2.INTER_CUBIC):
    """"""
    out = mx.nd.crop(src, begin=(y0, x0, 0), end=(y0+h, x0+w, int(src.shape[2])))
    if size is not None and (w, h) != size:
        out = resize(out, size, interpolation=interpolation)
    return out
465319
@SuppressWarnings("DeprecatedIsStillUsed")
    @Deprecated
    public static Bitmap crop(Drawable drawable, State state, Settings settings) {
        if (drawable == null) {
            return null;
        }

        float zoom = state.getZoom();

        // Computing crop size for base zoom level (zoom == 1)
        int width = Math.round(settings.getMovementAreaW() / zoom);
        int height = Math.round(settings.getMovementAreaH() / zoom);

        // Crop area coordinates within viewport
        Rect pos = new Rect();
        GravityUtils.getMovementAreaPosition(settings, pos);

        Matrix matrix = new Matrix();
        state.get(matrix);
        // Scaling to base zoom level (zoom == 1)
        matrix.postScale(1f / zoom, 1f / zoom, pos.left, pos.top);
        // Positioning crop area
        matrix.postTranslate(-pos.left, -pos.top);

        try {
            // Draw drawable into bitmap
            Bitmap dst = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

            Canvas canvas = new Canvas(dst);
            canvas.concat(matrix);
            drawable.draw(canvas);

            return dst;
        } catch (OutOfMemoryError e) {
            return null; // Not enough memory for cropped bitmap
        }
    }
434149
function crop($x1,$y1,$x2,$y2) {
		$tmp=imagecreatetruecolor($width=$x2-$x1+1,$height=$y2-$y1+1);
		imagesavealpha($tmp,TRUE);
		imagefill($tmp,0,0,IMG_COLOR_TRANSPARENT);
		imagecopyresampled($tmp,$this->data,
			0,0,$x1,$y1,$width,$height,$width,$height);
		imagedestroy($this->data);
		$this->data=$tmp;
		return $this->save();
	}
55394
def crop(data, crinfo):
    
    crinfo = fix_crinfo(crinfo)
    return data[
        __int_or_none(crinfo[0][0]) : __int_or_none(crinfo[0][1]),
        __int_or_none(crinfo[1][0]) : __int_or_none(crinfo[1][1]),
        __int_or_none(crinfo[2][0]) : __int_or_none(crinfo[2][1]),
    ]
1351160
public void crop(String url, Type type) {
        setUrl(url);
        bind(url, () -> crop(type));
    }
627690
def crop_coords(img, padding):
    """"""

    coords = np.nonzero(img)
    empty_axis_exists = np.any([len(arr) == 0 for arr in coords])
    if empty_axis_exists:
        end_coords = img.shape
        beg_coords = np.zeros((1, img.ndim)).astype(int).flatten()
    else:
        min_coords = np.array([arr.min() for arr in coords])
        max_coords = np.array([arr.max() for arr in coords])
        beg_coords = np.fmax(0, min_coords - padding)
        end_coords = np.fmin(img.shape, max_coords + padding)

    return beg_coords, end_coords