Conversation
| Quality int | ||
| Compression int | ||
| Zoom int | ||
| Fit bool // Fit image into given dimensions |
There was a problem hiding this comment.
I needed a new option to bypass settings Force=true in normalizeOperation later
I can't use Crop or Embed:
Cropwill crop extra pixelsEmbedwill pad missing pixes with background
|
|
||
| func normalizeOperation(o *Options, inWidth, inHeight int) { | ||
| if !o.Force && !o.Crop && !o.Embed && !o.Enlarge && o.Rotate == 0 && (o.Width > 0 || o.Height > 0) { | ||
| if !o.Force && !o.Fit && !o.Crop && !o.Embed && !o.Enlarge && o.Rotate == 0 && (o.Width > 0 || o.Height > 0) { |
There was a problem hiding this comment.
I check Fit option to disable setting Force=true
| // Fixed width and height | ||
| case o.Width > 0 && o.Height > 0: | ||
| factor = math.Min(xfactor, yfactor) | ||
| if o.Crop { |
There was a problem hiding this comment.
When Crop option is set, then we should resize less and then crop
When no Crop option is set, we resize more, to fit the resulting rectangle
| } | ||
| } | ||
|
|
||
| func TestResizeFit(t *testing.T) { |
| forceOptions := []bool{true, false} | ||
|
|
||
| for _, forceOpt := range forceOptions { | ||
| opts := Options{Width: 1000, Height: 20, Fit: true, Force: forceOpt} |
There was a problem hiding this comment.
I also check, that Force=true results in old behavior
|
I added some notes in code review |
|
Any update on this? |
|
Any update on this? How's the default resize behavior on bimg? |
|
Is there any update on this feature? I need a functionality exactly same as this. |
See https://github.com/suntong/bimg/tree/dev I.e., suntong@9dda52d |
Fixes #93, #257