returnnil,utils.HandleError("cr2 raw image decoding",err)
}
}else{
photoImg,_,err=image.Decode(photoFile)
iferr!=nil{
returnnil,utils.HandleError("image decoding",err)
}
}
// Get orientation from exif data
row:=tx.QueryRow("SELECT photo_exif.orientation FROM photo JOIN photo_exif WHERE photo.exif_id = photo_exif.exif_id AND photo.photo_id = ?",img.photo.PhotoID)
varorientation*int
iferr=row.Scan(&orientation);err!=nil{
// If not found use default orientation (not rotate)
iferr==sql.ErrNoRows{
orientation=nil
}else{
returnnil,err
}
}
iforientation==nil{
defaultOrientation:=0
orientation=&defaultOrientation
}
switch*orientation{
case2:
photoImg=imaging.FlipH(photoImg)
break
case3:
photoImg=imaging.Rotate180(photoImg)
break
case4:
photoImg=imaging.FlipV(photoImg)
break
case5:
photoImg=imaging.Transpose(photoImg)
break
case6:
photoImg=imaging.Rotate270(photoImg)
break
case7:
photoImg=imaging.Transverse(photoImg)
break
case8:
photoImg=imaging.Rotate90(photoImg)
break
default:
break
}
img._photoImage=photoImg
returnimg._photoImage,nil
}
// ThumbnailImage downsizes the image and returns it