Skip to content

Commit 36909ab

Browse files
author
Anshul Goyal
committed
change preset
1 parent 5e1828c commit 36909ab

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

decode.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
package imageflow
22

33
// Decode is used to create a decode node in graph
4-
type Decode struct {
4+
type decode struct {
55
IoID int `json:"io_id"`
66
}
77

88
// toStep is used to convert a Decode to step
9-
func (decode Decode) toStep() map[string]interface{} {
9+
func (decode decode) toStep() map[string]interface{} {
1010
decodeMap := make(map[string]interface{})
1111
decodeMap["decode"] = decode
1212
return decodeMap
1313
}
1414

1515
// Preset is a interface for encoder used to convert to image
16-
type Preset interface {
16+
type presetInterface interface {
1717
toPreset() interface{}
1818
}
1919

2020
// Encode is used to convert to a image
21-
type Encode struct {
21+
type encode struct {
2222
IoID int `json:"io_id"`
2323
Preset interface{} `json:"preset"`
2424
}
2525

2626
// toStep is used to convert a Encode to step
27-
func (encode Encode) toStep() interface{} {
27+
func (encode encode) toStep() interface{} {
2828
encodeMap := make(map[string]interface{})
2929
encodeMap["encode"] = encode
3030
return encodeMap
@@ -38,7 +38,7 @@ type MozJPEG struct {
3838

3939
// toPreset is used to convert the MozJPG to a preset
4040
func (preset MozJPEG) toPreset() interface{} {
41-
presetMap := make(map[string]Preset)
41+
presetMap := make(map[string]presetInterface)
4242
if preset.Quality == 0 {
4343
preset.Quality = 100
4444
}
@@ -61,7 +61,7 @@ type LosslessPNG struct {
6161

6262
// toPreset is used to LosslessPNG to Preset
6363
func (preset LosslessPNG) toPreset() interface{} {
64-
presetMap := make(map[string]Preset)
64+
presetMap := make(map[string]presetInterface)
6565
presetMap["lodepng"] = preset
6666
return presetMap
6767
}
@@ -76,7 +76,7 @@ type LossyPNG struct {
7676

7777
// toPreset is used to convert LossPNG to preset
7878
func (preset LossyPNG) toPreset() interface{} {
79-
presetMap := make(map[string]Preset)
79+
presetMap := make(map[string]presetInterface)
8080
presetMap["pngquant"] = preset
8181
return presetMap
8282
}
@@ -91,7 +91,7 @@ func (preset WebP) toPreset() interface{} {
9191
if preset.Quality == 0 {
9292
preset.Quality = 100
9393
}
94-
presetMap := make(map[string]Preset)
94+
presetMap := make(map[string]presetInterface)
9595
presetMap["webplossy"] = preset
9696
return presetMap
9797
}
@@ -205,7 +205,7 @@ func (step Constrain) toStep() interface{} {
205205
if step.CanvasColor != nil {
206206
step.CanvasColor = step.CanvasColor.(Color).toColor()
207207
}
208-
stepMap := make(map[string]Step)
208+
stepMap := make(map[string]stepInterface)
209209
stepMap["constrain"] = step
210210
return stepMap
211211
}
@@ -223,7 +223,7 @@ type Region struct {
223223
// toStep create a step from Region
224224
func (region Region) toStep() interface{} {
225225
region.BackgroundColor = region.BackgroundColor.(Color).toColor()
226-
stepMap := make(map[string]Step)
226+
stepMap := make(map[string]stepInterface)
227227
stepMap["region"] = region
228228
return stepMap
229229
}
@@ -241,7 +241,7 @@ type RegionPercentage struct {
241241
// toStep create a step from Region
242242
func (region RegionPercentage) toStep() interface{} {
243243
region.BackgroundColor = region.BackgroundColor.(Color).toColor()
244-
stepMap := make(map[string]Step)
244+
stepMap := make(map[string]stepInterface)
245245
stepMap["region_percent"] = region
246246
return stepMap
247247
}
@@ -256,7 +256,7 @@ type cropWhitespace struct {
256256

257257
// toStep create a step from Region
258258
func (region cropWhitespace) toStep() interface{} {
259-
stepMap := make(map[string]Step)
259+
stepMap := make(map[string]stepInterface)
260260
stepMap["crop_whitespace"] = region
261261
return stepMap
262262
}
@@ -312,7 +312,7 @@ type fillRect struct {
312312

313313
// toStep create a step from fillRect
314314
func (region fillRect) toStep() interface{} {
315-
stepMap := make(map[string]Step)
315+
stepMap := make(map[string]stepInterface)
316316
region.Color = region.Color.(Color).toColor()
317317
stepMap["fill_rect"] = region
318318
return stepMap
@@ -329,7 +329,7 @@ type ExpandCanvas struct {
329329

330330
// toStep create a step from fillRect
331331
func (region ExpandCanvas) toStep() interface{} {
332-
stepMap := make(map[string]Step)
332+
stepMap := make(map[string]stepInterface)
333333
region.Color = region.Color.(Color).toColor()
334334
stepMap["expand_canvas"] = region
335335
return stepMap
@@ -390,7 +390,7 @@ func (watermark watermark) toStep() interface{} {
390390
if watermark.FitBox != nil {
391391
watermark.FitBox = watermark.FitBox.(FitBox).toFitBox()
392392
}
393-
stepMap := make(map[string]Step)
393+
stepMap := make(map[string]stepInterface)
394394
if watermark.Gravity != nil {
395395
watermark.Gravity = watermark.Gravity.(ConstraintGravity).toGravity()
396396
}

imageflow.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Steps struct {
1919
func (steps *Steps) Decode(task ioOperation) *Steps {
2020
steps.inputs = append(steps.inputs, task)
2121
task.setIo(uint(steps.ioID))
22-
steps.vertex = append(steps.vertex, Decode{
22+
steps.vertex = append(steps.vertex, decode{
2323
IoID: steps.ioID,
2424
}.toStep())
2525
steps.ioID++
@@ -61,10 +61,10 @@ func constrainWithinMap(w interface{}, h interface{}) map[string]interface{} {
6161
}
6262

6363
// Encode is used to convert the image
64-
func (steps *Steps) Encode(task ioOperation, preset Preset) *Steps {
64+
func (steps *Steps) Encode(task ioOperation, preset presetInterface) *Steps {
6565
task.setIo(uint(steps.ioID))
6666
steps.outputs = append(steps.outputs, task)
67-
steps.input(Encode{
67+
steps.input(encode{
6868
IoID: steps.ioID,
6969
Preset: preset.toPreset(),
7070
}.toStep())
@@ -113,7 +113,7 @@ func (steps *Steps) input(step interface{}) {
113113
steps.last = uint(len(steps.vertex) - 1)
114114
}
115115

116-
func (steps *Steps) canvas(f func(*Steps), step Step) *Steps {
116+
func (steps *Steps) canvas(f func(*Steps), step stepInterface) *Steps {
117117
last := steps.last
118118
f(steps)
119119
steps.vertex = append(steps.vertex, step.toStep())
@@ -322,7 +322,7 @@ func (steps *Steps) colorFilterSRGBValue(name string, value float32) *Steps {
322322
}
323323

324324
// Step specify different nodes
325-
type Step interface {
325+
type stepInterface interface {
326326
toStep() interface{}
327327
}
328328

0 commit comments

Comments
 (0)