mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-15 00:46:51 +08:00
Add option to auto fix jpg orientation
This commit is contained in:
@@ -63,6 +63,7 @@ var (
|
||||
volumeDataFolders = cmdServer.Flag.String("dir", os.TempDir(), "directories to store data files. dir[,dir]...")
|
||||
volumeMaxDataVolumeCounts = cmdServer.Flag.String("volume.max", "7", "maximum numbers of volumes, count[,count]...")
|
||||
volumePulse = cmdServer.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats")
|
||||
volumeFixJpgOrientation = cmdServer.Flag.Bool("volume.fix.jpg.orientation", false, "Adjust jpg orientation when uploading.")
|
||||
isStartingFiler = cmdServer.Flag.Bool("filer", false, "whether to start filer")
|
||||
|
||||
serverWhiteList []string
|
||||
@@ -206,6 +207,7 @@ func runServer(cmd *Command, args []string) bool {
|
||||
r := http.NewServeMux()
|
||||
volumeServer := weed_server.NewVolumeServer(r, *serverIp, *volumePort, *serverPublicIp, folders, maxCounts,
|
||||
*serverIp+":"+strconv.Itoa(*masterPort), *volumePulse, *serverDataCenter, *serverRack, serverWhiteList,
|
||||
*volumeFixJpgOrientation,
|
||||
)
|
||||
|
||||
glog.V(0).Infoln("Start Weed volume server", util.VERSION, "at", *serverIp+":"+strconv.Itoa(*volumePort))
|
||||
|
@@ -37,6 +37,7 @@ var (
|
||||
dataCenter = cmdVolume.Flag.String("dataCenter", "", "current volume server's data center name")
|
||||
rack = cmdVolume.Flag.String("rack", "", "current volume server's rack name")
|
||||
volumeWhiteListOption = cmdVolume.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.")
|
||||
fixJpgOrientation = cmdVolume.Flag.Bool("fix.jpg.orientation", false, "Adjust jpg orientation when uploading.")
|
||||
|
||||
volumeWhiteList []string
|
||||
)
|
||||
@@ -80,6 +81,7 @@ func runVolume(cmd *Command, args []string) bool {
|
||||
|
||||
volumeServer := weed_server.NewVolumeServer(r, *ip, *vport, *publicIp, folders, maxCounts,
|
||||
*masterNode, *vpulse, *dataCenter, *rack, volumeWhiteList,
|
||||
*fixJpgOrientation,
|
||||
)
|
||||
|
||||
listeningAddress := *ip + ":" + strconv.Itoa(*vport)
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -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 == "" {
|
||||
|
Reference in New Issue
Block a user