-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
715b474
commit 36bc51d
Showing
5 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Use Cases/Image to Gif/NET Standard/Image to Gif/Image to Gif.sln
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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.9.34310.174 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Image to Gif", "Image to Gif\Image to Gif.csproj", "{1ED29CD7-AA72-46E3-B532-E7429BED055F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{1ED29CD7-AA72-46E3-B532-E7429BED055F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1ED29CD7-AA72-46E3-B532-E7429BED055F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1ED29CD7-AA72-46E3-B532-E7429BED055F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1ED29CD7-AA72-46E3-B532-E7429BED055F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {9122DE32-2608-472A-919F-2DC5B1DDEF6D} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+24.1 KB
Use Cases/Image to Gif/NET Standard/Image to Gif/Image to Gif/Data/InputTemplate.xlsx
Binary file not shown.
17 changes: 17 additions & 0 deletions
17
Use Cases/Image to Gif/NET Standard/Image to Gif/Image to Gif/Image to Gif.csproj
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,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Image_to_Gif</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.9.1" /> | ||
<PackageReference Include="Syncfusion.XlsIORenderer.Net.Core" Version="26.1.42" /> | ||
<PackageReference Include="System.Drawing.Common" Version="8.0.7" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+434 KB
Use Cases/Image to Gif/NET Standard/Image to Gif/Image to Gif/Output/animated.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions
60
Use Cases/Image to Gif/NET Standard/Image to Gif/Image to Gif/Program.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,60 @@ | ||
using ImageMagick; | ||
using Syncfusion.XlsIO; | ||
using Syncfusion.XlsIORenderer; | ||
|
||
namespace Image_to_Gif | ||
{ | ||
class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
using (ExcelEngine excelEngine = new ExcelEngine()) | ||
{ | ||
IApplication application = excelEngine.Excel; | ||
application.DefaultVersion = ExcelVersion.Excel2013; | ||
|
||
//Load an input template | ||
using(FileStream file = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read)) | ||
{ | ||
IWorkbook workbook = application.Workbooks.Open(file); | ||
|
||
using (MagickImageCollection collection = new MagickImageCollection()) | ||
{ | ||
for (int i = 0; i < workbook.Worksheets.Count; i++) | ||
{ | ||
IWorksheet worksheet = workbook.Worksheets[i]; | ||
|
||
//Initialize XlsIORenderer | ||
application.XlsIORenderer = new XlsIORenderer(); | ||
|
||
//Create a memory stream to save the image | ||
using (MemoryStream stream = new MemoryStream()) | ||
{ | ||
//Convert worksheet to image and save it to stream | ||
worksheet.ConvertToImage(1,1,27,11, stream); | ||
|
||
//Set stream postition | ||
stream.Position = 0; | ||
|
||
//Load the image into MagickImage | ||
MagickImage image = new MagickImage(stream); | ||
|
||
//Add the image to the collection | ||
collection.Add(image); | ||
} | ||
} | ||
|
||
//Set the delay between frames (100 = 1 second) | ||
foreach (MagickImage image in collection) | ||
{ | ||
image.AnimationDelay = 100; | ||
} | ||
|
||
//Create an animated GIF | ||
collection.Write(@"..\..\..\Output\animated.gif"); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |