Com.DotNetBros.ImageBase64Encoder
1.0.0
dotnet add package Com.DotNetBros.ImageBase64Encoder --version 1.0.0
NuGet\Install-Package Com.DotNetBros.ImageBase64Encoder -Version 1.0.0
<PackageReference Include="Com.DotNetBros.ImageBase64Encoder" Version="1.0.0" />
paket add Com.DotNetBros.ImageBase64Encoder --version 1.0.0
#r "nuget: Com.DotNetBros.ImageBase64Encoder, 1.0.0"
// Install Com.DotNetBros.ImageBase64Encoder as a Cake Addin
#addin nuget:?package=Com.DotNetBros.ImageBase64Encoder&version=1.0.0
// Install Com.DotNetBros.ImageBase64Encoder as a Cake Tool
#tool nuget:?package=Com.DotNetBros.ImageBase64Encoder&version=1.0.0
Com.DotNetBros.ImageBase64Encoder
ImageBase64Encoder is a versatile C# class that makes it simple to convert images to Base64 strings and vice versa. It is particularly useful for embedding images in HTML or CSS, transmitting images over a network, or storing them in databases. This class is built on top of the powerful SixLabors.ImageSharp library, ensuring top-notch performance and reliability.
Features
Easily convert images to Base64 strings and back Supports loading images from file paths or byte arrays Lightweight and efficient with the help of SixLabors.ImageSharp Compatible with various image formats, automatically handled by the ImageSharp library Installation To use this class, you need to install the SixLabors.ImageSharp NuGet package:
Install-Package SixLabors.ImageSharp -Version 1.0.4
Then, simply add the ImageBase64Encoder.cs
file to your project.
Usage Examples
Here are a few examples of how to use the ImageBase64Encoder class:
Convert an image from a file path to a Base64
using Com.DotNetBros.ImageBase64Encoder;
string imagePath = "path/to/your/image.png";
string base64String = ImageBase64Encoder.ImageToBase64(imagePath);
Console.WriteLine("Base64 String: " + base64String);
Convert an image from a byte array to a Base64 string
using Com.DotNetBros.ImageBase64Encoder;
byte[] imageBytes = File.ReadAllBytes("path/to/your/image.png");
string base64String = ImageBase64Encoder.ImageToBase64(imageBytes);
Console.WriteLine("Base64 String: " + base64String);
Convert a Base64 string back to an Image object
using Com.DotNetBros.ImageBase64Encoder;
string base64String = "your_base64_string_here";
Image image = ImageBase64Encoder.Base64ToImage(base64String);
// Perform any additional image processing or save it to a file
image.Save("output_image.png");
License
This project is open source and available under the MIT License.
Contributing
Pull requests and suggestions are welcome! If you have any ideas or improvements, please don't hesitate to submit an issue or create a pull request.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- SixLabors.ImageSharp (>= 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 160 | 3/17/2023 |