Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wenlng committed Nov 22, 2024
1 parent 4fe0ef2 commit 636cffb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@

- GoCaptcha:[https://github.com/wenlng/go-captcha](https://github.com/wenlng/go-captcha)
- GoCaptcha Document:[http://gocaptcha.wencodes.com](http://gocaptcha.wencodes.com)
- Go Example:[https://github.com/wenlng/go-captcha-example](https://github.com/wenlng/go-captcha-example)
- Go Assets File:[https://github.com/wenlng/go-captcha-assets](https://github.com/wenlng/go-captcha-assets)
- Example Project:[https://github.com/wenlng/go-captcha-example](https://github.com/wenlng/go-captcha-example)
- Javascript Library:[https://github.com/wenlng/go-captcha-jslib](https://github.com/wenlng/go-captcha-jslib)
- Vue Package:[https://github.com/wenlng/go-captcha-vue](https://github.com/wenlng/go-captcha-vue)
- React Package:[https://github.com/wenlng/go-captcha-react](https://github.com/wenlng/go-captcha-react)
- Angular Package:[https://github.com/wenlng/go-captcha-angular](https://github.com/wenlng/go-captcha-angular)
Expand Down Expand Up @@ -457,7 +458,7 @@ builder.SetResources(rotate.WithXxx(), ...)
<br/>

## Install package
- <p>Web Native ✔</p>
- <p>JavaScript ✔</p>
- <p>Vue ✔</p>
- <p>React ✔</p>
- <p>Angular ✔</p>
Expand Down
34 changes: 18 additions & 16 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</p>

<p style="text-align: center"> ⭐️ 如果能帮助到你,请随手给点一个star</p>
<p style="text-align: center">QQ交流群:178498936</p>


<br/>

Expand All @@ -30,8 +32,9 @@

- GoCaptcha:[https://github.com/wenlng/go-captcha](https://github.com/wenlng/go-captcha)
- GoCaptcha 文档:[http://gocaptcha.wencodes.com](http://gocaptcha.wencodes.com)
- 后端Go实例:[https://github.com/wenlng/go-captcha-example](https://github.com/wenlng/go-captcha-example)
- Go内嵌素材资源:[https://github.com/wenlng/go-captcha-assets](https://github.com/wenlng/go-captcha-assets)
- Golang/前端的实例:[https://github.com/wenlng/go-captcha-example](https://github.com/wenlng/go-captcha-example)
- Javascript 原生库:[https://github.com/wenlng/go-captcha-jslib](https://github.com/wenlng/go-captcha-jslib)
- Vue Package:[https://github.com/wenlng/go-captcha-vue](https://github.com/wenlng/go-captcha-vue)
- React Package:[https://github.com/wenlng/go-captcha-react](https://github.com/wenlng/go-captcha-react)
- Angular Package:[https://github.com/wenlng/go-captcha-angular](https://github.com/wenlng/go-captcha-angular)
Expand Down Expand Up @@ -454,22 +457,21 @@ func loadPng(p string) (image.Image, error) {
## 验证码图片

### JPEGImageData
- Get() image.Image 获取原图像
- ToBytes() ([]byte, error) 转为JPEG字节数组
- ToBytesWithQuality(imageQuality int) ([]byte, error) 指定清晰度转为JPEG字节数组
- ToBase64() (string, error) 转为 JPEG Base64 字符串
- ToBase64Data() (string, error) 转为 JPEG Base64 字符串,带 "data:image/jpeg;base64," 前缀
- ToBase64WithQuality(imageQuality int) (string, error) 指定清晰度转为 JPEG Base64 字符串
- ToBase64DataWithQuality(imageQuality int) (string, error) 指定清晰度转为 JPEG Base64 字符串,带 "data:image/jpeg;base64," 前缀
- SaveToFile(filepath string, quality int) error 保存 JPEG 到文件

- Get() image.Image <span style='padding: 0 10px'></span>获取原图像
- ToBytes() ([]byte, error) <span style='padding: 0 10px'></span>转为字节数组
- ToBytesWithQuality(imageQuality int) ([]byte, error) 指定清晰度转为字节数组
- ToBase64() (string, error) <span style='padding: 0 10px'></span>转为 Base64 字符串,带 <span style='color:#ed4630;'>"data:image/jpeg;base64,"</span> 前缀
- ToBase64Data() (string, error) <span style='padding: 0 10px'></span>转为 Base64 字符串
- ToBase64WithQuality(imageQuality int) (string, error) <span style='padding: 0 10px'></span>指定清晰度转为 Base64 字符串,带 <span style='color:#ed4630;'>"data:image/jpeg;base64,"</span> 前缀
- ToBase64DataWithQuality(imageQuality int) (string, error) <span style='padding: 0 10px'></span>指定清晰度转为 Base64 字符串
- SaveToFile(filepath string, quality int) error <span style='padding: 0 10px'></span>保存 JPEG 到文件

### PNGImageData
- Get() image.Image 获取原图像
- ToBytes() ([]byte, error) 转为PNG字节数组
- ToBase64() (string, error) 转为 PNG Base64 字符串
- ToBase64Data() (string, error) 转为 PNG Base64 字符串,带 "data:image/png;base64," 前缀
- SaveToFile(filepath string) error 保存 PNG 到文件
- Get() image.Image <span style='padding: 0 10px'></span>获取原图像
- ToBytes() ([]byte, error) <span style='padding: 0 10px'></span>转为字节数组
- ToBase64() (string, error) <span style='padding: 0 10px'></span>转为 Base64 字符串,带 <span style='color:#ed4630;'>"data:image/png;base64,"</span> 前缀
- ToBase64Data() (string, error) <span style='padding: 0 10px'></span>转为 Base64 字符串
- SaveToFile(filepath string) error <span style='padding: 0 10px'></span>保存 到文件

<br/>

Expand All @@ -483,7 +485,7 @@ func loadPng(p string) (image.Image, error) {
<br />

## B端 / C端 依赖包
- <p>Web Native ✔</p>
- <p>JavaScript ✔</p>
- <p>Vue ✔</p>
- <p>React ✔</p>
- <p>Angular ✔</p>
Expand Down
20 changes: 10 additions & 10 deletions v2/base/codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,37 +57,37 @@ func DecodeByteToPng(b []byte) (img image.Image, err error) {
return
}

// EncodePNGToBase64Data is to encode the png into string
func EncodePNGToBase64Data(img image.Image) (string, error) {
base64Str, err := EncodePNGToBase64(img)
// EncodePNGToBase64 is to encode the png into string
func EncodePNGToBase64(img image.Image) (string, error) {
base64Str, err := EncodePNGToBase64Data(img)
if err != nil {
return "", err
}

return pngBasePrefix + base64Str, nil
}

// EncodeJPEGToBase64Data is to encode the image into string
func EncodeJPEGToBase64Data(img image.Image, quality int) (string, error) {
base64Str, err := EncodeJPEGToBase64(img, quality)
// EncodeJPEGToBase64 is to encode the image into string
func EncodeJPEGToBase64(img image.Image, quality int) (string, error) {
base64Str, err := EncodeJPEGToBase64Data(img, quality)
if err != nil {
return "", err
}

return jpegBasePrefix + base64Str, nil
}

// EncodePNGToBase64 is to encode the png into string
func EncodePNGToBase64(img image.Image) (string, error) {
// EncodePNGToBase64Data is to encode the png into string
func EncodePNGToBase64Data(img image.Image) (string, error) {
byteCode, err := EncodePNGToByte(img)
if err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(byteCode), nil
}

// EncodeJPEGToBase64 is to encode the image into string
func EncodeJPEGToBase64(img image.Image, quality int) (string, error) {
// EncodeJPEGToBase64Data is to encode the image into string
func EncodeJPEGToBase64Data(img image.Image, quality int) (string, error) {
byteCode, err := EncodeJPEGToByte(img, quality)
if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions v2/tests/click_text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func TestClickTextCaptcha(t *testing.T) {

dots, _ := json.Marshal(dotData)
fmt.Println(string(dots))
fmt.Println(captData.GetMasterImage().ToBase64Data())
fmt.Println(captData.GetThumbImage().ToBase64Data())
fmt.Println(captData.GetMasterImage().ToBase64())
fmt.Println(captData.GetThumbImage().ToBase64())

err = captData.GetMasterImage().SaveToFile("../.cache/master.jpg", option.QualityNone)
if err != nil {
Expand Down

0 comments on commit 636cffb

Please sign in to comment.