-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conditional text, image watermark methods
- Loading branch information
Showing
7 changed files
with
364 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
LazZiya.ImageResize/Animated/AnimatedImageAnimatedTextWatermarkConditional.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
namespace LazZiya.ImageResize.Animated | ||
{ | ||
/// <summary> | ||
/// Add animated text watermark over animated image, depending on a condition parameter. | ||
/// </summary> | ||
public static class AnimatedImageAnimatedTextWatermarkConditional | ||
{ | ||
/// <summary> | ||
/// Add animated text watermark over animated image, depending on a conditon parameter. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add text watermark, false will return the img</param> | ||
/// <param name="text"></param> | ||
public static AnimatedImage AddAnimatedTextWatermarkIf(this AnimatedImage img, bool condition, string text) | ||
{ | ||
return condition ? AnimatedImageAnimatedTextWatermark.AddAnimatedTextWatermark(img, text) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Add animated text watermark over animated image, depending on a conditon parameter. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add text watermark, false will return the img</param> | ||
/// <param name="text"></param> | ||
/// <param name="animOps"></param> | ||
public static AnimatedImage AddAnimatedTextWatermarkIf(this AnimatedImage img, bool condition, string text, AnimatedTextWatermarkOptions animOps) | ||
{ | ||
return condition ? AnimatedImageAnimatedTextWatermark.AddAnimatedTextWatermark(img, text, animOps) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Add animated text watermark over animated image, depending on a conditon parameter. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add text watermark, false will return the img</param> | ||
/// <param name="text">text to draw over the image</param> | ||
/// <param name="ops">Text watermark options <see cref="TextWatermarkOptions"/></param> | ||
public static AnimatedImage AddAnimatedTextWatermarkIf(this AnimatedImage img, bool condition, string text, TextWatermarkOptions ops) | ||
{ | ||
return condition ? AnimatedImageAnimatedTextWatermark.AddAnimatedTextWatermark(img, text, ops) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Add animated text watermark over animated image, depending on a conditon parameter. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add text watermark, false will return the img</param> | ||
/// <param name="text">text to draw over the image</param> | ||
/// <param name="ops">Text watermark options <see cref="TextWatermarkOptions"/></param> | ||
/// <param name="animOps">Animated text options <see cref="AnimatedTextWatermarkOptions"/></param> | ||
public static AnimatedImage AddAnimatedTextWatermarkIf(this AnimatedImage img, bool condition, string text, TextWatermarkOptions ops, AnimatedTextWatermarkOptions animOps) | ||
{ | ||
return condition ? AnimatedImageAnimatedTextWatermark.AddAnimatedTextWatermark(img, text, ops, animOps) : img; | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
LazZiya.ImageResize/Animated/AnimatedImageImageWatermarkConditional.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Drawing; | ||
|
||
namespace LazZiya.ImageResize.Animated | ||
{ | ||
/// <summary> | ||
/// Add a static image watermark over animated image, depending on a condition parameter. | ||
/// </summary> | ||
public static class AnimatedImageImageWatermarkConditional | ||
{ | ||
/// <summary> | ||
/// Add a static image watermark over animated image, depending on a condition parameter. | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add image watermark, false will return the img</param> | ||
/// <param name="wmImgPath">Path to the watermark image file e.g. wwwroot\images\watermark.png</param> | ||
public static AnimatedImage AddImageWatermarkIf(this AnimatedImage img, bool condition, string wmImgPath) | ||
{ | ||
return condition ? AnimatedImageImageWatermark.AddImageWatermark(img, wmImgPath) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Add a static image watermark over animated image, depending on a condition parameter. | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add image watermark, false will return the img</param> | ||
/// <param name="wmImage">Watermark image</param> | ||
public static AnimatedImage AddImageWatermarkIf(this AnimatedImage img, bool condition, Image wmImage) | ||
{ | ||
return condition ? AnimatedImageImageWatermark.AddImageWatermark(img, wmImage) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Add a static image watermark over animated image, depending on a condition parameter. | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add image watermark, false will return the img</param> | ||
/// <param name="wmImgPath">Path to the watermark image file e.g. wwwroot\images\watermark.png</param> | ||
/// <param name="ops">Image watermark options <see cref="ImageWatermarkOptions"/></param> | ||
public static AnimatedImage AddImageWatermarkIf(this AnimatedImage img, bool condition, string wmImgPath, ImageWatermarkOptions ops) | ||
{ | ||
return condition ? AnimatedImageImageWatermark.AddImageWatermark(img, wmImgPath, ops) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Add a static image watermark over animated image, depending on a condition parameter. | ||
/// <para>Notice regarding watermark opacity:</para> | ||
/// <para>If watermark image needs to be resized, first resize the watermark image, | ||
/// then save it to the disc, and read it again with Image.FromFile.</para> | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add image watermark, false will return the img</param> | ||
/// <param name="wmImage">Watermak image</param> | ||
/// <param name="ops">Image watermark options <see cref="ImageWatermarkOptions"/></param> | ||
public static AnimatedImage AddImageWatermarkIf(this AnimatedImage img, bool condition, Image wmImage, ImageWatermarkOptions ops) | ||
{ | ||
return condition ? AnimatedImageImageWatermark.AddImageWatermark(img, wmImage, ops) : img; | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
LazZiya.ImageResize/Animated/AnimatedImageTextWatermarkConditional.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using LazZiya.ImageResize.Animated; | ||
|
||
namespace LazZiya.ImageResize | ||
{ | ||
/// <summary> | ||
/// Add a static text watermark over animated image, depending on a condition parameter | ||
/// </summary> | ||
public static class AnimatedImageTextWatermarkConditional | ||
{ | ||
/// <summary> | ||
/// Add a static text watermark over animated image depending on a condition parameter. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add text watermark, false will return the img</param> | ||
/// <param name="text"></param> | ||
public static AnimatedImage AddTextWatermarkIf(this AnimatedImage img, bool condition, string text) | ||
{ | ||
return condition ? AnimatedImageTextWatermark.AddTextWatermark(img, text) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Add a static text watermark over animated image depending on a condition parameter. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add text watermark, false will return the img</param> | ||
/// <param name="text">text to draw over the image</param> | ||
/// <param name="ops">Text watermark options <see cref="TextWatermarkOptions"/></param> | ||
public static AnimatedImage AddTextWatermarkIf(this AnimatedImage img, bool condition, string text, TextWatermarkOptions ops) | ||
{ | ||
return condition ? AnimatedImageTextWatermark.AddTextWatermark(img, text, ops) : img; | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
LazZiya.ImageResize/Animated/ImageAnimatedImageWatermarkConditional.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
|
||
namespace LazZiya.ImageResize.Animated | ||
{ | ||
|
||
/// <summary> | ||
/// Add an animated image watermark to static image adn return an AnimatedImage, depending on a condition parameter. | ||
/// </summary> | ||
public static class ImageAnimatedImageWatermarkConditional | ||
{ | ||
/// <summary> | ||
/// Draw animated image watermark over a static image, depending on a condition parameter. | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add animated image watermark, false will return the img as AnimatedImage</param> | ||
/// <param name="wmImgPath">Path to the watermark image file e.g. wwwroot\images\watermark.png</param> | ||
public static AnimatedImage AddAnimatedImageWatermarkIf(this Image img, bool condition, string wmImgPath) | ||
{ | ||
return condition ? ImageAnimatedImageWatermark.AddAnimatedImageWatermark(img, wmImgPath) : new AnimatedImage(new[] { img }); | ||
} | ||
|
||
/// <summary> | ||
/// Draw animated image watermark over a static image, depending on a condition parameter. | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add animated image watermark, false will return the img as AnimatedImage</param> | ||
/// <param name="wmImage">Watermark image</param> | ||
public static AnimatedImage AddAnimatedImageWatermarkIf(this Image img, bool condition, AnimatedImage wmImage) | ||
{ | ||
return condition ? ImageAnimatedImageWatermark.AddAnimatedImageWatermark(img, wmImage) : new AnimatedImage(new[] { img }); | ||
} | ||
|
||
/// <summary> | ||
/// Draw animated image watermark over a static image, depending on a condition parameter. | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add animated image watermark, false will return the img as AnimatedImage</param> | ||
/// <param name="wmImgPath">Path to the watermark image file e.g. wwwroot\images\watermark.png</param> | ||
/// <param name="ops">Image watermark options <see cref="ImageWatermarkOptions"/></param> | ||
public static AnimatedImage AddAnimatedImageWatermarkIf(this Image img, bool condition, string wmImgPath, ImageWatermarkOptions ops) | ||
{ | ||
return condition ? ImageAnimatedImageWatermark.AddAnimatedImageWatermark(img, wmImgPath, ops) : new AnimatedImage(new[] { img }); | ||
} | ||
|
||
/// <summary> | ||
/// Draw animated image watermark over a static image, depending on a condition parameter. | ||
/// <para>Notice regarding watermark opacity:</para> | ||
/// <para>If watermark image needs to be resized, first resize the watermark image, | ||
/// then save it to the disc, and read it again with Image.FromFile.</para> | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add animated image watermark, false will return the img as AnimatedImage</param> | ||
/// <param name="wmImage">Watermak image</param> | ||
/// <param name="ops">Image watermark options <see cref="ImageWatermarkOptions"/></param> | ||
public static AnimatedImage AddAnimatedImageWatermarkIf(this Image img, bool condition, AnimatedImage wmImage, ImageWatermarkOptions ops) | ||
{ | ||
return condition ? ImageAnimatedImageWatermark.AddAnimatedImageWatermark(img, wmImage, ops) : new AnimatedImage(new[] { img }); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
LazZiya.ImageResize/Animated/ImageAnimatedTextWatermarkConditional.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Drawing; | ||
|
||
namespace LazZiya.ImageResize.Animated | ||
{ | ||
/// <summary> | ||
/// Add animated text watermark over image, depending on a conditional parameter. | ||
/// </summary> | ||
public static class ImageAnimatedTextWatermarkConditional | ||
{ | ||
/// <summary> | ||
/// Add animated text watermark over a static image, depending on a conditional parameter. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add animated text watermark, false will return the img as AnimatedImage</param> | ||
/// <param name="text"></param> | ||
public static AnimatedImage AddAnimatedTextWatermarkIf(this Image img, bool condition, string text) | ||
{ | ||
return condition ? ImageAnimatedTextWatermark.AddAnimatedTextWatermark(img, text) : new AnimatedImage(new[] { img }); | ||
} | ||
|
||
/// <summary> | ||
/// Add animated text watermark over a static image, depending on a conditional parameter. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add animated text watermark, false will return the img as AnimatedImage</param> | ||
/// <param name="text"></param> | ||
/// <param name="animOps"></param> | ||
public static AnimatedImage AddAnimatedTextWatermarkIf(this Image img, bool condition, string text, AnimatedTextWatermarkOptions animOps) | ||
{ | ||
return condition ? ImageAnimatedTextWatermark.AddAnimatedTextWatermark(img, text, animOps) : new AnimatedImage(new[] { img }); | ||
} | ||
|
||
/// <summary> | ||
/// Add animated text watermark over a static image, depending on a conditional parameter. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add animated text watermark, false will return the img as AnimatedImage</param> | ||
/// <param name="text">text to draw over the image</param> | ||
/// <param name="ops">Text watermark options <see cref="TextWatermarkOptions"/></param> | ||
public static AnimatedImage AddAnimatedTextWatermarkIf(this Image img, bool condition, string text, TextWatermarkOptions ops) | ||
{ | ||
return condition ? ImageAnimatedTextWatermark.AddAnimatedTextWatermark(img, text, ops) : new AnimatedImage(new[] { img }); | ||
} | ||
|
||
/// <summary> | ||
/// Add animated text watermark over a static image, depending on a conditional parameter. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add animated text watermark, false will return the img as AnimatedImage</param> | ||
/// <param name="text">text to draw over the image</param> | ||
/// <param name="ops">Text watermark options <see cref="TextWatermarkOptions"/></param> | ||
/// <param name="animOps">Animated text options <see cref="AnimatedTextWatermarkOptions"/></param> | ||
public static AnimatedImage AddAnimatedTextWatermarkIf(this Image img, bool condition, string text, TextWatermarkOptions ops, AnimatedTextWatermarkOptions animOps) | ||
{ | ||
return condition ? ImageAnimatedTextWatermark.AddAnimatedTextWatermark(img, text, ops, animOps) : new AnimatedImage(new[] { img }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using LazZiya.ImageResize.Tools; | ||
using System.Drawing; | ||
using System.Drawing.Drawing2D; | ||
|
||
namespace LazZiya.ImageResize | ||
{ | ||
/// <summary> | ||
/// Draw image watermark depending on a conditional parameter | ||
/// </summary> | ||
public static class ImageWatermarkConditional | ||
{ | ||
|
||
/// <summary> | ||
/// Draw image watermark if the condition is true, otherwise return without image watermark | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add image watermark, false will return the img</param> | ||
/// <param name="wmImgPath">Path to the watermark image file e.g. wwwroot\images\watermark.png</param> | ||
public static Image AddImageWatermarkIf(this Image img, bool condition, string wmImgPath) | ||
{ | ||
return condition ? ImageWatermark.AddImageWatermark(img, wmImgPath) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Draw image watermark if the condition is true, otherwise return without image watermark | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add image watermark, false will return the img</param> | ||
/// <param name="wmImage">Watermark image</param> | ||
public static Image AddImageWatermarkIf(this Image img, bool condition, Image wmImage) | ||
{ | ||
return condition ? ImageWatermark.AddImageWatermark(img, wmImage) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Draw image watermark if the condition is true, otherwise return without image watermark | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add image watermark, false will return the img</param> | ||
/// <param name="wmImgPath">Path to the watermark image file e.g. wwwroot\images\watermark.png</param> | ||
/// <param name="ops">Image watermark options <see cref="ImageWatermarkOptions"/></param> | ||
public static Image AddImageWatermarkIf(this Image img, bool condition, string wmImgPath, ImageWatermarkOptions ops) | ||
{ | ||
return condition ? ImageWatermark.AddImageWatermark(img, wmImgPath, ops) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Draw image watermark if the condition is true, otherwise return without image watermark | ||
/// <para>Notice regarding watermark opacity:</para> | ||
/// <para>If watermark image needs to be resized, first resize the watermark image, | ||
/// then save it to the disc, and read it again with Image.FromFile.</para> | ||
/// </summary> | ||
/// <param name="img">The original image</param> | ||
/// <param name="condition">true to add image watermark, false will return the img</param> | ||
/// <param name="wmImage">Watermak image</param> | ||
/// <param name="ops">Image watermark options <see cref="ImageWatermarkOptions"/></param> | ||
/// <param name="disposeWaterMark">Optional: dispose watermar image after finishing. Default: true</param> | ||
public static Image AddImageWatermarkIf(this Image img, bool condition, Image wmImage, ImageWatermarkOptions ops, bool disposeWaterMark = true) | ||
{ | ||
return condition ? ImageWatermark.AddImageWatermark(img, wmImage, ops, disposeWaterMark) : img; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Drawing; | ||
|
||
namespace LazZiya.ImageResize | ||
{ | ||
/// <summary> | ||
/// Add text watermark over the image depending on a conditional parameter. | ||
/// </summary> | ||
public static class TextWatermarkConditional | ||
{ | ||
|
||
/// <summary> | ||
/// Add a text watermark if the condition is true, otherwise return without textwatermark. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add text watermark, false will return the img</param> | ||
/// <param name="text"></param> | ||
public static Image AddTextWatermarkIf(this Image img, bool condition, string text) | ||
{ | ||
return condition ? TextWatermark.AddTextWatermark(img, text) : img; | ||
} | ||
|
||
/// <summary> | ||
/// Add a text watermark if the condition is true, otherwise return without textwatermark. | ||
/// </summary> | ||
/// <param name="img"></param> | ||
/// <param name="condition">true to add text watermark, false will return the img</param> | ||
/// <param name="text">text to draw over the image</param> | ||
/// <param name="ops">Text watermark options <see cref="TextWatermarkOptions"/></param> | ||
public static Image AddTextWatermarkIf(this Image img, bool condition, string text, TextWatermarkOptions ops) | ||
{ | ||
return condition ? TextWatermark.AddTextWatermark(img, text, ops) : img; | ||
} | ||
} | ||
} |