mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-03 16:22:25 -06:00
[feature] media: add webp support (#1155)
* media: add webp support Signed-off-by: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> * bump exif-terminator to v0.5.0 Signed-off-by: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> Signed-off-by: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
This commit is contained in:
parent
f9e5ec99bd
commit
1a3f26fb5c
26 changed files with 4348 additions and 19 deletions
14
vendor/github.com/superseriousbusiness/exif-terminator/terminator.go
generated
vendored
14
vendor/github.com/superseriousbusiness/exif-terminator/terminator.go
generated
vendored
|
|
@ -43,6 +43,8 @@ func Terminate(in io.Reader, fileSize int, mediaType string) (io.Reader, error)
|
|||
switch mediaType {
|
||||
case "image/jpeg", "jpeg", "jpg":
|
||||
err = terminateJpeg(scanner, pipeWriter, fileSize)
|
||||
case "image/webp", "webp":
|
||||
err = terminateWebp(scanner, pipeWriter)
|
||||
case "image/png", "png":
|
||||
// for pngs we need to skip the header bytes, so read them in
|
||||
// and check we're really dealing with a png here
|
||||
|
|
@ -86,6 +88,18 @@ func terminateJpeg(scanner *bufio.Scanner, writer io.WriteCloser, expectedFileSi
|
|||
return nil
|
||||
}
|
||||
|
||||
func terminateWebp(scanner *bufio.Scanner, writer io.WriteCloser) error {
|
||||
v := &webpVisitor{
|
||||
writer: writer,
|
||||
}
|
||||
|
||||
// use the webp visitor's 'split' function, which satisfies the bufio.SplitFunc interface
|
||||
scanner.Split(v.split)
|
||||
|
||||
scanAndClose(scanner, writer)
|
||||
return nil
|
||||
}
|
||||
|
||||
func terminatePng(scanner *bufio.Scanner, writer io.WriteCloser) error {
|
||||
ps := pngstructure.NewPngSplitter()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue