diff --git a/LazZiya.ImageResize/Animated/AnimatedGif.cs b/LazZiya.ImageResize/Animated/AnimatedImage.cs
similarity index 71%
rename from LazZiya.ImageResize/Animated/AnimatedGif.cs
rename to LazZiya.ImageResize/Animated/AnimatedImage.cs
index 3e0f2d9..f4ece4b 100644
--- a/LazZiya.ImageResize/Animated/AnimatedGif.cs
+++ b/LazZiya.ImageResize/Animated/AnimatedImage.cs
@@ -9,9 +9,9 @@
namespace LazZiya.ImageResize.Animated
{
///
- /// Represents an animated gif image with multiple frames
+ /// Represents an animated image image with multiple frames
///
- public class AnimatedGif : IDisposable
+ public class AnimatedImage : IDisposable
{
///
/// Gif image as list of frames
@@ -59,72 +59,86 @@ public class AnimatedGif : IDisposable
public ImageFormat RawFormat { get; }
///
- /// Create an animated gif from file
+ /// private constructor
///
- ///
- public AnimatedGif(string filePath)
- : this(Image.FromFile(filePath))
+ private AnimatedImage(Image image)
{
-
+ if (!ImageAnimator.CanAnimate(image))
+ throw new BadImageFormatException("This is not an animated gif!");
+
+ var dim = new FrameDimension(image.FrameDimensionsList[0]);
+ FramesCount = image.GetFrameCount(dim);
+ Size = new Size(image.Width, image.Height);
+ Frames = new List();
+ ImageColorFormat = ImageColorFormats.GetColorFormat((Bitmap)image);
+ PixelFormat = image.PixelFormat;
+ HorizontalResolution = image.HorizontalResolution;
+ VerticalResolution = image.VerticalResolution;
+ RawFormat = image.RawFormat;
+
+ for (int i = 0; i < FramesCount; i++)
+ {
+ image.SelectActiveFrame(dim, i);
+ var frame = image.Clone() as Image;
+ Frames.Add(frame);
+ }
+
+ image.Dispose();
}
///
- /// Create an animated gif from a stream
+ /// Create animated image from file
///
- ///
- public AnimatedGif(Stream stream)
- :this(Image.FromStream(stream))
+ ///
+ ///
+ public static AnimatedImage FromFile(string fileName)
{
-
+ var img = Image.FromFile(fileName);
+ return new AnimatedImage(img);
}
///
- /// Create an animated gif from HBitmap
+ /// Create animated image from stream
///
- ///
- public AnimatedGif(IntPtr hbitmap)
- : this(Image.FromHbitmap(hbitmap))
+ ///
+ ///
+ public static AnimatedImage FromStream(Stream stream)
{
+ var img = Image.FromStream(stream);
+ return new AnimatedImage(img);
+ }
+ ///
+ /// Create animated image from image
+ ///
+ ///
+ ///
+ public static AnimatedImage FromImage(Image image)
+ {
+ return new AnimatedImage(image);
}
///
- /// Create an animated gif from HBitmap
+ /// Create animated image from bitmap
///
///
- ///
- public AnimatedGif(IntPtr hbitmap, IntPtr hplatte)
- : this(Image.FromHbitmap(hbitmap, hplatte))
+ ///
+ public static AnimatedImage FromHBitmap(IntPtr hbitmap)
{
-
+ var img = Image.FromHbitmap(hbitmap);
+ return new AnimatedImage(img);
}
///
- /// Create animated gif from Image file
+ /// Create animated image from bitmap
///
- ///
- public AnimatedGif(Image image)
+ ///
+ ///
+ ///
+ public static AnimatedImage FromHBitmap(IntPtr hbitmap, IntPtr hpalatte)
{
- if (!ImageAnimator.CanAnimate(image))
- throw new BadImageFormatException("This is not an animated gif!");
-
- var dim = new FrameDimension(image.FrameDimensionsList[0]);
- FramesCount = image.GetFrameCount(dim);
- Size = new Size(image.Width, image.Height);
- Frames = new List();
-
- ImageColorFormat = ImageColorFormats.GetColorFormat((Bitmap)image);
- PixelFormat = image.PixelFormat;
- HorizontalResolution = image.HorizontalResolution;
- VerticalResolution = image.VerticalResolution;
- RawFormat = image.RawFormat;
-
- for (int i = 0; i < FramesCount; i++)
- {
- image.SelectActiveFrame(dim, i);
- var frame = image.Clone() as Image;
- Frames.Add(frame);
- }
+ var img = Image.FromHbitmap(hbitmap, hpalatte);
+ return new AnimatedImage(img);
}
///
@@ -157,7 +171,7 @@ public void Dispose()
///
/// deconstruct
///
- ~AnimatedGif()
+ ~AnimatedImage()
{
this.Dispose();
}
diff --git a/LazZiya.ImageResize/Animated/AnimatedGifWaterMark.cs b/LazZiya.ImageResize/Animated/AnimatedImageImageWatermark.cs
similarity index 82%
rename from LazZiya.ImageResize/Animated/AnimatedGifWaterMark.cs
rename to LazZiya.ImageResize/Animated/AnimatedImageImageWatermark.cs
index 3fbe6ac..3a269d0 100644
--- a/LazZiya.ImageResize/Animated/AnimatedGifWaterMark.cs
+++ b/LazZiya.ImageResize/Animated/AnimatedImageImageWatermark.cs
@@ -6,14 +6,14 @@ namespace LazZiya.ImageResize.Animated
///
/// Add an image watermark to animated gif
///
- public static class AnimatedGifWaterMark
+ public static class AnimatedImageImageWatermark
{
///
/// Draw image watermark
///
/// The original image
/// Path to the watermark image file e.g. wwwroot\images\watermark.png
- public static AnimatedGif AddImageWatermark(this AnimatedGif img, string wmImgPath)
+ public static AnimatedImage AddImageWatermark(this AnimatedImage img, string wmImgPath)
{
var wm = Image.FromFile(wmImgPath);
return img.AddImageWatermark(wm, new ImageWatermarkOptions());
@@ -24,7 +24,7 @@ public static AnimatedGif AddImageWatermark(this AnimatedGif img, string wmImgPa
///
/// The original image
/// Watermark image
- public static AnimatedGif AddImageWatermark(this AnimatedGif img, Image wmImage)
+ public static AnimatedImage AddImageWatermark(this AnimatedImage img, Image wmImage)
{
return img.AddImageWatermark(wmImage, new ImageWatermarkOptions());
}
@@ -35,7 +35,7 @@ public static AnimatedGif AddImageWatermark(this AnimatedGif img, Image wmImage)
/// The original image
/// Path to the watermark image file e.g. wwwroot\images\watermark.png
/// Image watermark options
- public static AnimatedGif AddImageWatermark(this AnimatedGif img, string wmImgPath, ImageWatermarkOptions ops)
+ public static AnimatedImage AddImageWatermark(this AnimatedImage img, string wmImgPath, ImageWatermarkOptions ops)
{
var wm = Image.FromFile(wmImgPath);
return img.AddImageWatermark(wm, ops);
@@ -50,7 +50,7 @@ public static AnimatedGif AddImageWatermark(this AnimatedGif img, string wmImgPa
/// The original image
/// Watermak image
/// Image watermark options
- public static AnimatedGif AddImageWatermark(this AnimatedGif img, Image wmImage, ImageWatermarkOptions ops)
+ public static AnimatedImage AddImageWatermark(this AnimatedImage img, Image wmImage, ImageWatermarkOptions ops)
{
var fList = new List();
diff --git a/LazZiya.ImageResize/Animated/AnimatedGifResize.cs b/LazZiya.ImageResize/Animated/AnimatedImageResize.cs
similarity index 86%
rename from LazZiya.ImageResize/Animated/AnimatedGifResize.cs
rename to LazZiya.ImageResize/Animated/AnimatedImageResize.cs
index 537eb6a..b9cc84f 100644
--- a/LazZiya.ImageResize/Animated/AnimatedGifResize.cs
+++ b/LazZiya.ImageResize/Animated/AnimatedImageResize.cs
@@ -1,7 +1,5 @@
using LazZiya.ImageResize.ColorFormats;
using LazZiya.ImageResize.ResizeMethods;
-using LazZiya.ImageResize.Tools;
-using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
@@ -12,7 +10,7 @@ namespace LazZiya.ImageResize.Animated
///
/// Resize images
///
- public static class AnimatedGifResize
+ public static class AnimatedImageResize
{
///
/// Auto scale image by width or height till longest border (width/height) is equal to new width/height.
@@ -24,7 +22,7 @@ public static class AnimatedGifResize
///
///
///
- public static AnimatedGif Scale(this AnimatedGif img, int newWidth, int newHeight)
+ public static AnimatedImage Scale(this AnimatedImage img, int newWidth, int newHeight)
{
var resize = new Scale(img.Size, new Size(newWidth, newHeight));
@@ -42,7 +40,7 @@ public static AnimatedGif Scale(this AnimatedGif img, int newWidth, int newHeigh
///
/// Graphic options
///
- public static AnimatedGif Scale(this AnimatedGif img, int newWidth, int newHeight, GraphicOptions ops)
+ public static AnimatedImage Scale(this AnimatedImage img, int newWidth, int newHeight, GraphicOptions ops)
{
var resize = new Scale(img.Size, new Size(newWidth, newHeight));
@@ -56,7 +54,7 @@ public static AnimatedGif Scale(this AnimatedGif img, int newWidth, int newHeigh
///
///
///
- public static AnimatedGif ScaleByWidth(this AnimatedGif img, int newWidth)
+ public static AnimatedImage ScaleByWidth(this AnimatedImage img, int newWidth)
{
var resize = new Scale(img.Size, new Size(newWidth, 0));
@@ -71,7 +69,7 @@ public static AnimatedGif ScaleByWidth(this AnimatedGif img, int newWidth)
///
/// Graphic options
///
- public static AnimatedGif GifScaleByWidth(this AnimatedGif img, int newWidth, GraphicOptions ops)
+ public static AnimatedImage GifScaleByWidth(this AnimatedImage img, int newWidth, GraphicOptions ops)
{
var resize = new Scale(img.Size, new Size(newWidth, 0));
@@ -85,7 +83,7 @@ public static AnimatedGif GifScaleByWidth(this AnimatedGif img, int newWidth, Gr
///
///
///
- public static AnimatedGif ScaleByHeight(this AnimatedGif img, int newHeight)
+ public static AnimatedImage ScaleByHeight(this AnimatedImage img, int newHeight)
{
var resize = new Scale(img.Size, new Size(0, newHeight));
@@ -100,7 +98,7 @@ public static AnimatedGif ScaleByHeight(this AnimatedGif img, int newHeight)
///
/// Graphic options
///
- public static AnimatedGif ScaleByHeight(this AnimatedGif img, int newHeight, GraphicOptions ops)
+ public static AnimatedImage ScaleByHeight(this AnimatedImage img, int newHeight, GraphicOptions ops)
{
var resize = new Scale(img.Size, new Size(0, newHeight));
@@ -117,7 +115,7 @@ public static AnimatedGif ScaleByHeight(this AnimatedGif img, int newHeight, Gra
///
///
///
- public static AnimatedGif ScaleAndCrop(this AnimatedGif img, int newWidth, int newHeight, TargetSpot spot = TargetSpot.Center)
+ public static AnimatedImage ScaleAndCrop(this AnimatedImage img, int newWidth, int newHeight, TargetSpot spot = TargetSpot.Center)
{
var resize = new ScaleAndCrop(img.Size, new Size(newWidth, newHeight), spot);
@@ -135,7 +133,7 @@ public static AnimatedGif ScaleAndCrop(this AnimatedGif img, int newWidth, int n
///
/// Graphic options
///
- public static AnimatedGif ScaleAndCrop(this AnimatedGif img, int newWidth, int newHeight, GraphicOptions ops, TargetSpot spot = TargetSpot.Center)
+ public static AnimatedImage ScaleAndCrop(this AnimatedImage img, int newWidth, int newHeight, GraphicOptions ops, TargetSpot spot = TargetSpot.Center)
{
var resize = new ScaleAndCrop(img.Size, new Size(newWidth, newHeight), spot);
@@ -151,7 +149,7 @@ public static AnimatedGif ScaleAndCrop(this AnimatedGif img, int newWidth, int n
///
/// target spot to crop and save
///
- public static AnimatedGif Crop(this AnimatedGif img, int newWidth, int newHeight, TargetSpot spot = TargetSpot.Center)
+ public static AnimatedImage Crop(this AnimatedImage img, int newWidth, int newHeight, TargetSpot spot = TargetSpot.Center)
{
var resize = new Crop(img.Size, new Size(newWidth, newHeight), spot);
return Resize(img, resize.SourceRect, resize.TargetRect);
@@ -167,7 +165,7 @@ public static AnimatedGif Crop(this AnimatedGif img, int newWidth, int newHeight
/// target spot to crop and save
/// Graphic options
///
- public static AnimatedGif Crop(this AnimatedGif img, int newWidth, int newHeight, GraphicOptions ops, TargetSpot spot = TargetSpot.Center)
+ public static AnimatedImage Crop(this AnimatedImage img, int newWidth, int newHeight, GraphicOptions ops, TargetSpot spot = TargetSpot.Center)
{
var resize = new Crop(img.Size, new Size(newWidth, newHeight), spot);
return Resize(img, resize.SourceRect, resize.TargetRect, ops);
@@ -181,7 +179,7 @@ public static AnimatedGif Crop(this AnimatedGif img, int newWidth, int newHeight
/// can be the whole image or part of it
/// The coordinates of the target image size
///
- public static AnimatedGif Resize(this AnimatedGif img, Rectangle source, Rectangle target)
+ public static AnimatedImage Resize(this AnimatedImage img, Rectangle source, Rectangle target)
{
return img.Resize(source, target, new GraphicOptions());
}
@@ -195,7 +193,7 @@ public static AnimatedGif Resize(this AnimatedGif img, Rectangle source, Rectang
/// The coordinates of the target image size
/// Graphic options
///
- public static AnimatedGif Resize(this AnimatedGif img, Rectangle source, Rectangle target, GraphicOptions ops)
+ public static AnimatedImage Resize(this AnimatedImage img, Rectangle source, Rectangle target, GraphicOptions ops)
{
// check for CMYK pixel format to use Format32bppArgb
// or use the image pixel format
diff --git a/LazZiya.ImageResize/Animated/AnimatedTextWatermark.cs b/LazZiya.ImageResize/Animated/AnimatedImageTextWatermark.cs
similarity index 80%
rename from LazZiya.ImageResize/Animated/AnimatedTextWatermark.cs
rename to LazZiya.ImageResize/Animated/AnimatedImageTextWatermark.cs
index d0720cc..3f2735d 100644
--- a/LazZiya.ImageResize/Animated/AnimatedTextWatermark.cs
+++ b/LazZiya.ImageResize/Animated/AnimatedImageTextWatermark.cs
@@ -7,7 +7,7 @@ namespace LazZiya.ImageResize
///
/// Add text watermark over the image.
///
- public static class AnimatedTextWatermark
+ public static class AnimatedImageTextWatermark
{
///
@@ -15,7 +15,7 @@ public static class AnimatedTextWatermark
///
///
///
- public static AnimatedGif AddTextWatermark(this AnimatedGif img, string text)
+ public static AnimatedImage AddTextWatermark(this AnimatedImage img, string text)
{
return AddTextWatermark(img, text, new TextWatermarkOptions());
}
@@ -26,7 +26,7 @@ public static AnimatedGif AddTextWatermark(this AnimatedGif img, string text)
///
/// text to draw over the image
/// Text watermark options
- public static AnimatedGif AddTextWatermark(this AnimatedGif img, string text, TextWatermarkOptions ops)
+ public static AnimatedImage AddTextWatermark(this AnimatedImage img, string text, TextWatermarkOptions ops)
{
var fList = new List();
diff --git a/LazZiya.ImageResize/LazZiya.ImageResize.csproj b/LazZiya.ImageResize/LazZiya.ImageResize.csproj
index 2c98e42..160039c 100644
--- a/LazZiya.ImageResize/LazZiya.ImageResize.csproj
+++ b/LazZiya.ImageResize/LazZiya.ImageResize.csproj
@@ -10,11 +10,12 @@
asp.net,core,.net,dotnet,image,resize,text,overlay
https://github.com/LazZiya/ImageResize
http://demo.ziyad.info/en/ImageResize
- 3.1.0
- beta1
- 3.1.0.0
- 3.1.0.0
+ 4.0.0
+ preview1
+ 4.0.0.0
+ 4.0.0.0
+ - Added support for animated gif (resize, text watewrmark, image water
- Update ref for System.Drawing.Common https://github.com/dotnet/core/issues/3244
- See all release notes https://github.com/LazZiya/ImageResize/releases
diff --git a/LazZiya.ImageResize/files/LazZiya.ImageResize.xml b/LazZiya.ImageResize/files/LazZiya.ImageResize.xml
index bc942da..3705605 100644
--- a/LazZiya.ImageResize/files/LazZiya.ImageResize.xml
+++ b/LazZiya.ImageResize/files/LazZiya.ImageResize.xml
@@ -4,110 +4,158 @@
LazZiya.ImageResize
-
+
- Represents an animated gif image with multiple frames
+ Represents an animated image image with multiple frames
-
+
Gif image as list of frames
-
+
Set repeat count. (-1) no repeat. (0) always repeat
-
+
Get frames count in an animated gif
-
+
Get width and height of the image
-
+
Get image color format
-
+
Get pixel format
-
+
Get horizontal resolution
-
+
Get vertival resolution
-
+
Get image raw format
-
+
- Create an animated gif from file
+ private constructor
-
-
+
- Create an animated gif from a stream
+ Create animated image from file
+
+
+
+
+
+
+ Create animated image from stream
+
-
+
- Create an animated gif from HBitmap
+ Create animated image from image
-
+
+
-
+
- Create an animated gif from HBitmap
+ Create animated image from bitmap
-
+
-
+
- Create animated gif from Image file
+ Create animated image from bitmap
-
+
+
+
-
+
Save animated gif
Frmae delay in milliseconds
-
+
Clear frames
-
+
deconstruct
-
+
+
+ Add an image watermark to animated gif
+
+
+
+
+ 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.
+ Notice regarding watermark opacity:
+ 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.
+
+ The original image
+ Watermak image
+ Image watermark options
+
+
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.
@@ -119,7 +167,7 @@
-
+
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.
@@ -132,7 +180,7 @@
Graphic options
-
+
Scale image by width and keep same aspect ratio of target image same as the original image.
Height will be adjusted automatically
@@ -141,7 +189,7 @@
-
+
Scale image by width and keep same aspect ratio of target image same as the original image.
Height will be adjusted automatically
@@ -151,7 +199,7 @@
Graphic options
-
+
Scale image by height and keep same aspect ratio of target image same as the original image.
Width will be adjusted automatically
@@ -160,7 +208,7 @@
-
+
Scale image by height and keep same aspect ratio of target image same as the original image.
Width will be adjusted automatically
@@ -170,7 +218,7 @@
Graphic options
-
+
Scale target image till shortest border are equal to target value,
then crop the additonal pixels from the longest border.
@@ -182,7 +230,7 @@
-
+
Scale target image till shortest border are equal to target value,
then crop the additonal pixels from the longest border.
@@ -195,7 +243,7 @@
Graphic options
-
+
Directly crop original image without scaling it.
Final image aspect ratio is equal to given new width/height
@@ -206,7 +254,7 @@
target spot to crop and save
-
+
Directly crop original image without scaling it.
Final image aspect ratio is equal to given new width/height
@@ -218,7 +266,7 @@
Graphic options
-
+
Specify custom resize options
@@ -228,7 +276,7 @@
The coordinates of the target image size
-
+
Specify custom resize options
@@ -239,44 +287,6 @@
Graphic options
-
-
- Add an image watermark to animated gif
-
-
-
-
- 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.
- Notice regarding watermark opacity:
- 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.
-
- The original image
- Watermak image
- Image watermark options
-
Encodes multiple images as an animated gif to a stream.
@@ -314,19 +324,19 @@
Save and dispose
-
+
Add text watermark over the image.
-
+
Add text watermark over the image.
-
+
Add text watermark over the image.