Пример #1
0
func (this *ThumbFile) processSquare(original *UploadedFile) error {
	filename, err := processorcommand.SquareThumb(original.GetPath(), this.GetName(), this.GetWidth(), thumbType.FromMime(original.GetMime()))
	if err != nil {
		return err
	}

	if err := this.SetPath(filename); err != nil {
		return err
	}

	return nil
}
Пример #2
0
func (this *ThumbFile) processCustom(original *UploadedFile) error {
	cropWidth := this.GetCropWidth()
	cropHeight := this.GetCropHeight()
	var err error

	if this.GetCropRatio() != "" {
		cropWidth, cropHeight, err = this.ComputeCrop(original)
		if err != nil {
			return err
		}
	}

	filename, err := processorcommand.CustomThumb(original.GetPath(), this.GetName(), this.ComputeWidth(original), this.ComputeHeight(original), this.GetCropGravity(), cropWidth, cropHeight, this.GetQuality(), thumbType.FromMime(original.GetMime()))
	if err != nil {
		return err
	}

	if err := this.SetPath(filename); err != nil {
		return err
	}

	return nil
}