Skip to content

Commit

Permalink
Remove optimization in FluentBuildJob.ToFramewise that breaks branchi…
Browse files Browse the repository at this point in the history
…ng. Test branching
  • Loading branch information
lilith committed Apr 18, 2020
1 parent 53bda06 commit 8aa89b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
9 changes: 1 addition & 8 deletions src/Imageflow/Fluent/FluentBuildJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,7 @@ private static IEnumerable<Tuple<long, long, EdgeKind>> CollectEdges(ICollection
internal object ToFramewise()
{
var nodes = CollectUnique();
if (nodes.All(n => n.Canvas == null) && nodes.Count(n => n.Canvas == null && n.Input == null) == 1)
{
return new {steps = nodes.OrderBy(n => n.Uid).Select(n => n.NodeData).ToList()};
}
else
{
return ToFramewiseGraph(nodes);
}
return ToFramewiseGraph(nodes);
}

private object ToFramewiseGraph(ICollection<BuildItemBase> uniqueNodes)
Expand Down
24 changes: 22 additions & 2 deletions tests/Imageflow.Test/TestApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public void TestGetImageInfo()
Assert.Equal(result.PreferredExtension, "png");
Assert.Equal(result.PreferredMimeType, "image/png");
Assert.Equal(result.FrameDecodesInto, PixelFormat.Bgr_32);


}

}
Expand Down Expand Up @@ -68,6 +66,28 @@ public async Task TestConstraints()
}

}
[Fact]
public async Task TestMultipleOutputs()
{
var imageBytes = Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/TQBcNTh/AAAAAXRSTlPM0jRW/QAAAApJREFUeJxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII=");
using (var b = new FluentBuildJob())
{
var r = await b.Decode(imageBytes).
Constrain(new Constraint(ConstraintMode.Fit, 160, 120))
.Branch(f => f.ConstrainWithin(80, 60).EncodeToBytes(new GifEncoder()))
.Branch(f => f.ConstrainWithin(40, 30).EncodeToBytes(new LibJpegTurboEncoder()))
.EncodeToBytes(new LibPngEncoder())
.Finish().InProcessAsync();

Assert.Equal(60, r.TryGet(1).Width);
Assert.Equal(30, r.TryGet(2).Width);
Assert.Equal(120, r.TryGet(3).Width);
Assert.True(r.First.TryGetBytes().HasValue);
}

}



[Fact]
public async Task TestCommandStringJob()
Expand Down

0 comments on commit 8aa89b2

Please sign in to comment.