2022-01-02 15:00:53 +01:00
|
|
|
package media
|
|
|
|
|
2022-01-03 17:37:38 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
|
|
|
)
|
2022-01-02 15:00:53 +01:00
|
|
|
|
|
|
|
type Media struct {
|
2022-01-03 17:37:38 +01:00
|
|
|
mu sync.Mutex
|
|
|
|
attachment *gtsmodel.MediaAttachment
|
|
|
|
rawData []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Media) Thumb() (*ImageMeta, error) {
|
|
|
|
m.mu.Lock()
|
|
|
|
thumb, err := deriveThumbnail(m.rawData, m.attachment.File.ContentType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error deriving thumbnail: %s", err)
|
|
|
|
}
|
|
|
|
m.attachment.Blurhash = thumb.blurhash
|
|
|
|
aaaaaaaaaaaaaaaa
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Media) PreLoad() {
|
|
|
|
m.mu.Lock()
|
|
|
|
defer m.mu.Unlock()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Media) Load() {
|
|
|
|
m.mu.Lock()
|
|
|
|
defer m.mu.Unlock()
|
2022-01-02 15:00:53 +01:00
|
|
|
}
|