Filtrovat CMX přes C#
Vytvářejte své vlastní aplikace .NET pro filtrování souborů CMX pomocí rozhraní API na straně serveru.
Jak filtrovat soubory CMX pomocí C#
I ten nejdokonalejší obraz lze dále vylepšit nebo proměnit ve zcela jiné a jedinečné umělecké dílo. Použijte filtry pro dosažení široké škály obrazových efektů. Můžete například zostřit obrázek nebo naopak přidat rozostření, vyhladit jej nebo odstranit barevný šum. Filtry jsou také neocenitelné, když chcete svému obrazu dodat jedinečnost. Chcete-li toho dosáhnout, použijte požadovaný efekt nebo zkombinujte různé efekty. Tento přístup umožňuje vylepšit barevné přechody, eliminovat šum a současně zvýšit ostrost okrajů objektů na fotografii. K filtrování souborů ve formátu CMX použijeme Aspose.Imaging for .NET API, které je funkčně bohaté, výkonné a snadno použitelné rozhraní API pro manipulaci a konverzi obrázků pro platformu C#. Otevřete správce balíčků NuGet , vyhledejte Aspose.Imaging a nainstalujte. Můžete také použít následující příkaz z konzoly Správce balíčků.
Příkaz konzole Správce balíčků
PM> Install-Package Aspose.Imaging
Kroky k filtrování CMX přes C#
K vyzkoušení následujícího pracovního postupu ve svém vlastním prostředí potřebujete aspose.imaging.dll .
- Načíst soubory CMX metodou Image.Load
- Filtrovat obrázky;
- Uložte komprimovaný obrázek na disk ve formátu podporovaném Aspose.Imaging
Požadavky na systém
Aspose.Imaging pro .NET je podporován ve všech hlavních operačních systémech. Jen se ujistěte, že máte následující předpoklady.
- Microsoft Windows nebo kompatibilní OS s rozhraním .NET Framework, .NET Core, aplikací pro Windows, webovou aplikací ASP.NET.
- Vývojové prostředí jako Microsoft Visual Studio.
- Aspose.Imaging pro .NET odkazovaný ve vašem projektu.
Filtrovat obrázky ve formátu CMX – .NET
using Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Bmp; | |
using Aspose.Imaging.FileFormats.Dicom; | |
using Aspose.Imaging.FileFormats.Emf; | |
using Aspose.Imaging.FileFormats.Jpeg; | |
using Aspose.Imaging.FileFormats.Jpeg2000; | |
using Aspose.Imaging.FileFormats.Png; | |
using Aspose.Imaging.FileFormats.Psd; | |
using Aspose.Imaging.FileFormats.Tiff.Enums; | |
using Aspose.Imaging.ImageFilters.FilterOptions; | |
using Aspose.Imaging.ImageOptions; | |
using Aspose.Imaging.Masking; | |
using Aspose.Imaging.Masking.Options; | |
using Aspose.Imaging.Masking.Result; | |
using Aspose.Imaging.Sources; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
string templatesFolder = @"c:\Users\USER\Downloads"; | |
MedianFilter(); | |
void SmallRectangularFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/smallrectangularfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new SmallRectangularFilterOptions()); | |
}, "smallrectangular"); | |
} | |
void BigRectangularFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/bigrectangularfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new BigRectangularFilterOptions()); | |
}, "bigrectangular"); | |
} | |
void SharpenFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/sharpenfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new SharpenFilterOptions()); | |
}, "sharpen"); | |
} | |
void MotionWienerFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/motionwienerfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new MotionWienerFilterOptions(20, 2, 0)); | |
}, "motionwiener"); | |
} | |
void BilateralSmoothingFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/bilateralsmoothingfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new BilateralSmoothingFilterOptions()); | |
}, "bilateralsmoothing"); | |
} | |
void GaussBlurFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/gaussianblurfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new GaussianBlurFilterOptions(5, 4)); | |
}, "gaussblur"); | |
} | |
void GaussWienerFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/gausswienerfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new GaussWienerFilterOptions(5, 5)); | |
}, "gausswiener"); | |
} | |
void MedianFilter() | |
{ | |
FilterImages(image => | |
{ | |
//https://apireference.aspose.com/imaging/net/aspose.imaging.imagefilters.filteroptions/medianfilteroptions | |
var filterRect = new Aspose.Imaging.Rectangle(image.Width / 6, image.Height / 6, image.Width * 2 / 3, image.Height * 2 / 3); | |
image.Filter(filterRect, new MedianFilterOptions(20)); | |
}, "median"); | |
} | |
void FilterImages(Action<RasterImage> doFilter, string filterName) | |
{ | |
List<string> rasterFormats = new List<string>() { "jpg", "png", "bmp", "apng", "dicom", | |
"jp2", "j2k", "tga", "webp", "tif", "gif","ico" }; | |
List<string> vectorFormats = new List<string>() { "svg", "otg", "odg", "eps", "wmf", "emf", "wmz", "emz", "cmx", "cdr" }; | |
List<string> allFormats = new List<string>(rasterFormats); | |
allFormats.AddRange(vectorFormats); | |
allFormats.ForEach( | |
formatExt => | |
{ | |
var inputFile = Path.Combine(templatesFolder, $"template.{formatExt}"); | |
bool isVectorFormat = vectorFormats.IndexOf(formatExt) > -1; | |
//Need to rasterize vector formats before background remove | |
if (isVectorFormat) | |
{ | |
inputFile = RasterizeVectorImage(formatExt, inputFile); | |
} | |
var outputFile = Path.Combine(templatesFolder, $"{filterName}_{formatExt}.png"); | |
Console.WriteLine($"Processing {formatExt}"); | |
using (var image = (RasterImage)Image.Load(inputFile)) | |
{ | |
doFilter(image); | |
//If image is multipage save each page to png to demonstrate results | |
if (image is IMultipageImage multiPage && multiPage.PageCount > 1) | |
{ | |
for (var pageIndex = 0; pageIndex < multiPage.PageCount; pageIndex++) | |
{ | |
string fileName = $"{filterName}_page{pageIndex}_{formatExt}.png"; | |
multiPage.Pages[pageIndex].Save(templatesFolder + fileName, new PngOptions()); | |
File.Delete(templatesFolder + fileName); | |
} | |
} | |
else | |
{ | |
image.Save(outputFile, new PngOptions()); | |
File.Delete(outputFile); | |
} | |
} | |
//Remove rasterized vector image | |
if (isVectorFormat) | |
{ | |
File.Delete(inputFile); | |
} | |
} | |
); | |
} | |
string RasterizeVectorImage(string formatExt, string inputFile) | |
{ | |
string outputFile = Path.Combine(templatesFolder, $"rasterized.{formatExt}.png"); | |
using (var image = Image.Load(inputFile)) | |
{ | |
image.Save(outputFile, new PngOptions()); | |
} | |
return outputFile; | |
} |
O Aspose.Imaging pro .NET API
Aspose.Imaging API je řešení pro zpracování obrázků pro vytváření, úpravu, kreslení nebo konverzi obrázků (fotografií) v rámci aplikací. Nabízí: multiplatformní zpracování obrazu, mimo jiné včetně převodů mezi různými formáty obrázků (včetně jednotného vícestránkového nebo vícesnímkového zpracování obrazu), úpravy jako kreslení, práci s grafickými primitivy, transformace (změna velikosti, oříznutí, převrácení a otočení). binarizace, stupně šedi, úprava), pokročilé funkce pro manipulaci s obrázky (filtrování, rozklad, maskování, vyrovnání sklonu) a strategie optimalizace paměti. Je to samostatná knihovna a není závislá na žádném softwaru pro operace s obrázky. V rámci projektů lze snadno přidat vysoce výkonné funkce pro konverzi obrázků s nativními rozhraními API. Jedná se o 100% soukromá on-premise API a obrázky se zpracovávají na vašich serverech.Filtrujte CMX prostřednictvím online aplikace
Filtrujte dokumenty ve formátu CMX na našem webu s živými ukázkami . Živé demo má následující výhody
CMX co je CMX Formát souboru
Soubory s příponou CMX jsou formát souboru obrázků Corel Exchange, který používají aplikace CorelSuite jako prezentaci. Obsahuje obrazová data jako vektorovou grafiku i metadata, která obrázek popisují. Soubory CMX lze otevřít pomocí aplikací CorelDraw, Corel Presentations, Paint Shop Pro a některých verzí aplikace Adobe Illustrator.
Přečtěte si víceDalší podporované formáty filtrů
Pomocí C# lze snadno filtrovat různé formáty včetně.