-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add manual crop #33
Add manual crop #33
Conversation
err = engine.Crop(coodinates.CropWidth, coodinates.CropHeight, coodinates.WidthOffset, coodinates.HeightOffset) | ||
if err != nil { | ||
return &ResizeResult{err: logger.ErrorDebug(err)} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMO] 条件複雑になっちゃうので、全部クロップを最初に倒したほうが良さそうですけどどうでしょう?
@TakatoshiMaeda パラメータを分割しました。 |
@@ -90,8 +102,60 @@ func ParseGeometry(geo string) (*Geometry, error) { | |||
pos = GEO_AUTO_CROP | |||
if cond[1] == "true" { | |||
needsAutoCrop = true | |||
} else if cond[1] == "manual" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manual
にするのであれば、true
もauto
にして対にしたいですね。
mc=true
のような形式にしなかったのは理由ありますか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
特に無いですね。
別フラグにします。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正しました!
ed28a69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
engine.SetSizeHint(coodinates.ResizeWidth, coodinates.ResizeHeight) | ||
if option.NeedsManualCrop { | ||
// open with source image size. | ||
engine.SetSizeHint(option.SizeHintWidth, option.SizeHintHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この分岐ってなんで必要なんでしたっけ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMO]
一段浅いifのblockで
if option.HasSizeHint() && !option.NeedsManualCrop {
calculator.SetImageSize(option.SizeHintWidth, option.SizeHintHeight)
coodinates = calculator.Calc(option)
engine.SetSizeHint(coodinates.ResizeWidth, coodinates.ResizeHeight)
}
こうするのが意図がわかりやすいかなと思いました
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほど。
修正しました。
305790f
👍 |
cf. #11
Manual croppingを追加しました。
Auto croppingとは違いcropの順番を変えたほうが効率が良いので、先にcroppingしてからリサイズするようにしています。
フラグを持つことでAuto croppingの場合は順序を変えていません。