|
|
|
@ -94,14 +94,18 @@ func (fs *FileSystem) GenerateThumbnail(ctx context.Context, file *model.File) {
|
|
|
|
|
currentPosition, err := source.Seek(0, 1)
|
|
|
|
|
source.Seek(0,0)
|
|
|
|
|
x, err := exif.Decode(source)
|
|
|
|
|
source.Seek(currentPosition, 0)
|
|
|
|
|
if err != nil {
|
|
|
|
|
util.Log().Warning("照片解析EXIF失败:%s", err)
|
|
|
|
|
}
|
|
|
|
|
source.Seek(currentPosition, 0)
|
|
|
|
|
ExifCamModel, _ := x.Get(exif.Model) // normally, don't ignore errors!
|
|
|
|
|
}else{
|
|
|
|
|
ExifCamModel, _ := x.Get(exif.Model)
|
|
|
|
|
file.ExifModel,_ = ExifCamModel.StringVal()
|
|
|
|
|
|
|
|
|
|
ExifDateTime, _ := x.DateTime()
|
|
|
|
|
if !ExifDateTime.IsZero() {
|
|
|
|
|
file.ExifDateTime = ExifDateTime
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lat, long, _ := x.LatLong()
|
|
|
|
|
if lat > 0 && long > 0 {
|
|
|
|
|
file.ExifLatLong = fmt.Sprintf("%f,%f", lat, long)
|
|
|
|
@ -109,11 +113,14 @@ func (fs *FileSystem) GenerateThumbnail(ctx context.Context, file *model.File) {
|
|
|
|
|
util.Log().Debug("照片的经纬度:%f,%f", lat,long)
|
|
|
|
|
if file.Model.ID > 0 {
|
|
|
|
|
file.UpdatePicExifModel(file.ExifModel)
|
|
|
|
|
if !ExifDateTime.IsZero() {
|
|
|
|
|
file.UpdatePicExifDateTime(file.ExifDateTime)
|
|
|
|
|
}
|
|
|
|
|
if lat > 0 && long > 0 {
|
|
|
|
|
file.UpdatePicExifLatLong(file.ExifLatLong)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 失败时删除缩略图文件
|
|
|
|
|