示例#1
0
func (prc *CorrectionProcessor) process(nim image.Image, params imageserver.Params) (image.Image, error) {
	original := nim
	nim, _ = prc.before.Process(nim, params)
	nim, err := prc.Processor.Process(nim, params)
	if err != nil {
		return nil, err
	}
	nim, _ = prc.after.Process(nim, params)
	if isHighQuality(nim) && !isHighQuality(original) {
		newNim := imageserver_image_internal.NewDrawableSize(original, nim.Bounds())
		imageserver_image_internal.Copy(newNim, nim)
		nim = newNim
	}
	return nim, nil
}
示例#2
0
func (prc *ResizeProcessor) process(nim image.Image, params imageserver.Params) (image.Image, error) {
	width, height, err := prc.getSize(params)
	if err != nil {
		return nil, err
	}
	if width == 0 && height == 0 {
		return nim, err
	}
	f, err := prc.getFilter(width, height, params)
	if err != nil {
		return nil, err
	}
	g := gift.New(f)
	out := imageserver_image_internal.NewDrawableSize(nim, g.Bounds(nim.Bounds()))
	g.Draw(out, nim)
	return out, nil
}
示例#3
0
func (prc *RotateProcessor) process(nim image.Image, params imageserver.Params) (image.Image, error) {
	rot, err := prc.getRotation(params)
	if err != nil {
		return nil, err
	}
	if rot == 0 {
		return nim, nil
	}
	f, err := prc.getFilter(rot, params)
	if err != nil {
		return nil, err
	}
	g := gift.New(f)
	out := imageserver_image_internal.NewDrawableSize(nim, g.Bounds(nim.Bounds()))
	g.Draw(out, nim)
	return out, nil
}