529103462c
Related Issues: - Samsung: Initial support for Motion Photos (#439) - Google: Initial support for Motion Photos (#1739) - Metadata: Flag Samsung/Google Motion Photos as Live Photos (#2788) Related Pull Requests: - Live Photos: Add Support for Samsung Motion Photos (#3588) - Samsung: Improved support for Motion Photos (#3660) - Google: Initial support for Motion Photos (#3709) - Google: Add support for Motion Photos (#3722) Signed-off-by: Michael Mayer <michael@photoprism.app>
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package frame
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/disintegration/imaging"
|
|
"github.com/photoprism/photoprism/pkg/fs"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestImage(t *testing.T) {
|
|
t.Run("Polaroid", func(t *testing.T) {
|
|
img, err := imaging.Open("testdata/500x500.jpg")
|
|
assert.NoError(t, err)
|
|
|
|
saveName := "testdata/test-image.png"
|
|
|
|
out, err := Image(Polaroid, img, RandomAngle(30))
|
|
|
|
assert.NoError(t, err)
|
|
|
|
err = imaging.Save(out, saveName)
|
|
|
|
assert.NoError(t, err)
|
|
mimeType := fs.MimeType(saveName)
|
|
assert.Equal(t, fs.MimeTypePNG, mimeType)
|
|
|
|
_ = os.Remove(saveName)
|
|
})
|
|
|
|
t.Run("TypeUnknown", func(t *testing.T) {
|
|
img, err := imaging.Open("testdata/500x500.jpg")
|
|
assert.NoError(t, err)
|
|
|
|
saveName := "testdata/test-image.png"
|
|
|
|
out, err := Image("unknown", img, RandomAngle(30))
|
|
|
|
assert.Error(t, err)
|
|
assert.Equal(t, "unknown collage type unknown", err.Error())
|
|
|
|
err = imaging.Save(out, saveName)
|
|
|
|
assert.NoError(t, err)
|
|
mimeType := fs.MimeType(saveName)
|
|
assert.Equal(t, fs.MimeTypePNG, mimeType)
|
|
|
|
_ = os.Remove(saveName)
|
|
})
|
|
}
|