Browse Source

Fix force resizing type + zero width/height

DarthSim 4 years ago
parent
commit
27fa220fea
2 changed files with 4 additions and 4 deletions
  1. 2 2
      docs/generating_the_url.md
  2. 2 2
      process.go

+ 2 - 2
docs/generating_the_url.md

@@ -80,7 +80,7 @@ width:%width
 w:%width
 ```
 
-Defines the width of the resulting image. When set to `0`, imgproxy will calculate the resulting width using the defined height and source aspect ratio.
+Defines the width of the resulting image. When set to `0`, imgproxy will calculate the resulting width using the defined height and source aspect ratio. When set to `0` and rezizing type is `force`, imgproxy will keep the original width.
 
 Default: `0`
 
@@ -91,7 +91,7 @@ height:%height
 h:%height
 ```
 
-Defines the height of the resulting image. When set to `0`, imgproxy will calculate resulting height using the defined width and source aspect ratio.
+Defines the height of the resulting image. When set to `0`, imgproxy will calculate resulting height using the defined width and source aspect ratio. When set to `0` and rezizing type is `force`, imgproxy will keep the original height.
 
 Default: `0`
 

+ 2 - 2
process.go

@@ -111,9 +111,9 @@ func calcScale(width, height int, po *processingOptions, imgtype imageType) (flo
 		}
 
 		switch {
-		case po.Width == 0:
+		case po.Width == 0 && rt != resizeForce:
 			wshrink = hshrink
-		case po.Height == 0:
+		case po.Height == 0 && rt != resizeForce:
 			hshrink = wshrink
 		case rt == resizeFit:
 			wshrink = math.Max(wshrink, hshrink)