File: qart_test.go

package info (click to toggle)
golang-github-vitrun-qart 0.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 152 kB
  • sloc: makefile: 2
file content (37 lines) | stat: -rw-r--r-- 634 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
 * Copyright ©2014-04-07 Alex <zhirun.yu@duitang.com>
 */
package qart

import (
	"bytes"
	"image/png"
	"io/ioutil"
	"fmt"
	"os"
	"testing"
)

// ReadWrite test
func ReadWrite() {
	data, err := ioutil.ReadFile("/tmp/in.png")
	if err != nil {
		fmt.Printf("err: %s\n", err)
		return
	}

	i := loadSize(data, 48)
	var buf bytes.Buffer
	png.Encode(&buf, i)
	ioutil.WriteFile("/tmp/out.png", buf.Bytes(), (os.FileMode)(0644))
	fmt.Printf("Hello world!")
}

// Image test
func TestEncodeByFile(t *testing.T) {
	srcImg := "/tmp/in.png"
	dstImg := "/tmp/out.png"
	url := "http://www.baidu.com/"
	EncodeByFile(url, srcImg, dstImg, 8)
}