diff --git a/LazZiya.sln b/ImageResize.sln
similarity index 96%
rename from LazZiya.sln
rename to ImageResize.sln
index 0917ca7..37d7c08 100644
--- a/LazZiya.sln
+++ b/ImageResize.sln
@@ -15,12 +15,12 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Debug|x64.ActiveCfg = Debug|x64
- {23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Debug|x64.Build.0 = Debug|x64
+ {23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Debug|x64.Build.0 = Debug|Any CPU
{23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Release|Any CPU.Build.0 = Release|Any CPU
- {23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Release|x64.ActiveCfg = Release|x64
- {23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Release|x64.Build.0 = Release|x64
+ {23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Release|x64.ActiveCfg = Release|Any CPU
+ {23C49B9A-D554-4F5B-8201-5F5C69FF41C0}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/LazZiya.ImageResize/Exceptions/ImageResizeException.cs b/LazZiya.ImageResize/Exceptions/ImageResizeException.cs
index 5e87022..0c26997 100644
--- a/LazZiya.ImageResize/Exceptions/ImageResizeException.cs
+++ b/LazZiya.ImageResize/Exceptions/ImageResizeException.cs
@@ -7,6 +7,27 @@ namespace LazZiya.ImageResize.Exceptions
///
public class ImageResizeException : Exception
{
+ ///
+ /// Raise an image resize exeption
+ ///
+ public ImageResizeException()
+ {
+ }
+
+ ///
+ /// Raise an image resize exeption
+ ///
+ public ImageResizeException(string message) : base(message)
+ {
+ }
+
+ ///
+ /// Raise an image resize exeption
+ ///
+ public ImageResizeException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
///
/// Image resize result
///
diff --git a/LazZiya.ImageResize/ImageResize.cs b/LazZiya.ImageResize/ImageResize.cs
index ab085f5..4ad0162 100644
--- a/LazZiya.ImageResize/ImageResize.cs
+++ b/LazZiya.ImageResize/ImageResize.cs
@@ -10,7 +10,7 @@ namespace LazZiya.ImageResize
///
/// Resize images
///
- public abstract class ImageResize
+ public static class ImageResize
{
///
/// Auto scale image by width or height till longest border (width/height) is equal to new width/height.
@@ -97,7 +97,7 @@ public static Image Crop(Image img, int newWidth, int newHeight, TargetSpot spot
/// can be the whole image or part of it
/// The coordinates of the target image size
///
- public static Image Resize(Image img, Rectangle source, Rectangle target)
+ public static Image Resize(this Image img, Rectangle source, Rectangle target)
{
Bitmap outputImage = new Bitmap(target.Width, target.Height, img.PixelFormat);
@@ -105,15 +105,20 @@ public static Image Resize(Image img, Rectangle source, Rectangle target)
try
{
- Graphics graphics = Graphics.FromImage(outputImage);
+ using (var graphics = Graphics.FromImage(outputImage))
+ {
+ graphics.CompositingQuality = CompositingQuality.HighQuality;
+ graphics.SmoothingMode = SmoothingMode.HighQuality;
+ graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
+ graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
- graphics.DrawImage(
- img,
- target,
- source,
- GraphicsUnit.Pixel);
+ graphics.DrawImage(
+ img,
+ target,
+ source,
+ GraphicsUnit.Pixel);
- graphics.Dispose();
+ }
}
catch (Exception e)
{
@@ -124,7 +129,6 @@ public static Image Resize(Image img, Rectangle source, Rectangle target)
Value = e.Message
});
}
-
return outputImage;
}
}
diff --git a/LazZiya.ImageResize/ImageWatermark.cs b/LazZiya.ImageResize/ImageWatermark.cs
index a6af826..d5c68b1 100644
--- a/LazZiya.ImageResize/ImageWatermark.cs
+++ b/LazZiya.ImageResize/ImageWatermark.cs
@@ -5,16 +5,16 @@
namespace LazZiya.ImageResize
{
///
- ///
+ /// Draw image watermark
///
public static class ImageWatermark
{
///
- ///
+ /// Draw image watermark
///
- ///
- ///
+ /// The original image
+ /// Path to the watermark image file e.g. wwwroot\images\watermark.png
public static Image AddImageWatermark(this Image img, string wmImgPath)
{
var wm = Image.FromFile(wmImgPath);
@@ -22,21 +22,21 @@ public static Image AddImageWatermark(this Image img, string wmImgPath)
}
///
- ///
+ /// Draw image watermark
///
- ///
- ///
+ /// The original image
+ /// Watermark image
public static Image AddImageWatermark(this Image img, Image wmImage)
{
return img.AddImageWatermark(wmImage, new ImageWatermarkOptions());
}
///
- ///
+ /// Draw image watermark
///
- ///
- ///
- ///
+ /// The original image
+ /// Path to the watermark image file e.g. wwwroot\images\watermark.png
+ /// Image watermark options
public static Image AddImageWatermark(this Image img, string wmImgPath, ImageWatermarkOptions ops)
{
var wm = Image.FromFile(wmImgPath);
@@ -44,33 +44,31 @@ public static Image AddImageWatermark(this Image img, string wmImgPath, ImageWat
}
///
- /// Add image watermark
+ /// Draw image watermark
///
- /// The main image
- /// full path to the image that will be used as watermark
- /// Image watermark options
+ /// The original image
+ /// Watermak image
+ /// Image watermark options
public static Image AddImageWatermark(this Image img, Image wmImage, ImageWatermarkOptions ops)
{
if (ops.Opacity > 0)
{
- var graphics = Graphics.FromImage(img);
+ using (var graphics = Graphics.FromImage(img))
+ {
+ graphics.SmoothingMode = SmoothingMode.None;
+ graphics.CompositingMode = CompositingMode.SourceOver;
- graphics.SmoothingMode = SmoothingMode.None;
- graphics.CompositingMode = CompositingMode.SourceOver;
+ if (ops.Opacity < 100)
+ wmImage = ImageOpacity.ChangeImageOpacityMethod1(wmImage, ops.Opacity);
- if (ops.Opacity < 100)
- wmImage = ImageOpacity.ChangeImageOpacityMethod1(wmImage, ops.Opacity);
+ var wmW = wmImage.Width;
+ var wmH = wmImage.Height;
- var wmW = wmImage.Width;
- var wmH = wmImage.Height;
+ var drawingPoint = ImageWatermarkPosition.ImageWatermarkPos(img.Width, img.Height, wmW, wmH, ops.Location, ops.Margin);
- var drawingPoint = ImageWatermarkPosition.ImageWatermarkPos(img.Width, img.Height, wmW, wmH, ops.Location, ops.Margin);
-
- graphics.DrawImage(wmImage, drawingPoint.X, drawingPoint.Y, wmW, wmH);
-
- graphics.Dispose();
+ graphics.DrawImage(wmImage, drawingPoint.X, drawingPoint.Y, wmW, wmH);
+ }
}
-
return img;
}
}
diff --git a/LazZiya.ImageResize/ImageWatermarkOptions.cs b/LazZiya.ImageResize/ImageWatermarkOptions.cs
index 09d4e70..f70576a 100644
--- a/LazZiya.ImageResize/ImageWatermarkOptions.cs
+++ b/LazZiya.ImageResize/ImageWatermarkOptions.cs
@@ -3,24 +3,27 @@
namespace LazZiya.ImageResize
{
///
- /// Define options for adding text watermark over the image, like text color, opacity, text outline, etc.
+ /// Define options for adding image watermark over the image, like margin, opacity, and location.
///
public class ImageWatermarkOptions
{
///
- /// Margin in pixels. Depends on watermark location.
+ /// Margin in pixels. Depends on watermark location. default value 10
///
public int Margin { get; set; } = 10;
///
- /// The location to draw the image watermark. Choose from pre-defined 9 main locations (3 cols, 3 rows)
+ /// The location to draw the image watermark. Choose from pre-defined 9 main locations (3 cols, 3 rows).
+ /// Default value TargetSpot.TopRight.
+ /// See
///
- public TargetSpot Location { get; set; } = TargetSpot.BottomLeft;
+ public TargetSpot Location { get; set; } = TargetSpot.TopRight;
///
- /// Set opacity value of the image watermark
+ /// Set opacity value of the image watermark (0 - 100).
+ /// Default value 100 full color.
///
[Range(0, 100)]
- public int Opacity { get; set; }
+ public int Opacity { get; set; } = 100;
}
}
diff --git a/LazZiya.ImageResize/LazZiya.ImageResize.csproj b/LazZiya.ImageResize/LazZiya.ImageResize.csproj
index ee1d7dc..e9fa4db 100644
--- a/LazZiya.ImageResize/LazZiya.ImageResize.csproj
+++ b/LazZiya.ImageResize/LazZiya.ImageResize.csproj
@@ -5,38 +5,43 @@
Ziya Mollamahmut
Ziyad.info
true
- Simple tool for image resize, and add text over image for ASP.NET Core
+ Easily resize images, add text watermark with outline, add image watermark with transparency.
Ziyad.info
asp.net,core,.net,dotnet,image,resize,text,overlay
https://github.com/LazZiya/ImageResize
http://ziyad.info/en/articles/29-Image_Resize_for_dotNetCore
- AnyCPU;x64
- 3.0.0-preview1
+ 3.0.0-preview2
3.0.0.0
3.0.0.0
- image watermark with opacity settings
+
+ - .NetStandard 2.0 support
+ - New: TextOutline for text watermark
+ - New: AddTextWatermark methods
+ - New: AddImageWatermark methods
+ - Obsolete: TextWatermark, ImageWatermark extensions are obsolete and will be removed in a feature release
+ - Overall performance improvments
+
https://raw.githubusercontent.com/LazZiya/ImageResize/master/LazZiya.ImageResize/files/icon.png
+ icon.png
files\LazZiya.ImageResize.xml
+
+ LazZiya.ImageResize.xml
+
+
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
+
+
+
diff --git a/LazZiya.ImageResize/LazZiya.ImageResize.xml b/LazZiya.ImageResize/LazZiya.ImageResize.xml
new file mode 100644
index 0000000..6749ec8
--- /dev/null
+++ b/LazZiya.ImageResize/LazZiya.ImageResize.xml
@@ -0,0 +1,616 @@
+
+
+
+ LazZiya.ImageResize
+
+
+
+
+ Failure reasone type
+
+
+
+
+ not listed
+
+
+
+
+ Relevant encoder info not found
+
+
+
+
+ File extension is not supported
+
+
+
+
+ Image file format GUID is unknown
+
+
+
+
+ Zero size error
+
+
+
+
+ GDI+ related exceptin
+
+
+
+
+ Raise an image resize exeption
+
+
+
+
+ Raise an image resize exeption
+
+
+
+
+ Raise an image resize exeption
+
+
+
+
+ Raise an image resize exeption
+
+
+
+
+ Image resize result
+
+
+
+
+ Raise an image resize exeption
+
+
+
+
+ Image resize result object
+
+
+
+
+ Resize result status, true for success, false for failure
+
+
+
+
+ String message value
+
+
+
+
+ Specify failure reason
+
+
+
+
+ Resize images
+
+
+
+
+ Auto scale image by width or height till longest border (width/height) is equal to new width/height.
+ Final image aspect ratio is equal to original image aspect ratio.
+ If the aspect ratio of new w/h != aspect ratio of original image then
+ one border will be in different size than the given value in order to keep original aspect ratio
+
+
+
+
+
+
+
+
+ Scale image by width and keep same aspect ratio of target image same as the original image.
+ Height will be adjusted automatically
+
+
+
+
+
+
+
+ Scale image by height and keep same aspect ratio of target image same as the original image.
+ Width will be adjusted automatically
+
+
+
+
+
+
+
+ Scale target image till shortest border are equal to target value,
+ then crop the additonal pixels from the longest border.
+ Final image aspect ratio is equal to the given new width/height
+
+
+
+
+
+
+
+
+
+ Directly crop original image without scaling it.
+ Final image aspect ratio is equal to given new width/height
+
+
+
+
+ target spot to crop and save
+
+
+
+
+ Specify custom resize options
+
+ the image to resize
+ The coordinates to read as source from the image,
+ can be the whole image or part of it
+ The coordinates of the target image size
+
+
+
+
+ Draw image watermark
+
+
+
+
+ Draw image watermark
+
+ The original image
+ Path to the watermark image file e.g. wwwroot\images\watermark.png
+
+
+
+ Draw image watermark
+
+ The original image
+ Watermark image
+
+
+
+ Draw image watermark
+
+ The original image
+ Path to the watermark image file e.g. wwwroot\images\watermark.png
+ Image watermark options
+
+
+
+ Draw image watermark
+
+ The original image
+ Watermak image
+ Image watermark options
+
+
+
+ Define options for adding image watermark over the image, like margin, opacity, and location.
+
+
+
+
+ Margin in pixels. Depends on watermark location. default value 10
+
+
+
+
+ The location to draw the image watermark. Choose from pre-defined 9 main locations (3 cols, 3 rows).
+ Default value TargetSpot.TopRight.
+ See
+
+
+
+
+ Set opacity value of the image watermark (0 - 100).
+ Default value 100 full color.
+
+
+
+
+ Defines the image resize / crop method
+
+
+
+
+ The rectangle info to read from the source image, the whole image size by default
+
+
+
+
+ The target image size
+
+
+
+
+ The origin point to start reading from the source image
+
+
+
+
+ The origin point to start writing the target image
+
+
+
+
+ Source image size
+
+
+
+
+ Target image size
+
+
+
+
+ Crop an image according to the specified values
+
+ The source image size
+ The target image size
+ The pre-defined spot of the source image to read and crop.
+
+
+
+
+ Common properties for image resize methods
+
+
+
+
+ The source image size and position
+
+
+
+
+ The target image size and position
+
+
+
+
+ scale image size down till both width and height are in the target image size
+ keep target image aspect ratio = original image aspect ratio
+
+
+
+
+ The source reading rectangle from the source image
+
+
+
+
+ the target image size and position
+
+
+
+
+ Scale an image as per given size and keep aspect ratio.
+ The final result of the scale may have different width or hight
+
+
+
+
+
+
+ Get the height of the scaled image according to its given width
+
+ The source image size
+ The desired image width
+ Size result of the scaling calculation
+
+
+
+ Get the width of the scaled image according to its given height
+
+ The source image size
+ The desired image height
+ Size result of the scaling calculation
+
+
+
+ Get new sizes of the image to resize,
+ The scale calculation will fit the new size till both width and height are contianed,
+ So the final image is not cropped and completely fits in the new size.
+
+
+
+
+
+
+
+ scale down image size till one of width or height are equal to target image size
+ extra pixels will be cropped out
+ target image aspect ratio is equal to defined new size aspect ratio
+
+
+
+
+ The source reading rectangle from the source image
+
+
+
+
+ the target image size and position
+
+
+
+
+ Scale and crop the image,
+ If the final width or heghit is out of the target area it will be cropped out.
+
+ Source image size
+ Target image size
+ The target spot to read from the source image. See
+
+
+
+ define the max rect size and pos to read from source image
+
+
+
+
+ calculate the source origin point from image
+
+
+
+
+ Save the image file to disc
+
+
+
+
+ Save the image to the specified path then dispose the Image object.
+
+ Image to save
+ Full path including file name and extension to save the image to
+
+
+
+ Use target spot to specify the reading sport of the source image,
+ if the cropped image is larger than the new image size
+ then select the spot to crop.
+ The TargetSpot pre-defines 9 main spots in the image, 3 columns and 3 rows.
+ it helps easily select which area to read from the image for resize and crop.
+
+
+
+
+ Takes the top left area of the image
+
+
+
+
+ Takes the top middle area of the image
+
+
+
+
+ Takes the top right area
+
+
+
+
+ Takes the middle left area
+
+
+
+
+ Takes the center area of the image
+
+
+
+
+ Takes the middle right area of the image
+
+
+
+
+ Takes the bottom left area of the image
+
+
+
+
+ Takes the bottom middle area of the image
+
+
+
+
+ Takes the bottom left area of the image
+
+
+
+
+ Add text watermark over the image.
+
+
+
+
+ Add text watermark over the image.
+
+
+
+
+
+
+ Add text watermark over the image.
+
+
+ text to draw over the image
+ Text watermark options
+
+
+
+ Define options for adding text watermark over the image, like text color, opacity, text outline, etc.
+
+
+
+
+ Value for the text color. Use alpha channel to specify transparency (0 - 255).
+ Set alpha to 0 to remove text color.
+ Default value Color.FromArgb(255, Color.White) full color.
+ See
+
+
+
+
+ Font size in pixel.
+ Default value 24
+
+
+
+
+ Font style. Default value FontStyle.Regular.
+ See
+
+
+
+
+ Font family. Default value "Arial"
+
+
+
+
+ Value for the text background color. Use alpha channel to specify transparency (0 - 255).
+ Set alpha to 0 to remove background.
+ Default value Color.FromArgb(0, Color.White) no background.
+ See
+
+
+
+
+ Top/Bottom margin in pixels. Depends on watermark horizontal alignment.
+ Default value 10
+
+
+
+
+ The location to draw the text watermark. Choose from pre-defined 9 main locations (3 cols, 3 rows).
+ Default value TargetSpot.BottomLeft.
+ See
+
+
+
+
+ Value for the text outline color. Use alpha channel to specify transparency (0 - 255).
+ Set alpha to 0 to remove outline.
+ Default value Color.FromArgb(255, Color.Black)
+ See
+
+
+
+
+ Text outline width in pixels. Default value 3.5f
+
+
+
+
+ Image extension methods to get encoder info
+
+
+
+
+ Get image codec information for the given extension.
+
+ extension of the image file
+
+
+
+
+ Available image formats and GUID values
+
+
+
+
+ return image format by comparing the ImageFormat.Guid param
+
+
+ System.Drawing.Imaging.ImageFormat
+
+
+
+ return image format by reading file extension
+
+
+ System.Drawing.Imaging.ImageFormat
+
+
+
+ Change image opacity
+
+
+
+
+ Change the opacity of an image, this method loops through all image pixels and changes the opacity
+
+ The original image
+ Opacity, where 100 is no opacity, 00 is full transparency, 100 full color
+ The changed image
+
+
+
+ method for changing the opacity of an image, this method uses ImageAttributes matrix to change the opacity.
+
+ image to set opacity on
+ opacity 0 full transparent, 100 no opacity
+
+
+
+
+ Calculate the watermark text background size and position according to the taret spot,
+ main image size and font size.
+
+ Main image width
+ Main image height
+ Font size
+ target spot
+ Distance from the nearest border
+
+
+
+
+ Add image watermark over another image
+
+
+ Add a text watermark over the main image
+
+
+
+
+ Add image watermark over another image.
+
+ The main image
+ full path to the image that will be used as watermark
+ The taret spot on the main image to draw the watermark over. See
+ The distance of the watermark image in pixels from the nearest border.
+ The opacity of the watermark image (0 - 100)
+
+
+
+ Add a text watermark over the main image
+
+ The main image
+ The text to add as watermark
+ The color of the text.
+ use 8 digit hex code to specify alpha channed as well.
+ sample: #77FFFFFF (77 is the alpha channed (00 - FF)
+
+ The color of the text background.
+ use 8 digit hex code to specify alpha channed as well.
+ sample: #77FFFFFF (77 is the alpha channed (00 - FF)
+ Font family name
+ Text size
+ Target spot to draw the watermark text over the main image.
+ See
+ Font style
+ The distance in pixels between the watermark text and the nearest border of the main image.
+
+
+
diff --git a/LazZiya.ImageResize/SaveImage.cs b/LazZiya.ImageResize/SaveImage.cs
index cf18158..01d5eff 100644
--- a/LazZiya.ImageResize/SaveImage.cs
+++ b/LazZiya.ImageResize/SaveImage.cs
@@ -4,10 +4,13 @@
namespace LazZiya.ImageResize
{
+ ///
+ /// Save the image file to disc
+ ///
public static class SaveImage
{
///
- /// Save the image to the specified path
+ /// Save the image to the specified path then dispose the Image object.
///
/// Image to save
/// Full path including file name and extension to save the image to
@@ -15,19 +18,22 @@ public static void SaveAs(this Image img, string path)
{
ImageCodecInfo myImageCodecInfo;
Encoder myEncoder;
- EncoderParameter myEncoderParameter;
- EncoderParameters myEncoderParameters;
var dotIndex = path.LastIndexOf('.');
var ext = path.Substring(dotIndex, path.Length - dotIndex - 1);
myImageCodecInfo = EncoderInfo.GetEncoderInfo(ext);
myEncoder = Encoder.Quality;
- myEncoderParameters = new EncoderParameters(1);
- myEncoderParameter = new EncoderParameter(myEncoder, 100L);
- myEncoderParameters.Param[0] = myEncoderParameter;
- img.Save(path, myImageCodecInfo, myEncoderParameters);
+ using (var myEncoderParameters = new EncoderParameters(1))
+ {
+ using (var myEncoderParameter = new EncoderParameter(myEncoder, 100L))
+ {
+ myEncoderParameters.Param[0] = myEncoderParameter;
+ img.Save(path, myImageCodecInfo, myEncoderParameters);
+ img.Dispose();
+ }
+ }
}
}
}
diff --git a/LazZiya.ImageResize/TextWatermark.cs b/LazZiya.ImageResize/TextWatermark.cs
index 2067559..492efc2 100644
--- a/LazZiya.ImageResize/TextWatermark.cs
+++ b/LazZiya.ImageResize/TextWatermark.cs
@@ -7,6 +7,9 @@
namespace LazZiya.ImageResize
{
+ ///
+ /// Add text watermark over the image.
+ ///
public static class TextWatermark
{
@@ -24,8 +27,8 @@ public static Image AddTextWatermark(this Image img, string text)
/// Add text watermark over the image.
///
///
- ///
- ///
+ /// text to draw over the image
+ /// Text watermark options
public static Image AddTextWatermark(this Image img, string text, TextWatermarkOptions ops)
{
using (var graphics = Graphics.FromImage(img))
diff --git a/LazZiya.ImageResize/TextWatermarkOptions.cs b/LazZiya.ImageResize/TextWatermarkOptions.cs
index 43d9873..6541c2f 100644
--- a/LazZiya.ImageResize/TextWatermarkOptions.cs
+++ b/LazZiya.ImageResize/TextWatermarkOptions.cs
@@ -8,49 +8,61 @@ namespace LazZiya.ImageResize
public class TextWatermarkOptions
{
///
- /// Value for the text color. Use alpha channel to specify transparency
+ /// Value for the text color. Use alpha channel to specify transparency (0 - 255).
+ /// Set alpha to 0 to remove text color.
+ /// Default value Color.FromArgb(255, Color.White) full color.
+ /// See
///
- public Color TextColor { get; set; } = Color.FromArgb(150, Color.White);
+ public Color TextColor { get; set; } = Color.FromArgb(255, Color.White);
///
- /// Font size in pixel
+ /// Font size in pixel.
+ /// Default value 24
///
public int FontSize { get; set; } = 24;
///
- /// Font style
+ /// Font style. Default value FontStyle.Regular.
+ /// See
///
public FontStyle FontStyle { get; set; } = FontStyle.Regular;
///
- /// Font family
+ /// Font family. Default value "Arial"
///
public string FontName { get; set; } = "Arial";
///
- /// Value for the text background color. Use alpha channel to specify transparency
- /// Set transparency to 0 to remove background.
+ /// Value for the text background color. Use alpha channel to specify transparency (0 - 255).
+ /// Set alpha to 0 to remove background.
+ /// Default value Color.FromArgb(0, Color.White) no background.
+ /// See
///
public Color BGColor { get; set; } = Color.FromArgb(0, Color.White);
///
/// Top/Bottom margin in pixels. Depends on watermark horizontal alignment.
+ /// Default value 10
///
public int Margin { get; set; } = 10;
///
- /// The location to draw the text watermark. Choose from pre-defined 9 main locations (3 cols, 3 rows)
+ /// The location to draw the text watermark. Choose from pre-defined 9 main locations (3 cols, 3 rows).
+ /// Default value TargetSpot.BottomLeft.
+ /// See
///
public TargetSpot Location { get; set; } = TargetSpot.BottomLeft;
///
- /// Value for the text outline color. Use alpha channel to specify transparency.
- /// Set transparency to 0 to remove outline.
+ /// Value for the text outline color. Use alpha channel to specify transparency (0 - 255).
+ /// Set alpha to 0 to remove outline.
+ /// Default value Color.FromArgb(255, Color.Black)
+ /// See
///
- public Color OutlineColor { get; set; } = Color.FromArgb(200, Color.Black);
+ public Color OutlineColor { get; set; } = Color.FromArgb(255, Color.Black);
///
- /// Text outline width in pixels
+ /// Text outline width in pixels. Default value 3.5f
///
public float OutlineWidth { get; set; } = 3.5f;
}
diff --git a/LazZiya.ImageResize/Tools/EncoderInfo.cs b/LazZiya.ImageResize/Tools/EncoderInfo.cs
index c523362..0201d3b 100644
--- a/LazZiya.ImageResize/Tools/EncoderInfo.cs
+++ b/LazZiya.ImageResize/Tools/EncoderInfo.cs
@@ -5,7 +5,7 @@
namespace LazZiya.ImageResize.Tools
{
///
- /// Image extnsion methods to get encoder info
+ /// Image extension methods to get encoder info
///
public abstract class EncoderInfo
{
diff --git a/LazZiya.ImageResize/Tools/ImageOpacity.cs b/LazZiya.ImageResize/Tools/ImageOpacity.cs
index c84ba7e..fc5a7b6 100644
--- a/LazZiya.ImageResize/Tools/ImageOpacity.cs
+++ b/LazZiya.ImageResize/Tools/ImageOpacity.cs
@@ -15,7 +15,7 @@ public abstract class ImageOpacity
/// Change the opacity of an image, this method loops through all image pixels and changes the opacity
///
/// The original image
- /// Opacity, where 100 is no opacity, 00 is full transparency
+ /// Opacity, where 100 is no opacity, 00 is full transparency, 100 full color
/// The changed image
public static Image ChangeImageOpacityMethod1(Image originalImage, int opacity)
{
diff --git a/LazZiya.ImageResize/Tools/ImageWatermark.cs b/LazZiya.ImageResize/Watermark/ImageWatermark.cs
similarity index 95%
rename from LazZiya.ImageResize/Tools/ImageWatermark.cs
rename to LazZiya.ImageResize/Watermark/ImageWatermark.cs
index 84e165c..7c9f8d6 100644
--- a/LazZiya.ImageResize/Tools/ImageWatermark.cs
+++ b/LazZiya.ImageResize/Watermark/ImageWatermark.cs
@@ -1,8 +1,9 @@
-using System;
+using LazZiya.ImageResize.Tools;
+using System;
using System.Drawing;
using System.Drawing.Drawing2D;
-namespace LazZiya.ImageResize.Tools
+namespace LazZiya.ImageResize.Watermark
{
///
/// Add image watermark over another image
diff --git a/LazZiya.ImageResize/Tools/TextWatermark.cs b/LazZiya.ImageResize/Watermark/TextWatermark.cs
similarity index 97%
rename from LazZiya.ImageResize/Tools/TextWatermark.cs
rename to LazZiya.ImageResize/Watermark/TextWatermark.cs
index 43a1f26..d6bc882 100644
--- a/LazZiya.ImageResize/Tools/TextWatermark.cs
+++ b/LazZiya.ImageResize/Watermark/TextWatermark.cs
@@ -1,10 +1,11 @@
-using System;
+using LazZiya.ImageResize.Tools;
+using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Globalization;
-namespace LazZiya.ImageResize.Tools
+namespace LazZiya.ImageResize.Watermark
{
///
/// Add a text watermark over the main image
diff --git a/LazZiya.ImageResize/files/LazZiya.ImageResize.xml b/LazZiya.ImageResize/files/LazZiya.ImageResize.xml
index b23ca7e..6749ec8 100644
--- a/LazZiya.ImageResize/files/LazZiya.ImageResize.xml
+++ b/LazZiya.ImageResize/files/LazZiya.ImageResize.xml
@@ -44,6 +44,21 @@
Raise an image resize exeption
+
+
+ Raise an image resize exeption
+
+
+
+
+ Raise an image resize exeption
+
+
+
+
+ Raise an image resize exeption
+
+
Image resize result
@@ -144,57 +159,60 @@
-
+ Draw image watermark
-
+ Draw image watermark
-
-
+ The original image
+ Path to the watermark image file e.g. wwwroot\images\watermark.png
-
+ Draw image watermark
-
-
+ The original image
+ Watermark image
-
+ Draw image watermark
-
-
-
+ The original image
+ Path to the watermark image file e.g. wwwroot\images\watermark.png
+ Image watermark options
- Add image watermark
+ Draw image watermark
- The main image
- full path to the image that will be used as watermark
- Image watermark options
+ The original image
+ Watermak image
+ Image watermark options
- Define options for adding text watermark over the image, like text color, opacity, text outline, etc.
+ Define options for adding image watermark over the image, like margin, opacity, and location.
- Margin in pixels. Depends on watermark location.
+ Margin in pixels. Depends on watermark location. default value 10
- The location to draw the image watermark. Choose from pre-defined 9 main locations (3 cols, 3 rows)
+ The location to draw the image watermark. Choose from pre-defined 9 main locations (3 cols, 3 rows).
+ Default value TargetSpot.TopRight.
+ See
- Set opacity value of the image watermark
+ Set opacity value of the image watermark (0 - 100).
+ Default value 100 full color.
@@ -342,9 +360,14 @@
calculate the source origin point from image
+
+
+ Save the image file to disc
+
+
- Save the image to the specified path
+ Save the image to the specified path then dispose the Image object.
Image to save
Full path including file name and extension to save the image to
@@ -403,6 +426,11 @@
Takes the bottom left area of the image
+
+
+ Add text watermark over the image.
+
+
Add text watermark over the image.
@@ -415,8 +443,8 @@
Add text watermark over the image.
-
-
+ text to draw over the image
+ Text watermark options
@@ -425,54 +453,66 @@
- Value for the text color. Use alpha channel to specify transparency
+ Value for the text color. Use alpha channel to specify transparency (0 - 255).
+ Set alpha to 0 to remove text color.
+ Default value Color.FromArgb(255, Color.White) full color.
+ See
- Font size in pixel
+ Font size in pixel.
+ Default value 24
- Font style
+ Font style. Default value FontStyle.Regular.
+ See
- Font family
+ Font family. Default value "Arial"
- Value for the text background color. Use alpha channel to specify transparency
- Set transparency to 0 to remove background.
+ Value for the text background color. Use alpha channel to specify transparency (0 - 255).
+ Set alpha to 0 to remove background.
+ Default value Color.FromArgb(0, Color.White) no background.
+ See
Top/Bottom margin in pixels. Depends on watermark horizontal alignment.
+ Default value 10
- The location to draw the text watermark. Choose from pre-defined 9 main locations (3 cols, 3 rows)
+ The location to draw the text watermark. Choose from pre-defined 9 main locations (3 cols, 3 rows).
+ Default value TargetSpot.BottomLeft.
+ See
- Value for the text outline color. Use alpha channel to specify transparency.
- Set transparency to 0 to remove outline.
+ Value for the text outline color. Use alpha channel to specify transparency (0 - 255).
+ Set alpha to 0 to remove outline.
+ Default value Color.FromArgb(255, Color.Black)
+ See
- Text outline width in pixels
+ Text outline width in pixels. Default value 3.5f
- Image extnsion methods to get encoder info
+ Image extension methods to get encoder info
@@ -511,7 +551,7 @@
Change the opacity of an image, this method loops through all image pixels and changes the opacity
The original image
- Opacity, where 100 is no opacity, 00 is full transparency
+ Opacity, where 100 is no opacity, 00 is full transparency, 100 full color
The changed image
@@ -522,7 +562,19 @@
opacity 0 full transparent, 100 no opacity
-
+
+
+ Calculate the watermark text background size and position according to the taret spot,
+ main image size and font size.
+
+ Main image width
+ Main image height
+ Font size
+ target spot
+ Distance from the nearest border
+
+
+
Add image watermark over another image
@@ -530,7 +582,7 @@
Add a text watermark over the main image
-
+
Add image watermark over another image.
@@ -540,7 +592,7 @@
The distance of the watermark image in pixels from the nearest border.
The opacity of the watermark image (0 - 100)
-
+
Add a text watermark over the main image
@@ -560,17 +612,5 @@
Font style
The distance in pixels between the watermark text and the nearest border of the main image.
-
-
- Calculate the watermark text background size and position according to the taret spot,
- main image size and font size.
-
- Main image width
- Main image height
- Font size
- target spot
- Distance from the nearest border
-
-