upload.go 527 B

1234567891011121314151617181920212223242526
  1. package model
  2. import "go-common/library/database/bfs"
  3. const (
  4. _defaultPaddingX = 10
  5. _defaultPaddingY = 10
  6. _defaultScale = 0.035
  7. )
  8. // TweakWatermark makes some attributes of watermark default if they are not legal.
  9. func TweakWatermark(req *bfs.Request) {
  10. if req.WMKey != "" || req.WMText != "" {
  11. if req.WMPaddingX == 0 {
  12. req.WMPaddingX = _defaultPaddingX
  13. }
  14. if req.WMPaddingY == 0 {
  15. req.WMPaddingY = _defaultPaddingY
  16. }
  17. if req.WMScale <= 0 || req.WMScale >= 1 {
  18. req.WMScale = _defaultScale
  19. }
  20. }
  21. }