Checks the maximum image width.

@param Model $model
@param array $data
@param int $size
@return bool
184681
public function maxWidth(Model $model, $data, $size) {
        return $this->_validate($model, $data, 'maxWidth', array($size));
    }
442031
public function height(Model $model, $data, $size) {
        return $this->_validate($model, $data, 'height', array($size));
    }
763538
public function update(Model $model, array $data, $callback = null)
    {
        $model = $model->fill($data);

        DB::transaction(function () use ($model, $data, $callback) {
            if ($model->save()) {

                if ($callback instanceof Closure) {
                    $callback($model, $data);
                }

                return true;
            }

            throw new GeneralException($model, '更新时出现问题，请再试一次。');
        });

        return $model;
    }
324080
public function handleImageRules($model, $rules)
    {

        // If the model is an image, the rules were passed in by NestedModels
        // and are good to go
        if (is_a($model, Image::class)) {
            return $rules;
        }

        // Otherwise, remove any image rules because this is a non-Image and
        // these rules will get applied by NestedModels
        return array_where($rules, function ($val, $key) {
            return !starts_with($key, 'images.');
        });
    }
1030426
public function runResize(Image $image, $fit, $width, $height)
    {
        if ($fit === 'contain') {
            return $this->runContainResize($image, $width, $height);
        }

        if ($fit === 'fill') {
            return $this->runFillResize($image, $width, $height);
        }

        if ($fit === 'max') {
            return $this->runMaxResize($image, $width, $height);
        }

        if ($fit === 'stretch') {
            return $this->runStretchResize($image, $width, $height);
        }

        if ($fit === 'crop') {
            return $this->runCropResize($image, $width, $height);
        }

        return $image;
    }
1001300
public static function checkModeNum($size, $data)
    {
        for($i=0; $i<$size; $i++) {
            if((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))){
                return false;
            }
        }

        return true;
    }
880890
protected function updateByModel(Model $model, array $data): Model
    {
        array_walk($data, function ($value, $key) use ($model) {
            $model->{$key} = $value;
        });

        try {
            $model->save();
        } catch (\RuntimeException $exception) {
            throw new ResourceUpdateException($exception->getMessage(), $exception->getCode(), $exception);
        }

        return $model;
    }
858510
private function verifyFileSize($size)
    {
        $max = $this->config['max_size'];
        if ($max > 0 && $size > $max) {
            throw FileSizeException::fileIsTooBig($size, $max);
        }

        return $size;
    }
969356
private function setImageSize($image, $size, $needExactSize = false)
    {
        if (empty($size)) {
            return $image;
        }

        if ($needExactSize || $image->getImageWidth() > $size[0]) {
            if ($size[0] == 0 || $size[1] == 0) {
                $image->scaleImage($size[0], $size[1]);
            } else {
                $image->cropThumbnailImage($size[0], $size[1]);
            }
        }

        return $image;
    }
754107
public function type(Model $model, $data, array $allowed = array()) {
        return $this->_validate($model, $data, 'type', array($allowed));
    }
761649
public function filesize(Model $model, $data, $size = 5242880) {
        return $this->_validate($model, $data, 'size', array($size));
    }
1017838
public static function get_image_size( $size ) {
		// Check for a directly passed image configuration array.
		if ( is_array( $size ) ) {
			return $size;
		}

		$sizes = self::get_image_sizes();

		// Return found image size.
		if ( isset( $sizes[ $size ] ) ) {
			return $sizes[ $size ];
		}

		self::notice( "Image size \"{$size}\" does not exist in your image configuration." );

		return false;
	}
3623
public function limitImageSize($width, $height)
    {
        if ($this->maxImageSize !== null) {
            $imageSize = $width * $height;

            if ($imageSize > $this->maxImageSize) {
                $width = $width / sqrt($imageSize / $this->maxImageSize);
                $height = $height / sqrt($imageSize / $this->maxImageSize);
            }
        }

        return [
            (int) $width,
            (int) $height,
        ];
    }
798207
protected function validateSize($width, $height)
    {
        if ($this->maximumHeight && $height > $this->maximumHeight) {
            $this->setErrorMessage(sprintf(
                $this->messages['size_height_max'],
                $height,
                $this->maximumHeight
            ));
            return false;
        }

        if ($this->maximumWidth && $width > $this->maximumWidth) {
            $this->setErrorMessage(sprintf(
                $this->messages['size_width_max'],
                $width,
                $this->maximumWidth
            ));
            return false;
        }

        if ($this->minimumHeight && $height < $this->minimumHeight) {
            $this->setErrorMessage(sprintf(
                $this->messages['size_height_min'],
                $height,
                $this->minimumHeight
            ));
            return false;
        }

        if ($this->minimumWidth && $width < $this->minimumWidth) {
            $this->setErrorMessage(sprintf(
                $this->messages['size_width_min'],
                $width,
                $this->minimumWidth
            ));
            return false;
        }

        return true;
    }
288183
public static function getImageDimensions($width=false, $height=false) {

		$max_width  = config('center.img.max.width');
		$max_height = config('center.img.max.height');
		$max_area   = config('center.img.max.area');

		//too wide?
		if ($width && $width > $max_width) {
			if ($height) $height *= $max_width / $width;
			$width = $max_width;
		}

		//too tall?
		if ($height && $height > $max_height) {
			if ($width) $width *= $max_height / $height;
			$height = $max_height;
		}

		//not specified?
		if (!$width) $width = config('center.img.default.width');
		if (!$height) $height = config('center.img.default.height');

		//too large?
		$area = $width * $height;
		if ($width * $height > $max_area) {
			$width *= $max_area / $area;
			$height *= $max_area / $area;
		}

		return array($width, $height);
	}
1013021
public static function get_image_width($size)
    {
        // Get the size meta array.
        $size = static::get_image_size($size);

        if ($size === false) {
            return false;
        }

        if (isset($size['width'])) {
            return (int) $size['width'];
        }

        return false;
    }
398632
public function getMetaImageResizeWidth($width = null)
    {
        if ($width) {
            return $width;
        }
        
        if ($width = $this->owner->ImageMetaResizeWidth) {
            return $width;
        }
        
        return $this->owner->getFieldFromParent('DefaultImageResizeWidth');
    }