mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-13 17:30:28 -07:00
refactor(watermark): auto define width
This commit is contained in:
parent
0bff93ddae
commit
4bf5d7391e
2 changed files with 3 additions and 3 deletions
|
|
@ -168,7 +168,7 @@ func TestImageWatermarkNoReplicate(t *testing.T) {
|
||||||
func TestImageZoom(t *testing.T) {
|
func TestImageZoom(t *testing.T) {
|
||||||
image := initImage("test.jpg")
|
image := initImage("test.jpg")
|
||||||
|
|
||||||
_, err := image.Extract(100, 100, 0, 0)
|
_, err := image.Extract(100, 100, 400, 300)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Cannot extract the image: %s", err)
|
t.Errorf("Cannot extract the image: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +180,7 @@ func TestImageZoom(t *testing.T) {
|
||||||
|
|
||||||
err = assertSize(buf, 800, 600)
|
err = assertSize(buf, 800, 600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Write("fixtures/test_zoom_out.jpg", buf)
|
Write("fixtures/test_zoom_out.jpg", buf)
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ func watermakImage(image *C.struct__VipsImage, w Watermark) (*C.struct__VipsImag
|
||||||
w.Font = "sans 10"
|
w.Font = "sans 10"
|
||||||
}
|
}
|
||||||
if w.Width == 0 {
|
if w.Width == 0 {
|
||||||
w.Width = int(math.Floor(float64(image.Xsize / 8)))
|
w.Width = int(math.Floor(float64(image.Xsize / 6)))
|
||||||
}
|
}
|
||||||
if w.DPI == 0 {
|
if w.DPI == 0 {
|
||||||
w.DPI = 150
|
w.DPI = 150
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue