-
Notifications
You must be signed in to change notification settings - Fork 0
/
thumbnails.go
56 lines (45 loc) · 1.12 KB
/
thumbnails.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package generate
import (
"fmt"
"log"
"os"
apyhub "github.com/apyhub/apyhub.go"
)
func init() {
apyhub.InitApyHub("Enter your apyhub token")
}
func Thumbnails() {
File, err := os.Open("./test_file/flower.jpeg")
if err != nil {
log.Fatal(err)
}
//thumbnails the image as file to file
byt, err := apyhub.ThumnailsImageAsFile(File, 200, 250)
if err != nil {
log.Fatal(err)
}
// write bytes in specific file
if err := os.WriteFile("./test_file/thumbnails.png", byt, 0666); err != nil {
log.Fatal(err)
}
//thumbnails the image as fileurl to file
byt, err = apyhub.ThumnailsImageAsFile("https://assets.apyhub.com/samples/sample.jpg", 200, 250)
if err != nil {
log.Fatal(err)
}
// write bytes in specific file
if err := os.WriteFile("./test_file/thumbnails.png", byt, 0666); err != nil {
log.Fatal(err)
}
url, err := apyhub.ThumnailsImageAsURL(File, 200, 250)
if err != nil {
log.Fatal(err)
}
fmt.Println(url)
//thumbnails the image as fileurl to file
url, err = apyhub.ThumnailsImageAsURL("https://assets.apyhub.com/samples/sample.jpg", 200, 250)
if err != nil {
log.Fatal(err)
}
fmt.Println(url)
}