|
1 | 1 | # DotNetCampus.MediaConverters
|
2 | 2 |
|
| 3 | +## Usage |
| 4 | + |
| 5 | +### Command Line |
| 6 | + |
| 7 | +Command line parameters: |
| 8 | + |
| 9 | +```shell |
| 10 | +--WorkingFolder: Working directory |
| 11 | +--InputFile: Path to the input file |
| 12 | +--OutputFile: Path to the output file |
| 13 | +--ConvertConfigurationFile: Path to the conversion configuration file |
| 14 | +``` |
| 15 | + |
| 16 | +The `--ConvertConfigurationFile` parameter specifies a JSON-format configuration file, which contains the settings for the conversion tasks. The configuration follows the structure of a serialized `ImageConvertContext` object, defined as follows: |
| 17 | + |
| 18 | +- **MaxImageWidth**: Maximum image width limit. Optional; if omitted or empty, no limit is applied. |
| 19 | +- **MaxImageHeight**: Maximum image height limit. Optional; if omitted or empty, no limit is applied. |
| 20 | +- **UseAreaSizeLimit**: Whether to apply an area size limit. Optional; if omitted or empty, the default is to use an area size limit. |
| 21 | +- **ImageConvertTaskList**: List of conversion tasks. Optional; if omitted or empty, no conversion tasks will be performed. This should be an array of objects implementing the `IImageConvertTask` interface. |
| 22 | + |
| 23 | +Each task object must contain a `Type` property indicating the type of task. The available task types and their parameters are as follows: |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +#### SetSoftEdgeEffectTask |
| 28 | + |
| 29 | +Applies a soft edge effect to the image. |
| 30 | + |
| 31 | +- **Radius**: The radius of the soft edge in pixels. Optional. |
| 32 | + |
| 33 | +Example: |
| 34 | + |
| 35 | +```json |
| 36 | +{ |
| 37 | + "ImageConvertTaskList": |
| 38 | + [ |
| 39 | + { |
| 40 | + "Type": "SetSoftEdgeEffectTask", |
| 41 | + "Radius": 20 |
| 42 | + } |
| 43 | + ] |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +#### SetLuminanceEffectTask |
| 50 | + |
| 51 | +Applies a luminance (erosion) effect to the image. |
| 52 | + |
| 53 | +Example: |
| 54 | + |
| 55 | +```json |
| 56 | +{ |
| 57 | + "ImageConvertTaskList": |
| 58 | + [ |
| 59 | + { |
| 60 | + "Type": "SetLuminanceEffectTask" |
| 61 | + } |
| 62 | + ] |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +#### SetGrayScaleEffectTask |
| 69 | + |
| 70 | +Converts the image to grayscale. |
| 71 | + |
| 72 | +Example: |
| 73 | + |
| 74 | +```json |
| 75 | +{ |
| 76 | + "ImageConvertTaskList": |
| 77 | + [ |
| 78 | + { |
| 79 | + "Type": "SetGrayScaleEffectTask" |
| 80 | + } |
| 81 | + ] |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +#### SetContrastTask |
| 88 | + |
| 89 | +Adjusts the contrast of the current image. |
| 90 | + |
| 91 | +- **Percentage**: A value of 0 produces a completely gray image. A value of 1 leaves the input unchanged. Other values act as linear multipliers for contrast adjustment. Values greater than 1 are allowed for increased contrast. |
| 92 | + |
| 93 | +Example: |
| 94 | + |
| 95 | +```json |
| 96 | +{ |
| 97 | + "ImageConvertTaskList": |
| 98 | + [ |
| 99 | + { |
| 100 | + "Type": "SetContrastTask", |
| 101 | + "Percentage": 0.7 |
| 102 | + } |
| 103 | + ] |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +#### SetBrightnessTask |
| 110 | + |
| 111 | +Adjusts the brightness of the current image. |
| 112 | + |
| 113 | +- **Percentage**: A value of 0 produces a completely black image. A value of 1 leaves the input unchanged. Other values act as linear multipliers for brightness adjustment. Values greater than 1 are allowed for increased brightness. |
| 114 | + |
| 115 | +Example: |
| 116 | + |
| 117 | +```json |
| 118 | +{ |
| 119 | + "ImageConvertTaskList": |
| 120 | + [ |
| 121 | + { |
| 122 | + "Type": "SetBrightnessTask", |
| 123 | + "Percentage": 0.7 |
| 124 | + } |
| 125 | + ] |
| 126 | +} |
| 127 | +``` |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +#### SetBlackWhiteEffectTask |
| 132 | + |
| 133 | +Converts the image to black and white. |
| 134 | + |
| 135 | +- **Threshold**: Threshold value for black-and-white conversion (optional). |
| 136 | + |
| 137 | +Example: |
| 138 | + |
| 139 | +```json |
| 140 | +{ |
| 141 | + "ImageConvertTaskList": |
| 142 | + [ |
| 143 | + { |
| 144 | + "Type": "SetBlackWhiteEffectTask", |
| 145 | + "Threshold": 0.7 |
| 146 | + } |
| 147 | + ] |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +#### SetDuotoneEffectTask |
| 154 | + |
| 155 | +Applies a duotone effect using two specified colors. |
| 156 | + |
| 157 | +- **ArgbFormatColor1**: ARGB format string representing color 1. |
| 158 | +- **ArgbFormatColor2**: ARGB format string representing color 2. |
| 159 | + |
| 160 | +Example: |
| 161 | + |
| 162 | +```json |
| 163 | +{ |
| 164 | + "ImageConvertTaskList": |
| 165 | + [ |
| 166 | + { |
| 167 | + "Type": "SetDuotoneEffectTask", |
| 168 | + "ArgbFormatColor1": "#FFF1D7A6", |
| 169 | + "ArgbFormatColor2": "#FFFFF2C8" |
| 170 | + } |
| 171 | + ] |
| 172 | +} |
| 173 | +``` |
| 174 | + |
| 175 | +--- |
| 176 | + |
| 177 | +#### ReplaceColorTask |
| 178 | + |
| 179 | +Replaces specific colors in the image with new ones. |
| 180 | + |
| 181 | +- **ReplaceColorInfoList**: A list containing color replacement information. Each entry includes: |
| 182 | + - **OldColor**: ARGB format string for the color to be replaced. |
| 183 | + - **NewColor**: ARGB format string for the replacement color. |
| 184 | + |
| 185 | +Example: |
| 186 | + |
| 187 | +```json |
| 188 | +{ |
| 189 | + "ImageConvertTaskList": |
| 190 | + [ |
| 191 | + { |
| 192 | + "Type": "ReplaceColorTask", |
| 193 | + "ReplaceColorInfoList": |
| 194 | + [ |
| 195 | + { |
| 196 | + "OldColor": "#FFF1D7A6", |
| 197 | + "NewColor": "#00FFFFFF" |
| 198 | + }, |
| 199 | + { |
| 200 | + "OldColor": "#FFFFF2C8", |
| 201 | + "NewColor": "#00FFFFFF" |
| 202 | + }, |
| 203 | + { |
| 204 | + "OldColor": "#FFE3D8AB", |
| 205 | + "NewColor": "#00FFFFFF" |
| 206 | + } |
| 207 | + ] |
| 208 | + } |
| 209 | + ] |
| 210 | +} |
| 211 | +``` |
| 212 | + |
3 | 213 | ## Copyright Notice
|
4 | 214 |
|
5 | 215 | If you use MediaConverters.Lib as a direct dependency, you must comply with the [Six Labors Split License, Version 1.0](ThirdPartyNotices/SixLabors.LICENSE.txt). This is because this project uses Six Labors' ImageSharp library as its infrastructure.
|
|
0 commit comments