diff options
author | 2024-08-02 11:46:41 +0000 | |
---|---|---|
committer | 2024-08-02 12:46:41 +0100 | |
commit | 94e87610c4ce9bbb1c614a61bab29c1422fed11b (patch) | |
tree | 2e06b8ce64212140e796f6077ba841b6cc678501 /vendor/github.com/superseriousbusiness/go-png-image-structure/v2/utility.go | |
parent | [feature] Allow import of following and blocks via CSV (#3150) (diff) | |
download | gotosocial-94e87610c4ce9bbb1c614a61bab29c1422fed11b.tar.xz |
[chore] add back exif-terminator and use only for jpeg,png,webp (#3161)
* add back exif-terminator and use only for jpeg,png,webp
* fix arguments passed to terminateExif()
* pull in latest exif-terminator
* fix test
* update processed img
---------
Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'vendor/github.com/superseriousbusiness/go-png-image-structure/v2/utility.go')
-rw-r--r-- | vendor/github.com/superseriousbusiness/go-png-image-structure/v2/utility.go | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/vendor/github.com/superseriousbusiness/go-png-image-structure/v2/utility.go b/vendor/github.com/superseriousbusiness/go-png-image-structure/v2/utility.go new file mode 100644 index 000000000..cac6020f2 --- /dev/null +++ b/vendor/github.com/superseriousbusiness/go-png-image-structure/v2/utility.go @@ -0,0 +1,67 @@ +package pngstructure + +import ( + "bytes" + "fmt" +) + +func DumpBytes(data []byte) { + fmt.Printf("DUMP: ") + for _, x := range data { + fmt.Printf("%02x ", x) + } + + fmt.Printf("\n") +} + +func DumpBytesClause(data []byte) { + fmt.Printf("DUMP: ") + + fmt.Printf("[]byte { ") + + for i, x := range data { + fmt.Printf("0x%02x", x) + + if i < len(data)-1 { + fmt.Printf(", ") + } + } + + fmt.Printf(" }\n") +} + +func DumpBytesToString(data []byte) (string, error) { + b := new(bytes.Buffer) + + for i, x := range data { + if _, err := b.WriteString(fmt.Sprintf("%02x", x)); err != nil { + return "", err + } + + if i < len(data)-1 { + if _, err := b.WriteRune(' '); err != nil { + return "", err + } + } + } + + return b.String(), nil +} + +func DumpBytesClauseToString(data []byte) (string, error) { + b := new(bytes.Buffer) + + for i, x := range data { + if _, err := b.WriteString(fmt.Sprintf("0x%02x", x)); err != nil { + return "", err + } + + if i < len(data)-1 { + if _, err := b.WriteString(", "); err != nil { + return "", err + } + } + } + + return b.String(), nil +} |