mirror of https://github.com/IoTcat/auxpi.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
931 B
35 lines
931 B
// Copyright (c) 2019 aimerforreimu. All Rights Reserved. |
|
// Use of this source code is governed by a BSD-style |
|
// license that can be found in the LICENSE file. |
|
// |
|
// GNU GENERAL PUBLIC LICENSE |
|
// Version 3, 29 June 2007 |
|
// |
|
// Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> |
|
// Everyone is permitted to copy and distribute verbatim copies |
|
// of this license document, but changing it is not allowed. |
|
// |
|
// repo: https://github.com/aimerforreimu/auxpi |
|
|
|
package tools |
|
|
|
import ( |
|
"fmt" |
|
"hash/crc32" |
|
) |
|
|
|
func CheckPid(pid string, imgType string, size string) string { |
|
if pid == "" { |
|
return "" |
|
} |
|
sinaNumber := fmt.Sprint((crc32.ChecksumIEEE([]byte(pid)) & 3) + 1) |
|
n := len(imgType) |
|
rs := []rune(imgType) |
|
suffix := string(rs[6:n]) |
|
if suffix != "gif" { |
|
suffix = "jpg" |
|
} |
|
sinaUrl := "https://ww" + sinaNumber + ".sinaimg.cn/" + size + "/" + pid + "." + suffix |
|
return sinaUrl |
|
|
|
}
|
|
|