Ikon: cari per domain/URL gambar + semua format dikonversi ke PNG
- Dialog ikon: nama aplikasi -> Iconify; domain (mikrotik.com) -> ikon resmi situs (manifest 512, apple-touch-icon, favicon) + layanan favicon; URL gambar -> langsung - Contoh kasus: 'winbox' cuma punya 1 ikon tidak nyambung di Iconify, tapi 'mikrotik.com' memberi ikon resminya (5 pilihan, semuanya PNG) - Decoder ICO: entri BMP 24/32-bit (favicon.ico lama) ikut didukung, bukan cuma PNG - FromURL/Fetch selalu mengembalikan PNG; hasil raster/konversi seragam 512px - Tes: deteksi URL gambar/domain, daftar ikon situs, decode ICO BMP, konversi format
This commit is contained in:
1 parent
cad41caaee
commit
59145910b5
9 files changed
+441
-33
No files matched your search
@@ -1,6 +1,10 @@
|
||||
package icon
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -23,7 +27,17 @@ func icoWithPNG(png []byte) []byte {
|
||||
return ico
|
||||
}
|
||||
|
||||
var pngBytes = append([]byte("\x89PNG\r\n\x1a\n"), []byte("payload")...)
|
||||
// pngBytes adalah PNG asli (kecil) untuk tes: ICO yang berisi PNG harus benar-benar
|
||||
// bisa di-decode, bukan sekadar punya magic bytes.
|
||||
var pngBytes = func() []byte {
|
||||
img := image.NewNRGBA(image.Rect(0, 0, 8, 8))
|
||||
img.Set(4, 4, color.NRGBA{R: 0x20, G: 0x80, B: 0xE0, A: 0xFF})
|
||||
var buf bytes.Buffer
|
||||
if err := png.Encode(&buf, img); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return buf.Bytes()
|
||||
}()
|
||||
|
||||
func TestFetchUsesLinkedIcon(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in new issue
Block a user