|
@ -36,6 +36,10 @@ type Pipeline struct { |
|
|
Type PipelineType `json:"type" faker:"-"` |
|
|
Type PipelineType `json:"type" faker:"-"` |
|
|
RemoveMetadata bool `json:"remove_metadata" faker:"-"` |
|
|
RemoveMetadata bool `json:"remove_metadata" faker:"-"` |
|
|
Steps []Step `json:"steps" faker:"-"` |
|
|
Steps []Step `json:"steps" faker:"-"` |
|
|
|
|
|
Output struct { |
|
|
|
|
|
Format int `json:"format"` |
|
|
|
|
|
Quality int `json:"quality"` |
|
|
|
|
|
} `json:"output" faker:"-"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (p Pipeline) Run(srcPath, bucketName string, storageProvider storage.IStorageProvider) (string, error) { |
|
|
func (p Pipeline) Run(srcPath, bucketName string, storageProvider storage.IStorageProvider) (string, error) { |
|
@ -58,9 +62,16 @@ func (p Pipeline) Run(srcPath, bucketName string, storageProvider storage.IStora |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
format := imaging.Format(p.Output.Format) |
|
|
|
|
|
var options []imaging.EncodeOption |
|
|
|
|
|
|
|
|
|
|
|
if p.Output.Quality != 0 { |
|
|
|
|
|
options = append(options, imaging.JPEGQuality(p.Output.Quality)) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// encode image to io buffer
|
|
|
// encode image to io buffer
|
|
|
buffer := new(bytes.Buffer) |
|
|
buffer := new(bytes.Buffer) |
|
|
if err := imaging.Encode(buffer, src, imaging.JPEG); err != nil { |
|
|
|
|
|
|
|
|
if err := imaging.Encode(buffer, src, format, options...); err != nil { |
|
|
return "", err |
|
|
return "", err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|