Set `a:srcRect` child to crop according to *cropping* values.
321753
def crop(self, cropping):
        
        srcRect = self._add_srcRect()
        srcRect.l, srcRect.t, srcRect.r, srcRect.b = cropping
1112588
public function performCrop()
    {
        $req_post = esc_html( $_POST['post'] );
        if (!current_user_can('edit_post', $req_post))
            json_response([
                'status'=>'error',
                'message'=>'You are not strong enough, smart enough or fast enough.'
                          ]);


        $size = esc_html($_POST['size']);
        $crop_width = esc_html($_POST['width']);
        $crop_height = esc_html($_POST['height']);
        $crop_x = esc_html($_POST['x']);
        $crop_y = esc_html($_POST['y']);

        $img_path = _load_image_to_edit_path( $req_post );
        $meta = wp_get_attachment_metadata( $req_post );
        $img_editor = wp_get_image_editor( $img_path );
        if (is_wp_error($img_editor))
            json_response([
                              'status'=>'error',
                              'message'=>'Could not create image editor.'
                          ]);

        $crop_size=ilab_get_image_sizes($size);
        $dest_width = $crop_size['width'];
        $dest_height = $crop_size['height'];

        $img_editor->crop($crop_x, $crop_y, $crop_width, $crop_height, $dest_width, $dest_height, false );
        $img_editor->set_quality($this->cropQuality);
        $save_path_parts = pathinfo($img_path);

        $path_url=parse_url($img_path);
        if (($path_url!==false) && (isset($path_url['scheme'])))
        {
            $parsed_path=pathinfo($path_url['path']);
            $img_subpath=apply_filters('ilab_s3_process_file_name',$parsed_path['dirname']);

            $upload_dir=wp_upload_dir();
            $save_path=$upload_dir['basedir'].$img_subpath;
            @mkdir($save_path,0777,true);
        }
        else
            $save_path=$save_path_parts['dirname'];

        $extension=$save_path_parts['extension'];
        $filename=preg_replace('#^(IL[0-9-]*)#','',$save_path_parts['filename']);
        $filename='IL'.date("YmdHis").'-'.$filename.'-'.$dest_width.'x'.$dest_height.'.'.$extension;

        if (isset($meta['sizes'][$size]))
        {
            $meta['sizes'][$size]['file']=$filename;
            $meta['sizes'][$size]['width']=$dest_width;
            $meta['sizes'][$size]['height']=$dest_height;
            $meta['sizes'][$size]['crop']=[
                'x'=>round($crop_x),
                'y'=>round($crop_y),
                'w'=>round($crop_width),
                'h'=>round($crop_height)
            ];
        }
        else
        {
            $meta['sizes'][$size] = array(
                'file' => $filename,
                'width' => $dest_width,
                'height' => $dest_height,
                'mime-type' => $meta['sizes']['thumbnail']['mime-type'],
                'crop'=> [
                    'x'=>round($crop_x),
                    'y'=>round($crop_y),
                    'w'=>round($crop_width),
                    'h'=>round($crop_height)
                ]
            );
        }

        $img_editor->save($save_path . '/' . $filename);

        // Let S3 upload the new crop
        $processedSize = apply_filters('ilab_s3_process_crop', $size, $save_path, $filename, $meta['sizes'][$size]);
        if ($processedSize)
            $meta['sizes'][$size] = $processedSize;

        wp_update_attachment_metadata($req_post, $meta);

        $attrs = wp_get_attachment_image_src($req_post, $size);
        list($full_src,$full_width,$full_height,$full_cropped)=$attrs;

        json_response([
            'status'=>'ok',
            'src'=>$full_src,
            'width'=>$full_width,
            'height'=>$full_height
        ]);
    }
282431
def _set(self, value):
        """"""
        super(AttachmentsField, self)._set(value)
        self._cursor = None
619853
def _crop_box(self, size):
        
        (left, top) = self.offset
        right = left + min(size[0], self.width)
        bottom = top + min(size[1], self.height)

        return (left, top, right, bottom)
465876
def _do_crop(self, lines, width, height, x_crop, y_crop):
        '''
        '''
        lines = crop_or_expand(
            lines, height, default=[self.fillchar * width],
            scheme=self._schemes[y_crop])
        for i, line in enumerate(lines):
            lines[i] = crop_or_expand(
                line, width, default=self.fillchar,
                scheme=self._schemes[x_crop])
        return lines
833574
function setCropBoxData(data) {
    var cropBoxData = this.cropBoxData;
    var aspectRatio = this.options.aspectRatio;

    var widthChanged = void 0;
    var heightChanged = void 0;

    if (this.ready && this.cropped && !this.disabled && isPlainObject(data)) {
      if (isNumber(data.left)) {
        cropBoxData.left = data.left;
      }

      if (isNumber(data.top)) {
        cropBoxData.top = data.top;
      }

      if (isNumber(data.width) && data.width !== cropBoxData.width) {
        widthChanged = true;
        cropBoxData.width = data.width;
      }

      if (isNumber(data.height) && data.height !== cropBoxData.height) {
        heightChanged = true;
        cropBoxData.height = data.height;
      }

      if (aspectRatio) {
        if (widthChanged) {
          cropBoxData.height = cropBoxData.width / aspectRatio;
        } else if (heightChanged) {
          cropBoxData.width = cropBoxData.height * aspectRatio;
        }
      }

      this.renderCropBox();
    }

    return this;
  }
1048394
function Cropper(element) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    classCallCheck(this, Cropper);

    if (!element || !REGEXP_TAG_NAME.test(element.tagName)) {
      throw new Error('The first argument is required and must be an <img> or <canvas> element.');
    }

    this.element = element;
    this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
    this.cropped = false;
    this.disabled = false;
    this.pointers = {};
    this.ready = false;
    this.reloading = false;
    this.replaced = false;
    this.sized = false;
    this.sizing = false;
    this.init();
  }
240410
def set_in_bounds(self,obj,val):
        
        if not callable(val):
            bounded_val = self.crop_to_bounds(val)
        else:
            bounded_val = val
        super(Number,self).__set__(obj,bounded_val)
23471
def crop_2dimage(img, beg_coords, end_coords):
    """"""

    cropped_img = img[
                  beg_coords[0]:end_coords[0],
                  beg_coords[1]:end_coords[1],
                  ]

    return cropped_img
1011118
public function crop($x, $y, $width, $height, $interlace = false) {

		if(false === ('-' . intval($x) == '-' . $x)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($x)), E_USER_ERROR);
		}

		if(false === ('-' . intval($y) == '-' . $y)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($y)), E_USER_ERROR);
		}

		if(false === ('-' . intval($width) == '-' . $width)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($width)), E_USER_ERROR);
		}

		if(false === ('-' . intval($height) == '-' . $height)) {
			return trigger_error(sprintf('Argument 4 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($height)), E_USER_ERROR);
		}

		if(false === is_bool($interlace)) {
			return trigger_error(sprintf('Argument 5 passed to %s() must be of the type boolean, "%s" given', __METHOD__, gettype($interlace)), E_USER_ERROR);
		}

		$this -> add(__FUNCTION__, func_get_args());
		return $this;
	}
768524
public function do_crop($width, $height, $offsetX = 0, $offsetY = 0)
    {
        $this->_image->cropImage($width, $height, $offsetX, $offsetY);
        $this->_image->setImagePage($width, $height, 0, 0);

        $this->_width = $this->_image->getImageWidth();
        $this->_height = $this->_image->getImageHeight();

        return $this;
    }
345110
def crop(im, size):
    
    diff = [im.shape[index] - size[index] for index in (0, 1)]
    im2 = im[diff[0]//2:diff[0]//2 + size[0], diff[1]//2:diff[1]//2 + size[1]]
    return im2
1122048
def _srcRect_x(self, attr_name):
        
        srcRect = self.blipFill.srcRect
        if srcRect is None:
            return 0.0
        return getattr(srcRect, attr_name)
708172
def conditional_resize(image, ratio, width=None, height=None, upcrop=True,
                       namespace="resized"):
    
    aspect = float(image.width) / float(image.height)
    crop = False

    if (aspect > ratio and upcrop) or (aspect <= ratio and not upcrop):
        crop = True

    return resize_lazy(image=image, width=width, height=height, crop=crop,
                       namespace=namespace, as_url=True)
407780
def _adjust_crop_box(box, crop):
        

        if crop and box:
            # Both boxes are the same size; just line them up.
            return (box[0] + crop[0], box[1] + crop[1],
                    box[2] + crop[0], box[3] + crop[1])

        if crop:
            # We don't have a fit box, so just convert the crop box
            return (crop[0], crop[1], crop[0] + crop[2], crop[1] + crop[3])

        # We don't have a crop box, so return the fit box (even if it's None)
        return box
422879
def crop(gens, seconds=5, cropper=None):
	'''
	
	'''
	if hasattr(gens, "next"):
		# single generator
		gens = (gens,)

	if cropper == None:
		cropper = lambda gen: itertools.islice(gen, 0, seconds * sampler.FRAME_RATE)

	cropped = [cropper(gen) for gen in gens]
	return cropped[0] if len(cropped) == 1 else cropped
267486
public void setCropped(boolean cropped) {

        if (cropped) {
            m_heightBox.setEnabled(false);
            m_widthBox.setEnabled(false);
            m_selectBox.setEnabled(false);
            m_resetSize.disable(Messages.get().key(Messages.GUI_PREVIEW_BUTTON_DIS_CROPPED_0));
            m_ratioLock.disable(Messages.get().key(Messages.GUI_PREVIEW_BUTTON_DIS_CROPPED_0));
            m_cropButton.disable(Messages.get().key(Messages.GUI_PREVIEW_BUTTON_DIS_CROPPED_0));
            if (m_formEnabled) {
                m_removeCropButton.enable();
            }
            m_removeCropButton.setVisible(true);
            return;
        }
        if (m_formEnabled) {
            m_cropButton.enable();
            m_heightBox.setEnabled(true);
            m_widthBox.setEnabled(true);
            m_selectBox.setEnabled(true);
            m_resetSize.enable();
            m_ratioLock.enable();
        }
        m_removeCropButton.setVisible(false);
    }