mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-02-02 11:34:20 +02:00
po.Resize => po.ResizingType
This commit is contained in:
parent
a798530e40
commit
0d5d2f5ec2
@ -79,7 +79,7 @@ func calcScale(width, height int, po *processingOptions, imgtype imageType) floa
|
||||
wshrink := srcW / dstW
|
||||
hshrink := srcH / dstH
|
||||
|
||||
rt := po.Resize
|
||||
rt := po.ResizingType
|
||||
|
||||
if rt == resizeAuto {
|
||||
srcD := width - height
|
||||
@ -222,7 +222,7 @@ func prepareWatermark(wm *vipsImage, wmData *imageData, opts *watermarkOptions,
|
||||
}
|
||||
|
||||
po := newProcessingOptions()
|
||||
po.Resize = resizeFit
|
||||
po.ResizingType = resizeFit
|
||||
po.Dpr = 1
|
||||
po.Enlarge = true
|
||||
po.Format = wmData.Type
|
||||
@ -636,12 +636,12 @@ func processImage(ctx context.Context) ([]byte, context.CancelFunc, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if po.Resize == resizeCrop {
|
||||
if po.ResizingType == resizeCrop {
|
||||
logWarning("`crop` resizing type is deprecated and will be removed in future versions. Use `crop` processing option instead")
|
||||
|
||||
po.Crop.Width, po.Crop.Height = po.Width, po.Height
|
||||
|
||||
po.Resize = resizeFit
|
||||
po.ResizingType = resizeFit
|
||||
po.Width, po.Height = 0, 0
|
||||
}
|
||||
|
||||
|
@ -106,20 +106,20 @@ type watermarkOptions struct {
|
||||
}
|
||||
|
||||
type processingOptions struct {
|
||||
Resize resizeType
|
||||
Width int
|
||||
Height int
|
||||
Dpr float64
|
||||
Gravity gravityOptions
|
||||
Enlarge bool
|
||||
Extend bool
|
||||
Crop cropOptions
|
||||
Format imageType
|
||||
Quality int
|
||||
Flatten bool
|
||||
Background rgbColor
|
||||
Blur float32
|
||||
Sharpen float32
|
||||
ResizingType resizeType
|
||||
Width int
|
||||
Height int
|
||||
Dpr float64
|
||||
Gravity gravityOptions
|
||||
Enlarge bool
|
||||
Extend bool
|
||||
Crop cropOptions
|
||||
Format imageType
|
||||
Quality int
|
||||
Flatten bool
|
||||
Background rgbColor
|
||||
Blur float32
|
||||
Sharpen float32
|
||||
|
||||
CacheBuster string
|
||||
|
||||
@ -187,18 +187,18 @@ var (
|
||||
func newProcessingOptions() *processingOptions {
|
||||
newProcessingOptionsOnce.Do(func() {
|
||||
_newProcessingOptions = processingOptions{
|
||||
Resize: resizeFit,
|
||||
Width: 0,
|
||||
Height: 0,
|
||||
Gravity: gravityOptions{Type: gravityCenter},
|
||||
Enlarge: false,
|
||||
Quality: conf.Quality,
|
||||
Format: imageTypeUnknown,
|
||||
Background: rgbColor{255, 255, 255},
|
||||
Blur: 0,
|
||||
Sharpen: 0,
|
||||
Dpr: 1,
|
||||
Watermark: watermarkOptions{Opacity: 1, Replicate: false, Gravity: gravityCenter},
|
||||
ResizingType: resizeFit,
|
||||
Width: 0,
|
||||
Height: 0,
|
||||
Gravity: gravityOptions{Type: gravityCenter},
|
||||
Enlarge: false,
|
||||
Quality: conf.Quality,
|
||||
Format: imageTypeUnknown,
|
||||
Background: rgbColor{255, 255, 255},
|
||||
Blur: 0,
|
||||
Sharpen: 0,
|
||||
Dpr: 1,
|
||||
Watermark: watermarkOptions{Opacity: 1, Replicate: false, Gravity: gravityCenter},
|
||||
}
|
||||
})
|
||||
|
||||
@ -450,7 +450,7 @@ func applyResizingTypeOption(po *processingOptions, args []string) error {
|
||||
}
|
||||
|
||||
if r, ok := resizeTypes[args[0]]; ok {
|
||||
po.Resize = r
|
||||
po.ResizingType = r
|
||||
} else {
|
||||
return fmt.Errorf("Invalid resize type: %s", args[0])
|
||||
}
|
||||
@ -884,7 +884,7 @@ func parsePathBasic(parts []string, headers *processingHeaders) (string, *proces
|
||||
return "", po, err
|
||||
}
|
||||
|
||||
po.Resize = resizeTypes[parts[0]]
|
||||
po.ResizingType = resizeTypes[parts[0]]
|
||||
|
||||
if err = applyWidthOption(po, parts[1:2]); err != nil {
|
||||
return "", po, err
|
||||
|
@ -113,7 +113,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathBasic() {
|
||||
require.Nil(s.T(), err)
|
||||
|
||||
po := getProcessingOptions(ctx)
|
||||
assert.Equal(s.T(), resizeFill, po.Resize)
|
||||
assert.Equal(s.T(), resizeFill, po.ResizingType)
|
||||
assert.Equal(s.T(), 100, po.Width)
|
||||
assert.Equal(s.T(), 200, po.Height)
|
||||
assert.Equal(s.T(), gravityNorthEast, po.Gravity.Type)
|
||||
@ -138,7 +138,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedResize() {
|
||||
require.Nil(s.T(), err)
|
||||
|
||||
po := getProcessingOptions(ctx)
|
||||
assert.Equal(s.T(), resizeFill, po.Resize)
|
||||
assert.Equal(s.T(), resizeFill, po.ResizingType)
|
||||
assert.Equal(s.T(), 100, po.Width)
|
||||
assert.Equal(s.T(), 200, po.Height)
|
||||
assert.True(s.T(), po.Enlarge)
|
||||
@ -151,7 +151,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedResizingType() {
|
||||
require.Nil(s.T(), err)
|
||||
|
||||
po := getProcessingOptions(ctx)
|
||||
assert.Equal(s.T(), resizeFill, po.Resize)
|
||||
assert.Equal(s.T(), resizeFill, po.ResizingType)
|
||||
}
|
||||
|
||||
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedSize() {
|
||||
@ -322,7 +322,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedPreset() {
|
||||
require.Nil(s.T(), err)
|
||||
|
||||
po := getProcessingOptions(ctx)
|
||||
assert.Equal(s.T(), resizeFill, po.Resize)
|
||||
assert.Equal(s.T(), resizeFill, po.ResizingType)
|
||||
assert.Equal(s.T(), float32(0.2), po.Blur)
|
||||
assert.Equal(s.T(), 50, po.Quality)
|
||||
}
|
||||
@ -340,7 +340,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathPresetDefault() {
|
||||
require.Nil(s.T(), err)
|
||||
|
||||
po := getProcessingOptions(ctx)
|
||||
assert.Equal(s.T(), resizeFill, po.Resize)
|
||||
assert.Equal(s.T(), resizeFill, po.ResizingType)
|
||||
assert.Equal(s.T(), float32(0.2), po.Blur)
|
||||
assert.Equal(s.T(), 70, po.Quality)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user