Add option to auto fix jpg orientation

This commit is contained in:
Chris Lu
2014-05-15 01:08:00 -07:00
parent 025589adf8
commit dcd12576c6
5 changed files with 19 additions and 20 deletions

View File

@@ -16,19 +16,22 @@ type VolumeServer struct {
rack string
whiteList []string
store *storage.Store
FixJpgOrientation bool
}
func NewVolumeServer(r *http.ServeMux, ip string, port int, publicIp string, folders []string, maxCounts []int,
masterNode string, pulseSeconds int,
dataCenter string, rack string,
whiteList []string) *VolumeServer {
whiteList []string, fixJpgOrientation bool) *VolumeServer {
publicUrl := publicIp + ":" + strconv.Itoa(port)
vs := &VolumeServer{
masterNode: masterNode,
pulseSeconds: pulseSeconds,
dataCenter: dataCenter,
rack: rack,
whiteList: whiteList,
masterNode: masterNode,
pulseSeconds: pulseSeconds,
dataCenter: dataCenter,
rack: rack,
whiteList: whiteList,
FixJpgOrientation: fixJpgOrientation,
}
vs.store = storage.NewStore(port, ip, publicUrl, folders, maxCounts)

View File

@@ -156,6 +156,10 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
return
}
if vs.FixJpgOrientation && strings.HasSuffix(string(needle.Name), ".jpg") {
needle.Data = images.FixJpgOrientation(needle.Data)
}
ret := operation.UploadResult{}
size, errorStatus := topology.ReplicatedWrite(vs.masterNode, vs.store, volumeId, needle, r)
if errorStatus == "" {