Skip to content

Commit

Permalink
dont panic on unkown image format, but return placeholder image
Browse files Browse the repository at this point in the history
  • Loading branch information
mc51 committed Jun 16, 2022
1 parent 51be09f commit 31cb85e
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 9 deletions.
Binary file added assets/not_found_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
162 changes: 162 additions & 0 deletions clipster/icons.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
package clipster

// PNG file containing a "file not found" placeholder image as bytes
var PNG_BYTES_IMAGE_NOTFOUND []byte = []byte{
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40,
0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x60, 0xb9, 0x55, 0x00, 0x00, 0x02,
0xec, 0x7a, 0x54, 0x58, 0x74, 0x52, 0x61, 0x77, 0x20, 0x70, 0x72, 0x6f,
0x66, 0x69, 0x6c, 0x65, 0x20, 0x74, 0x79, 0x70, 0x65, 0x20, 0x65, 0x78,
0x69, 0x66, 0x00, 0x00, 0x78, 0xda, 0xed, 0x97, 0x5b, 0xb2, 0xdc, 0x28,
0x0c, 0x86, 0xdf, 0x59, 0x45, 0x96, 0x80, 0x24, 0x84, 0xc4, 0x72, 0x30,
0x97, 0xaa, 0xec, 0x60, 0x96, 0x9f, 0x1f, 0xec, 0xf6, 0xe9, 0x3e, 0x27,
0x33, 0x49, 0x6a, 0xe6, 0x69, 0xaa, 0xa1, 0x0c, 0x58, 0x60, 0x49, 0xd6,
0x27, 0x70, 0x77, 0x18, 0x7f, 0x7d, 0x9f, 0xe1, 0x1b, 0x0a, 0x95, 0xcc,
0x21, 0xa9, 0x79, 0x2e, 0x39, 0x47, 0x94, 0x54, 0x52, 0xe1, 0x8a, 0x81,
0xc7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3,
0x3c, 0x28, 0x82, 0xba, 0x35, 0xa7, 0x6a, 0x8d, 0x46, 0xf0, 0xfe, 0x08,
0xcb, 0x03, 0x58, 0x7d, 0x86, 0xce, 0x75, 0x43, 0xd6, 0xe2, 0xef, 0xb7,
0x35, 0xcc, 0x38, 0xf5, 0xcc, 0x3f, 0xdf, 0xf8, 0x05, 0x12, 0x9a, 0x50,
0x7a, 0xc6, 0x98, 0x0f, 0x91, 0x00, 0x00, 0x00, 0x02, 0x62, 0x4b, 0x47,
0x44, 0x00, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x00, 0x00, 0x00, 0x09, 0x70,
0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13, 0x01,
0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45,
0x07, 0xe6, 0x06, 0x10, 0x10, 0x20, 0x15, 0x37, 0xef, 0x93, 0x39, 0x00,
0x00, 0x02, 0xbe, 0x49, 0x44, 0x41, 0x54, 0x68, 0xde, 0xed, 0x99, 0x4b,
0x6b, 0x13, 0x51, 0x18, 0x86, 0x9f, 0xc4, 0xd6, 0xbb, 0x96, 0x8a, 0x52,
0x48, 0xa9, 0x35, 0x75, 0x51, 0x50, 0x11, 0xc4, 0xbf, 0x50, 0x8d, 0x44,
0xa5, 0x69, 0xbb, 0x10, 0x95, 0x58, 0xaa, 0x56, 0x11, 0xa1, 0x2b, 0xfd,
0x07, 0x2e, 0x5d, 0x08, 0xa2, 0x16, 0x6b, 0x10, 0x2b, 0x25, 0x05, 0x17,
0x0a, 0x15, 0xa2, 0x56, 0xa2, 0x68, 0x2f, 0xd6, 0x22, 0xba, 0xf2, 0xb2,
0x52, 0x17, 0x4a, 0x2b, 0x45, 0xaa, 0xb1, 0xde, 0xa8, 0x8e, 0x9b, 0x71,
0x7a, 0x4e, 0x66, 0x3a, 0x93, 0xb9, 0x9c, 0x44, 0x24, 0xd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0x50, 0x06, 0x08, 0x3c, 0x2a, 0x6c, 0x5d, 0x6f, 0x26, 0x20, 0x95,
0x25, 0xde, 0x00, 0x42, 0x2c, 0x2d, 0x45, 0x09, 0x34, 0xa5, 0x7a, 0x9a,
0x33, 0xc0, 0x7b, 0xa5, 0x00, 0x05, 0x1c, 0xdd, 0xdf, 0xa7, 0x5b, 0xfb,
0x65, 0x8a, 0xa8, 0xb9, 0xce, 0xe6, 0x58, 0xcb, 0x11, 0x4f, 0x1f, 0xaf,
0x9d, 0xef, 0x08, 0x3d, 0xbc, 0xe5, 0x5f, 0x8b, 0x3f, 0xe3, 0x15, 0x7b,
0xbc, 0x4e, 0xc3, 0x61, 0x15, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
0x44, 0xae, 0x42, 0x60, 0x82,
}
25 changes: 16 additions & 9 deletions clipster/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,39 @@ func BytesToPixbuf(img []byte) *gdk.Pixbuf {
return i
}

// BytesToImage reads bytes and returns image.Image
// BytesToImage reads bytes and returns image.Image. If bytes are not a valid Image
// return a default "file not found" Image
func BytesToImage(img []byte) (image.Image, error) {
m, _, err := image.Decode(bytes.NewReader(img))
img_decoded, _, err := image.Decode(bytes.NewReader(img))
if err != nil {
log.Panicln("Error:", err)
log.Println("Error BytesToImage:", err)
log.Println("Returning 'missing file' image instead")
img_decoded, _, err = image.Decode(bytes.NewReader(PNG_BYTES_IMAGE_NOTFOUND))
}
return m, err
return img_decoded, err
}

// ImageToBytes reads image and returns bytes
func ImageToBytes(img image.Image) ([]byte, error) {
buf := new(bytes.Buffer)
err := png.Encode(buf, img)
if err != nil {
log.Println("Error Encode:", err)
}
img_bytes := buf.Bytes()
return img_bytes, err
}

// B64ToImage converts b64 encoded string of an image to image.Image
// B64ToImage converts b64 encoded string of an image to image.Image if it fails
// nil is returned
func B64ToImage(img string) (image.Image, error) {
img_bytes, err := base64.StdEncoding.DecodeString(img)
if err != nil {
log.Panicln("Error:", err)
log.Println("Error DecodeString:", err)
}
image, err := BytesToImage(img_bytes)
if err != nil {
log.Panicln("Error:", err)
log.Println("Error BytesToImage:", err)
}
return image, err
}
Expand All @@ -62,7 +69,7 @@ func AreCredsComplete(host string, user string, pw string) (string, string, stri
var err error = nil
host = strings.TrimSpace(host)
user = strings.TrimSpace(user)
pw = strings.TrimSpace(pw)
pw = strings.TrimSpace(pw) // maybe space should be valid? but not at beginning or end?

if host == "" {
host = HOST_DEFAULT
Expand Down Expand Up @@ -208,7 +215,7 @@ func processClipTextToImages(clip Clips) Clips {
clip.GtkThumb, err = gtk.ImageNewFromPixbuf(img_thumb_pixbuf)

if err != nil {
log.Println(err)
log.Println("Error processClipTextToImages:", err)
}

return clip
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
)

require (
github.com/cratonica/2goarray v0.0.0-20190331194516-514510793eaa // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 // indirect
Expand Down Expand Up @@ -43,6 +44,7 @@ require (
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
golang.org/x/mobile v0.0.0-20210716004757-34ab1303b554 // indirect
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/cratonica/2goarray v0.0.0-20190331194516-514510793eaa h1:Wg+722vs7a2zQH5lR9QWYsVbplKeffaQFIs5FTdfNNo=
github.com/cratonica/2goarray v0.0.0-20190331194516-514510793eaa/go.mod h1:6Arca19mRx58CA7OWEd7Wu1NpC1rd3uDnNs6s1pj/DI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -110,6 +112,7 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down

0 comments on commit 31cb85e

Please sign in to comment.