File tree Expand file tree Collapse file tree
src/MediaConverters/MediaConverters.Tool Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66public class SetSoftEdgeEffectTask : IImageConvertTask
77{
88 public float Radius { get ; init ; }
9+
10+ /// <summary>
11+ /// 要求的图片宽度,如果不指定则使用原图宽度
12+ /// </summary>
13+ public int ? ImageWidth { get ; init ; }
14+
15+ /// <summary>
16+ /// 要求的图片高度,如果不指定则使用原图高度
17+ /// </summary>
18+ public int ? ImageHeight { get ; init ; }
919}
Original file line number Diff line number Diff line change 22using DotNetCampus . MediaConverters . Imaging . Effects ;
33using SixLabors . ImageSharp ;
44using SixLabors . ImageSharp . PixelFormats ;
5+ using SixLabors . ImageSharp . Processing ;
56
67namespace DotNetCampus . MediaConverters . Workers ;
78
89internal class SetSoftEdgeEffectWorker : WorkerBase < SetSoftEdgeEffectTask >
910{
1011 protected override void RunCore ( Image < Rgba32 > image , SetSoftEdgeEffectTask task )
1112 {
13+ if ( task . ImageWidth is not null || task . ImageHeight is not null )
14+ {
15+ var width = task . ImageWidth ?? image . Width ;
16+ var height = task . ImageHeight ?? image . Height ;
17+ image . Mutate ( context => context . Resize ( width , height ) ) ;
18+ }
19+
1220 image . SetSoftEdgeEffect ( task . Radius ) ;
1321 }
1422}
You can’t perform that action at this time.
0 commit comments