Merge pull request #41 from SixLabors/bp/vnextupdate

Update docs
This commit is contained in:
James Jackson-South 2022-02-04 11:32:53 +11:00 коммит произвёл GitHub
Родитель 4ee9e372ea b5c4c6cc77
Коммит d182b1fc8e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 81 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,38 @@
# Create an animated GIF
The following example demonstrates how to create a animated gif from several single images.
The different image frames will be images with different colors.
```c#
// Image dimensions of the gif.
const int width = 100;
const int height = 100;
// Delay between frames in (1/100) of a second.
const int frameDelay = 100;
// For demonstration: use images with different colors.
var colors = new Color[]
{
Color.Green,
Color.Red
};
// Create empty image.
using Image<Rgba32> gif = new(width, height, Color.Blue);
for (int i = 0; i < colors.Length; i++)
{
// Create a color image, which will be added to the gif.
using Image<Rgba32> image = new(width, height, colors[i]);
// Set the duration of the frame delay.
GifFrameMetadata metadata = image.Frames.RootFrame.Metadata.GetGifMetadata();
metadata.FrameDelay = frameDelay;
// Add the color image to the gif.
gif.Frames.AddFrame(image.Frames.RootFrame);
}
// Save the final result.
gif.SaveAsGif("output.gif");
```

Просмотреть файл

@ -47,6 +47,45 @@ In this very basic example you are actually utilizing several core ImageSharp fe
- [Image Formats](imageformats.md) by loading and saving an image.
- [Image Processors](processing.md) by calling `Mutate()` and `Resize()`
### Identify image
If you are only interested in the image dimensions or metadata of the image, you can achieve this with `Image.Identify`.
This will avoid decoding the complete image and therfore be much faster.
For example:
```c#
IImageInfo imageInfo = Image.Identify(@"image.jpg");
Console.WriteLine($"Width: {imageInfo.Width}");
Console.WriteLine($"Height: {imageInfo.Width}");
```
### Image metadata
To retrieve image metadata, either load an image with `Image.Load` or use `Image.Identify` (this will not decode the complete image, just the metadata). In both cases you will get the image dimensions and additional the the image
metadata in the `Metadata` property.
This will contain the following profiles, if present in the image:
- ExifProfile
- IccProfile
- IptcProfile
- XmpProfile
##### Format specific metadata
Further there are format specific metadata, which can be obtained for example like this:
```c#
Image image = Image.Load(@"image.jpg");
ImageMetadata imageMetaData = image.Metadata;
// Syntactic sugar for imageMetaData.GetFormatMetadata(JpegFormat.Instance)
JpegMetadata jpegData = imageMetaData.GetJpegMetadata();
```
And similar for the other supported formats.
### Initializing New Images
```c#
@ -58,7 +97,7 @@ int width = 640;
int height = 480;
// Creates a new image with empty pixel data.
using(var image = new Image<Rgba32>(width, height))
using(Image<Rgba32> image = new(width, height))
{
// Do your drawing in here...

Просмотреть файл

@ -47,3 +47,4 @@ using (Image image = Image.Load(inStream))
Examples of common operations can be found in the following documentation pages.
- [Resizing](resize.md) images using different options.
- Create [animated gif](animatedgif.md).

Просмотреть файл

@ -4,6 +4,7 @@
### [Image Formats](imagesharp/imageformats.md)
### [Processing Images](imagesharp/processing.md)
#### [Resizing Images](imagesharp/resize.md)
#### [Create an animated GIF](imagesharp/animatedgif.md)
### [Working with Pixel Buffers](imagesharp/pixelbuffers.md)
### [Configuration](imagesharp/configuration.md)

Просмотреть файл

@ -24,7 +24,7 @@ $(function () {
});
// Fix the width of the right sidebar so we don't lose content.
const scrollbarWidth = 3 * (window.innerWidth - document.body.offsetWidth);
const scrollbarWidth = 3.5 * (window.innerWidth - document.body.offsetWidth);
$(".sideaffix").each(function () {
const $this = $(this);