public static void Run() { // ExStart:SavingRasterImageToTIFFWithCompression // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Create an instance of TiffOptions and set its various properties TiffOptions options = new TiffOptions(TiffExpectedFormat.Default); options.BitsPerSample = new ushort[] { 8, 8, 8 }; options.Photometric = TiffPhotometrics.Rgb; options.Xresolution = new TiffRational(72); options.Yresolution = new TiffRational(72); options.ResolutionUnit = TiffResolutionUnits.Inch; options.PlanarConfiguration = TiffPlanarConfigs.Contiguous; // Set the Compression to AdobeDeflate options.Compression = TiffCompressions.AdobeDeflate; // Or Deflate // Options.Compression = TiffCompressions.Deflate; // Load an existing image in an instance of RasterImage using (RasterImage image = (RasterImage)Image.Load(dataDir + "SampleTiff1.tiff")) { // Create a new TiffImage from the RasterImage and Save the resultant image while passing the instance of TiffOptions using (TiffImage tiffImage = new TiffImage(new TiffFrame(image))) { tiffImage.Save(dataDir + "SavingRasterImage_out.tiff", options); } } // ExEnd:SavingRasterImageToTIFFWithCompression }
public static void Run() { // ExStart:CreatingTIFFImageWithCompression // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages() + "SavingRasterImageToTIFFWithCompression_out.tiff"; // Create an instance of TiffOptions and set its various properties TiffOptions options = new TiffOptions(TiffExpectedFormat.Default); options.BitsPerSample = new ushort[] { 8, 8, 8 }; options.Photometric = TiffPhotometrics.Rgb; options.Xresolution = new TiffRational(72); options.Yresolution = new TiffRational(72); options.ResolutionUnit = TiffResolutionUnits.Inch; options.PlanarConfiguration = TiffPlanarConfigs.Contiguous; // Set the Compression to AdobeDeflate options.Compression = TiffCompressions.AdobeDeflate; // Or Deflate // Options.Compression = TiffCompressions.Deflate; // Create a new TiffImage with specific size and TiffOptions settings using (TiffImage tiffImage = new TiffImage(new TiffFrame(options, 100, 100))) { // Loop over the pixels to set the color to red for (int i = 0; i < 100; i++) { tiffImage.ActiveFrame.SetPixel(i, i, Color.Red); } // Save resultant image tiffImage.Save(dataDir); } // ExEnd:CreatingTIFFImageWithCompression }
public static void Run() { //ExStart:PresentationToTIFFWithCustomImagePixelFormat // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Conversion(); // Instantiate a Presentation object that represents a Presentation file using (Presentation presentation = new Presentation(dataDir + "DemoFile.pptx")) { TiffOptions options = new TiffOptions(); options.PixelFormat = ImagePixelFormat.Format8bppIndexed; /* * ImagePixelFormat contains the following values (as could be seen from documentation): * Format1bppIndexed; // 1 bits per pixel, indexed. * Format4bppIndexed; // 4 bits per pixel, indexed. * Format8bppIndexed; // 8 bits per pixel, indexed. * Format24bppRgb; // 24 bits per pixel, RGB. * Format32bppArgb; // 32 bits per pixel, ARGB. */ // Save the presentation to TIFF with specified image size presentation.Save(dataDir + "Tiff_With_Custom_Image_Pixel_Format_out.tiff", SaveFormat.Tiff, options); } //ExEnd:PresentationToTIFFWithCustomImagePixelFormat }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_PSD(); //ExStart:AdjustingGamma string sourceFile = dataDir + @"sample.psd"; string destName = dataDir + @"AdjustGamma_out.tiff"; // Load an existing image into an instance of RasterImage class using (var image = Image.Load(sourceFile)) { // Cast object of Image to RasterImage RasterImage rasterImage = (RasterImage)image; // Check if RasterImage is cached and Cache RasterImage for better performance if (!rasterImage.IsCached) { rasterImage.CacheData(); } // Adjust the gamma rasterImage.AdjustGamma(2.2f, 2.2f, 2.2f); // Create an instance of TiffOptions for the resultant image, Set various properties for the object of TiffOptions and Save the resultant image to TIFF format TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default); tiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 }; tiffOptions.Photometric = TiffPhotometrics.Rgb; rasterImage.Save(destName, tiffOptions); } //ExEnd:AdjustingGamma }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); //ExStart:GIFImageLayersToTIFF String sourceFile = dataDir + @"sample.psd"; string destName = dataDir + @"output"; // Load a PSD image and Convert the image's layers to Tiff images. using (PsdImage image = (PsdImage)Image.Load(sourceFile)) { // Iterate through array of PSD layers for (int i = 0; i < image.Layers.Length; i++) { // Get PSD layer. Layer layer = image.Layers[i]; // Create an instance of TIFF Option class and Save the PSD layer as TIFF image TiffOptions objTiff = new TiffOptions(TiffExpectedFormat.TiffDeflateRgb); layer.Save("output" + i + "_out.tif", objTiff); } } //ExEnd:GIFImageLayersToTIFF }
public static void Run() { //ExStart:AdjustBrightness // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load an image in an instance of Image using (Image image__1 = Image.Load(dataDir + Convert.ToString("aspose-logo.jpg"))) { // Cast object of Image to RasterImage RasterImage rasterImage = (RasterImage)image__1; // Check if RasterImage is cached and Cache RasterImage for better performance if (!rasterImage.IsCached) { rasterImage.CacheData(); } // Adjust the brightness rasterImage.AdjustBrightness(70); // Create an instance of TiffOptions for the resultant image, Set various properties for the object of TiffOptions and Save the resultant image TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default); tiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 }; tiffOptions.Photometric = TiffPhotometrics.Rgb; rasterImage.Save(dataDir + Convert.ToString("AdjustBrightness_out.tiff"), tiffOptions); } //ExEnd:TiffOptionsConfiguration }
public static void Run() { // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); // ExStart:AdjustBrightness // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load an image in an instance of Image using (Image image = Image.Load(dataDir + "aspose-logo.jpg")) { // Cast object of Image to RasterImage RasterImage rasterImage = (RasterImage)image; // Check if RasterImage is cached and Cache RasterImage for better performance if (!rasterImage.IsCached) { rasterImage.CacheData(); } // Adjust the contrast rasterImage.AdjustContrast(10); // Create an instance of TiffOptions for the resultant image, Set various properties for the object of TiffOptions and Save the resultant image to TIFF format TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default); tiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 }; tiffOptions.Photometric = TiffPhotometrics.Rgb; rasterImage.Save(dataDir + "AdjustContrast_out.tiff", tiffOptions); } // ExEnd:TiffOptionsConfiguration }
{//ExStart:ICCProfileExtraction public static void Run() { //string dir = @"c:\aspose.work\IMAGINGNET\2990\"; string dataDir = RunExamples.GetDataDir_PSD(); string sourcePath = dataDir + "gray-d15.psd"; string outputPath = dataDir + "gray-d15.psd.apply-icc.tif"; // Save to grayscale TIFF TiffOptions saveOptions = new TiffOptions(TiffExpectedFormat.Default); saveOptions.Photometric = TiffPhotometrics.MinIsBlack; saveOptions.BitsPerSample = new ushort[] { 8 }; // If the image contains a built-in Gray ICC profile, it is not be applied by default in contrast of the CMYK profile. // Enable ICC conversion explicitly. LoadOptions loadOptions = new LoadOptions(); loadOptions.UseIccProfileConversion = true; using (PsdImage psdImage = (PsdImage)Image.Load(sourcePath, loadOptions)) { // Embed the gray ICC profile to the output TIFF. // The built-in Gray Profile can be read via the PsdImage.GrayColorProfile property. saveOptions.IccProfile = ToMemoryStream(psdImage.GrayColorProfile); psdImage.Save(outputPath, saveOptions); } }
public static void Run() { //ExStart:AIToTIFF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AI(); string[] sourcesFiles = new string[] { @"34992OStroke", @"rect2_color", }; for (int i = 0; i < sourcesFiles.Length; i++) { string name = sourcesFiles[i]; string sourceFileName = dataDir + name + ".ai"; string outFileName = dataDir + name + ".tif"; using (AiImage image = (AiImage)Image.Load(sourceFileName)) { ImageOptionsBase options = new TiffOptions(TiffExpectedFormat.TiffDeflateRgba); image.Save(outFileName, options); } } //ExEnd:AIToTIFF }
public static void Run() { Console.WriteLine("Running example ConvertGIFImageLayersToTIFF"); // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load a GIF image and Convert the image to GIF image Image objImage = Image.Load(dataDir + "asposelogo.gif"); using (GifImage gif = (GifImage)objImage) { // Iterate through arry of blocks in the GIF image for (int i = 0; i < gif.Blocks.Length; i++) { // Convert block to GifFrameBlock class instance GifFrameBlock gifBlock = gif.Blocks[i] as GifFrameBlock; // Check if gif block is then ignore it if (gifBlock == null) { continue; } // Create an instance of TIFF Option class and Save the GIFF block as TIFF image TiffOptions objTiff = new TiffOptions(TiffExpectedFormat.Default); gifBlock.Save(dataDir + "asposelogo" + i + "_out.tif", objTiff); } } Console.WriteLine("Finished example ConvertGIFImageLayersToTIFF"); }
public static void Run() { // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); // ExStart:ConvertGIFImageLayersToTIFF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load a GIF image Image objImage = Image.Load(dataDir + "asposelogo.gif"); // Convert the image to GIF image using (GifImage gif = (GifImage)objImage) { // iterate through arry of blocks in the GIF image for (int i = 0; i < gif.Blocks.Length; i++) { // convert block to GifFrameBlock class instance GifFrameBlock gifBlock = gif.Blocks[i] as GifFrameBlock; // Check if gif block is then ignore it if (gifBlock == null) { continue; } // Create an instance of TIFF Option class TiffOptions objTiff = new TiffOptions(TiffExpectedFormat.Default); // Save the GIFF block as TIFF image gifBlock.Save(dataDir + "asposelogo" + i + "_out.tif", objTiff); } } // ExEnd:ConvertGIFImageLayersToTIFF }
public static void Run() { // ExStart:AdjustBrightness // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load an image in an instance of Image using (Image image__1 = Image.Load(dataDir + Convert.ToString("aspose-logo.jpg"))) { // Cast object of Image to RasterImage RasterImage rasterImage = (RasterImage)image__1; // Check if RasterImage is cached and Cache RasterImage for better performance if (!rasterImage.IsCached) { rasterImage.CacheData(); } // Adjust the brightness rasterImage.AdjustBrightness(70); // Create an instance of TiffOptions for the resultant image, Set various properties for the object of TiffOptions and Save the resultant image TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.Default); tiffOptions.BitsPerSample = new ushort[] {8,8,8}; tiffOptions.Photometric = TiffPhotometrics.Rgb; rasterImage.Save(dataDir + Convert.ToString("AdjustBrightness_out.tiff"), tiffOptions); } // ExEnd:TiffOptionsConfiguration }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_PSD(); //ExStart:CompressingTiff // Load a PSD file as an image and cast it into PsdImage using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "layers.psd")) { // Create an instance of TiffOptions for the resultant image TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default); // Set BitsPerSample, Compression, Photometric mode and graycale palette outputSettings.BitsPerSample = new ushort[] { 4 }; outputSettings.Compression = TiffCompressions.Lzw; outputSettings.Photometric = TiffPhotometrics.Palette; outputSettings.Palette = ColorPaletteHelper.Create4BitGrayscale(true); psdImage.Save(dataDir + "SampleTiff_out.tiff", outputSettings); } //ExEnd:CompressingTiff }
public static void Run() { // ExStart:ConvertGIFImageLayersToTIFF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load a GIF image and Convert the image to GIF image Image objImage = Image.Load(dataDir + "asposelogo.gif"); using (GifImage gif = (GifImage)objImage) { // Iterate through arry of blocks in the GIF image for (int i = 0; i < gif.Blocks.Length; i++) { // Convert block to GifFrameBlock class instance GifFrameBlock gifBlock = gif.Blocks[i] as GifFrameBlock; // Check if gif block is then ignore it if (gifBlock == null) { continue; } // Create an instance of TIFF Option class and Save the GIFF block as TIFF image TiffOptions objTiff = new TiffOptions(TiffExpectedFormat.Default); gifBlock.Save(dataDir + "asposelogo" + i + "_out.tif", objTiff); } } // ExEnd:ConvertGIFImageLayersToTIFF }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); List<string> files = new List<string>(new[] { dataDir + "TestDemo.tiff", dataDir + "sample.tiff" }); TiffOptions createOptions = new TiffOptions(TiffExpectedFormat.Default); createOptions.BitsPerSample = new ushort[] { 1 }; createOptions.Orientation = TiffOrientations.TopLeft; createOptions.Photometric = TiffPhotometrics.MinIsBlack; createOptions.Compression = TiffCompressions.CcittFax3; createOptions.FillOrder = TiffFillOrders.Lsb2Msb; // Create a new image by passing the TiffOptions and size of first frame, we will remove the first frame at the end, cause it will be empty TiffImage output = null; try { List<TiffImage> images = new List<TiffImage>(); try { foreach (var file in files) { // Create an instance of TiffImage and load the source image TiffImage input = (TiffImage)Image.Load(file); images.Add(input); // Do not dispose before data is fetched. Data is fetched on 'Save' later. foreach (var frame in input.Frames) { if (output == null) { // Create a new tiff image with first frame defined. output = new TiffImage(TiffFrame.CopyFrame(frame)); } else { // Add copied frame to destination image output.AddFrame(TiffFrame.CopyFrame(frame)); } } } if (output != null) { // Save the result output.Save(dataDir + "ConcatenateTiffImagesHavingSeveralFrames_out.tif", createOptions); } } finally { foreach (TiffImage image in images) { image.Dispose(); } } } catch (Exception ex) { } }
void SaveDocument(SaveType type) { if (!SBSDK.IsLicenseValid()) { Alert.ShowLicenseDialog(this); return; } Task.Run(delegate { var input = adapter.GetDocumentUris().ToArray(); var output = GetOutputUri(".pdf"); if (type == SaveType.TIFF) { output = GetOutputUri(".tiff"); // Please note that some compression types are only compatible for 1-bit encoded images (binarized black & white images)! var options = new TiffOptions { OneBitEncoded = true, Compression = TiffCompressionOptions.CompressionCcittfax4, Dpi = 250 }; bool success = SBSDK.WriteTiff(input, output, options); } else if (type == SaveType.OCR) { var languages = SBSDK.GetOcrConfigs().InstalledLanguages.ToArray(); if (languages.Length == 0) { RunOnUiThread(delegate { Alert.Toast(this, "OCR languages blobs are not available"); }); return; } SBSDK.PerformOCR(input, languages, output); } else { SBSDK.CreatePDF(input, output, ScanbotSDK.Xamarin.PDFPageSize.FixedA4); } Java.IO.File file = Copier.Copy(this, output); var intent = new Intent(Intent.ActionView, output); var authority = ApplicationContext.PackageName + ".provider"; var uri = FileProvider.GetUriForFile(this, authority, file); intent.SetDataAndType(uri, MimeUtils.GetMimeByName(file.Name)); intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask); intent.AddFlags(ActivityFlags.GrantReadUriPermission | ActivityFlags.GrantWriteUriPermission); RunOnUiThread(delegate { StartActivity(Intent.CreateChooser(intent, output.LastPathSegment)); Alert.Toast(this, "File saved to: " + output.Path); }); }); }
///<Summary> /// ConvertImageToTiff method to convert image to tiff ///</Summary> public Response ConvertImageToTiff(string fileName, string folderName, string outputType) { ImageOptionsBase optionsBase = new TiffOptions(Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffJpegRgb); return(ProcessTask(fileName, folderName, "." + outputType, false, false, delegate(string inFilePath, string outPath, string zipOutFolder) { using (Image image = Image.Load(inFilePath)) { image.Save(outPath, optionsBase); } })); }
///<Summary> /// ConvertPSDToTiff method to convert psd to tiff ///</Summary> public Response ConvertPSDToTiff(string fileName, string folderName, string outputType) { TiffOptions tiffOptions = new TiffOptions(Aspose.PSD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); return(ProcessTask(fileName, folderName, ".tiff", false, false, delegate(string inFilePath, string outPath, string zipOutFolder) { using (Image image = Image.Load(inFilePath)) { image.Save(outPath, tiffOptions); } })); }
public static void Run() { //ExStart:RGBColorSytem string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); string sourceFilePath = "testTileDeflate.tif"; string outputFilePath = "testTileDeflate Cmyk Icc.tif"; TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffLzwCmyk); using (Image image = Image.Load(sourceFilePath)) { image.Save(outputFilePath, options); } //ExEnd:RGBColorSytem }
public static void Run() { // ExStart:TiffOptionsConfiguration // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load an image through file path location or stream using (Image image = Image.Load(dataDir + "SampleTiff1.tiff")) { // Create an instance of TiffOptions while specifying desired format Passsing TiffExpectedFormat.TiffJpegRGB will set the compression to Jpeg and BitsPerPixel according to the RGB color space. TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffJpegRgb); image.Save(dataDir + "SampleTiff_out.tiff", options); } // ExEnd:TiffOptionsConfiguration }
public static void Run() { //ExStart:TiffOptionsConfiguration // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load an image through file path location or stream using (Image image = Image.Load(dataDir + "SampleTiff1.tiff")) { // Create an instance of TiffOptions while specifying desired format Passsing TiffExpectedFormat.TiffJpegRGB will set the compression to Jpeg and BitsPerPixel according to the RGB color space. TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffJpegRgb); image.Save(dataDir + "SampleTiff_out.tiff", options); } //ExEnd:TiffOptionsConfiguration }
public static void Run() { Console.WriteLine("Running example SupportTiffDeflate"); string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); string sourceFileName = "FromRasterImageEthalon.psd"; string outputfile = "result.tiff"; //Export png with alpha channel to tiff using (Image image = Image.Load(dataDir + "sample.png")) { TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffDeflateRgba); image.Save(outputfile, options); } Console.WriteLine("Finished example SupportTiffDeflate"); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_DjVu(); // Load a DjVu image using (DjvuImage image = (DjvuImage)Image.Load(dataDir + "Sample.djvu")) { // Create an instance of TiffOptions & use preset options for Black n While with Deflate compression TiffOptions exportOptions = new TiffOptions(TiffExpectedFormat.TiffDeflateBw); // Initialize the DjvuMultiPageOptions exportOptions.MultiPageOptions = new DjvuMultiPageOptions(); // Call Save method while passing instance of TiffOptions image.Save(dataDir + "ConvertDjVuToTIFFFormat_out.tiff", exportOptions); } }
public static void Run() { //ExStart:SupportTiffDeflate string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); string sourceFileName = "FromRasterImageEthalon.psd"; string outputfile = "result.tiff"; //Export png with alpha channel to tiff using (Image image = Image.Load(dataDir + "Alpha.png")) { TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffDeflateRgba); image.Save(outputfile, options); } //ExEnd:SupportTiffDeflate }
public static void Run() { //ExStart:TiffOptionsConfiguration // The path to the documents directory. string dataDir = RunExamples.GetDataDir_PSD(); // Load a PSD file as an image and cast it into PsdImage using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "layers.psd")) { // Create an instance of TiffOptions while specifying desired format Passsing TiffExpectedFormat.TiffJpegRGB will set the compression to Jpeg and BitsPerPixel according to the RGB color space. TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffJpegRgb); psdImage.Save(dataDir + "SampleTiff_out.tiff", options); } //ExEnd:TiffOptionsConfiguration }
public static void Run() { Console.WriteLine("Running example AddFramesToTIFFImage"); // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default); outputSettings.BitsPerSample = new ushort[] { 1 }; outputSettings.Compression = TiffCompressions.CcittFax3; outputSettings.Photometric = TiffPhotometrics.MinIsWhite; outputSettings.Source = new StreamSource(new MemoryStream()); int newWidth = 500; int newHeight = 500; string path = dataDir + "AddFramesToTIFFImage_out.tif"; using (TiffImage tiffImage = (TiffImage)Image.Create(outputSettings, newWidth, newHeight)) { int index = 0; foreach (var file in Directory.GetFiles(dataDir, "*.jpg")) { using (RasterImage ri = (RasterImage)Image.Load(file)) { ri.Resize(newWidth, newHeight, ResizeType.NearestNeighbourResample); TiffFrame frame = tiffImage.ActiveFrame; if (index > 0) { frame = new TiffFrame(new TiffOptions(outputSettings) /*ensure options are cloned for each frame*/, newWidth, newHeight); // If there is a TIFF image loaded you need to enumerate the frames and perform the following // Frame = TiffFrame.CreateFrameFrom(sourceFrame, outputSettings); } frame.SavePixels(frame.Bounds, ri.LoadPixels(ri.Bounds)); if (index > 0) { tiffImage.AddFrame(frame); } index++; } } tiffImage.Save(path); } Console.WriteLine("Finished example AddFramesToTIFFImage"); }
public static void Run() { //ExStart:ConvertWithNoteToTiff // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Conversion(); // Instantiate a Presentation object that represents a presentation file using (Presentation pres = new Presentation(dataDir + "ConvertWithNoteToTiff.pptx")) { TiffOptions opts = new TiffOptions(); INotesCommentsLayoutingOptions notesOptions = opts.NotesCommentsLayouting; notesOptions.NotesPosition = NotesPositions.BottomFull; // Saving the presentation to TIFF notes pres.Save(dataDir + "TestNotes_out.tiff", SaveFormat.Tiff, opts); } //ExEnd:ConvertWithNoteToTiff }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); TiffOptions outputSettings = new TiffOptions(); outputSettings.BitsPerSample = new ushort[] { 1 }; outputSettings.Compression = TiffCompressions.CcittFax3; outputSettings.Photometric = TiffPhotometrics.MinIsWhite; outputSettings.Source = new StreamSource(new MemoryStream()); int newWidth = 500; int newHeight = 500; string path = dataDir + "output.tif"; using (TiffImage tiffImage = (TiffImage)Image.Create(outputSettings, newWidth, newHeight)) { int index = 0; foreach (var file in Directory.GetFiles(dataDir, "*.jpg")) { using (RasterImage ri = (RasterImage)Image.Load(file)) { ri.Resize(newWidth, newHeight, ResizeType.NearestNeighbourResample); TiffFrame frame = tiffImage.ActiveFrame; if (index > 0) { frame = new TiffFrame(new TiffOptions(outputSettings) /*ensure options are cloned for each frame*/, newWidth, newHeight); // If there is a TIFF image loaded you need to enumerate the frames and perform the following // frame = TiffFrame.CreateFrameFrom(sourceFrame, outputSettings); } frame.SavePixels(frame.Bounds, ri.LoadPixels(ri.Bounds)); if (index > 0) { tiffImage.AddFrame(frame); } index++; } } tiffImage.Save(path); } }
public static void Run() { //ExStart:TIFFwithDeflateCompression // The path to the documents directory. string dataDir = RunExamples.GetDataDir_PSD(); // Load a PSD file as an image and cast it into PsdImage using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "layers.psd")) { // Create an instance of TiffOptions while specifying desired format and compression TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffDeflateRgb); options.Compression = TiffCompressions.AdobeDeflate; psdImage.Save(dataDir + "TIFFwithDeflateCompression_out.tiff", options); } //ExEnd:TIFFwithDeflateCompression }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_DjVu(); // Load a DjVu image using (DjvuImage image = (DjvuImage)Image.Load(dataDir + "Sample.djvu")) { // Create an instance of TiffOptions with preset options TiffOptions exportOptions = new TiffOptions(TiffExpectedFormat.TiffDeflateBw); // Create an instance of IntRange and initialize it with range of pages to be exported IntRange range = new IntRange(0, 2); //Export first 2 pages // Initialize an instance of DjvuMultiPageOptions while passing instance of IntRange exportOptions.MultiPageOptions = new DjvuMultiPageOptions(range); // Call Save method while passing instance of TiffOptions image.Save(dataDir + "ConvertRangeOfDjVuPages_out.djvu", exportOptions); } }
public static void Run() { // ExStart:ConvertDjVuToTIFF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_DjVu(); // Load a DjVu image using (DjvuImage image = (DjvuImage)Image.Load(dataDir + "Sample.djvu")) { // Create an instance of TiffOptions & use preset options for Black n While with Deflate compression TiffOptions exportOptions = new TiffOptions(TiffExpectedFormat.TiffDeflateBw); // Initialize the DjvuMultiPageOptions and Call Save method while passing instance of TiffOptions exportOptions.MultiPageOptions = new DjvuMultiPageOptions(); image.Save(dataDir + "ConvertDjVuToTIFFFormat_out.tiff", exportOptions); } // ExEnd:ConvertDjVuToTIFF }
public static void Run() { // ExStart:ConvertRangeOfDjVuPages // The path to the documents directory. string dataDir = RunExamples.GetDataDir_DjVu(); // Load a DjVu image using (DjvuImage image = (DjvuImage)Image.Load(dataDir + "Sample.djvu")) { // Create an instance of TiffOptions with preset options and IntRange and initialize it with range of pages to be exported TiffOptions exportOptions = new TiffOptions(TiffExpectedFormat.TiffDeflateBw); IntRange range = new IntRange(0, 2); // Initialize an instance of DjvuMultiPageOptions while passing instance of IntRange and Call Save method while passing instance of TiffOptions exportOptions.MultiPageOptions = new DjvuMultiPageOptions(range); image.Save(dataDir + "ConvertRangeOfDjVuPages_out.djvu", exportOptions); } // ExEnd:ConvertRangeOfDjVuPages }
public static void Run() { // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); // ExStart:TiffOptionsConfiguration // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load an image through file path location or stream using (Image image = Image.Load(dataDir + "SampleTiff1.tiff")) { // Create an instance of TiffOptions while specifying desired format // Passsing TiffExpectedFormat.TiffJpegRGB will set the compression to Jpeg // And BitsPerPixel according to the RGB color space TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffJpegRgb); // Save the result in Tiff format RGB with Jpeg compression image.Save(dataDir + "SampleTiff_out.tiff", options); } // ExEnd:TiffOptionsConfiguration }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_PSD(); //ExStart:TIFFwithAdobeDeflateCompression // Create an instance of TiffOptions and set its various properties TiffOptions options = new TiffOptions(TiffExpectedFormat.Default); options.BitsPerSample = new ushort[] { 8, 8, 8 }; options.Photometric = TiffPhotometrics.Rgb; options.Xresolution = new TiffRational(72); options.Yresolution = new TiffRational(72); options.ResolutionUnit = TiffResolutionUnits.Inch; options.PlanarConfiguration = TiffPlanarConfigs.Contiguous; // Set the Compression to AdobeDeflate options.Compression = TiffCompressions.AdobeDeflate; //Create a new image with specific size and TiffOptions settings using (PsdImage image = new PsdImage(100, 100)) { // Fill image data. int count = image.Width * image.Height; int[] pixels = new int[count]; for (int i = 0; i < count; i++) { pixels[i] = Color.Red.ToArgb(); } // Save the newly created pixels. image.SaveArgb32Pixels(image.Bounds, pixels); // Save resultant image image.Save(dataDir + "TIFFwithAdobeDeflateCompression_output.tif", options); } //ExEnd:TIFFwithAdobeDeflateCompression }
public static void Run() { // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default); outputSettings.BitsPerSample = new ushort[] { 1 }; outputSettings.Compression = TiffCompressions.CcittFax3; outputSettings.Photometric = TiffPhotometrics.MinIsWhite; outputSettings.Source = new StreamSource(new MemoryStream()); int newWidth = 500; int newHeight = 500; string path = dataDir + "AddFramesToTIFFImage_out.tif"; using (TiffImage tiffImage = (TiffImage)Image.Create(outputSettings, newWidth, newHeight)) { int index = 0; foreach (var file in Directory.GetFiles(dataDir, "*.jpg")) { using (RasterImage ri = (RasterImage)Image.Load(file)) { ri.Resize(newWidth, newHeight, ResizeType.NearestNeighbourResample); TiffFrame frame = tiffImage.ActiveFrame; if (index > 0) { frame = new TiffFrame(new TiffOptions(outputSettings) /*ensure options are cloned for each frame*/, newWidth, newHeight); // If there is a TIFF image loaded you need to enumerate the frames and perform the following // Frame = TiffFrame.CreateFrameFrom(sourceFrame, outputSettings); } frame.SavePixels(frame.Bounds, ri.LoadPixels(ri.Bounds)); if (index > 0) { tiffImage.AddFrame(frame); } index++; } } tiffImage.Save(path); } }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_PSD(); //ExStart:PSDToRasterImageFormats String srcPath = dataDir + @"sample.psd"; string destName = dataDir + @"export"; // Load an existing PSD image as Image using (Image image = Image.Load(srcPath)) { // Create an instance of PngOptions class PngOptions pngOptions = new PngOptions(); // Create an instance of BmpOptions class BmpOptions bmpOptions = new BmpOptions(); // Create an instance of TiffOptions class TiffOptions tiffOptions = new TiffOptions(FileFormats.Tiff.Enums.TiffExpectedFormat.Default); // Create an instance of GifOptions class GifOptions gifOptions = new GifOptions(); // Create an instance of JpegOptions class JpegOptions jpegOptions = new JpegOptions(); // Create an instance of Jpeg2000Options class Jpeg2000Options jpeg2000Options = new Jpeg2000Options(); // Call the save method, provide output path and export options to convert PSD file to various raster file formats. image.Save(destName + ".png", pngOptions); image.Save(destName + ".bmp", bmpOptions); image.Save(destName + ".tiff", tiffOptions); image.Save(destName + ".gif", gifOptions); image.Save(destName + ".jpeg", jpegOptions); image.Save(destName + ".jp2", jpeg2000Options); } //ExEnd:PSDToRasterImageFormats }
public static void Run() { Console.WriteLine("Running example CompressingTIFFImagesWithLZWAlgorithm"); // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load an image through file path location or stream Image image = Image.Load(dataDir + "SampleTiff.tiff"); // Create an instance of TiffOptions for the resultant image TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default); // Set BitsPerSample, Compression, Photometric mode and graycale palette outputSettings.BitsPerSample = new ushort[] { 4 }; outputSettings.Compression = TiffCompressions.Lzw; outputSettings.Photometric = TiffPhotometrics.Palette; outputSettings.Palette = ColorPaletteHelper.Create4BitGrayscale(false); image.Save(dataDir + "SampleTiff_out.tiff", outputSettings); Console.WriteLine("Finished example CompressingTIFFImagesWithLZWAlgorithm"); }
public static void Run() { // ExStart:CompressingTIFFImagesWithLZWAlgorithm // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load an image through file path location or stream Image image = Image.Load(dataDir + "SampleTiff.tiff"); // Create an instance of TiffOptions for the resultant image TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default); // Set BitsPerSample, Compression, Photometric mode and graycale palette outputSettings.BitsPerSample = new ushort[] { 4 }; outputSettings.Compression = TiffCompressions.Lzw; outputSettings.Photometric = TiffPhotometrics.Palette; outputSettings.Palette = ColorPaletteHelper.Create4BitGrayscale(false); image.Save(dataDir + "SampleTiff_out.tiff", outputSettings); // ExEnd:CompressingTIFFImagesWithLZWAlgorithm }
public static void Run() { // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); // ExStart:CompressingTIFFImagesWithAdobeDeflateCompression // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load an image through file path location or stream Image image = Image.Load(dataDir + "SampleTiff1.tiff"); // Create an instance of TiffOptions for the resultant image TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default); // Set BitsPerSample, Photometric mode & Compression mode outputSettings.BitsPerSample = new ushort[] { 4 }; outputSettings.Compression = TiffCompressions.AdobeDeflate; outputSettings.Photometric = TiffPhotometrics.Palette; // Set graycale palette outputSettings.Palette = ColorPaletteHelper.Create4BitGrayscale(false); // ExEnd:CompressingTIFFImagesWithAdobeDeflateCompression }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Conversion(); // Instantiate a Presentation object that represents a Presentation file using (Presentation pres = new Presentation(dataDir + "Convert_Tiff_Custom.pptx")) { // Instantiate the TiffOptions class TiffOptions opts = new TiffOptions(); // Setting compression type opts.CompressionType = TiffCompressionTypes.Default; // Compression Types // Default - Specifies the default compression scheme (LZW). // None - Specifies no compression. // CCITT3 // CCITT4 // LZW // RLE // Depth depends on the compression type and cannot be set manually. // Resolution unit is always equal to “2” (dots per inch) // Setting image DPI opts.DpiX = 200; opts.DpiY = 100; // Set Image Size opts.ImageSize = new Size(1728, 1078); // Save the presentation to TIFF with specified image size pres.Save(dataDir + "TiffWithCustomSize_out.tiff", SaveFormat.Tiff, opts); } }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Conversion(); // Instantiate a Presentation object that represents a Presentation file using (Presentation presentation = new Presentation(dataDir + "DemoFile.pptx")) { TiffOptions options = new TiffOptions(); options.PixelFormat = ImagePixelFormat.Format8bppIndexed; /* ImagePixelFormat contains the following values (as could be seen from documentation): Format1bppIndexed; // 1 bits per pixel, indexed. Format4bppIndexed; // 4 bits per pixel, indexed. Format8bppIndexed; // 8 bits per pixel, indexed. Format24bppRgb; // 24 bits per pixel, RGB. Format32bppArgb; // 32 bits per pixel, ARGB. */ // Save the presentation to TIFF with specified image size presentation.Save(dataDir + "Tiff_With_Custom_Image_Pixel_Format_out.tiff", SaveFormat.Tiff, options); } }
public static void Run() { // ExStart:ReadAndWriteXMPDataToImages // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Specify the size of image by defining a Rectangle Rectangle rect = new Rectangle(0, 0, 100, 200); TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.TiffJpegRgb); tiffOptions.Photometric = TiffPhotometrics.MinIsBlack; tiffOptions.BitsPerSample = new ushort[] { 8 }; // Create the brand new image just for sample purposes using (var image = new TiffImage(new TiffFrame(tiffOptions, rect.Width, rect.Height))) { // Create an instance of XMP-Header XmpHeaderPi xmpHeader = new XmpHeaderPi(Guid.NewGuid().ToString()); // Create an instance of Xmp-TrailerPi, XMPmeta class to set different attributes XmpTrailerPi xmpTrailer = new XmpTrailerPi(true); XmpMeta xmpMeta = new XmpMeta(); xmpMeta.AddAttribute("Author", "Mr Smith"); xmpMeta.AddAttribute("Description", "The fake metadata value"); // Create an instance of XmpPacketWrapper that contains all metadata XmpPacketWrapper xmpData = new XmpPacketWrapper(xmpHeader,xmpTrailer, xmpMeta); // Create an instacne of Photoshop package and set photoshop attributes PhotoshopPackage photoshopPackage = new PhotoshopPackage(); photoshopPackage.SetCity("London"); photoshopPackage.SetCountry("England"); photoshopPackage.SetColorMode(ColorMode.Rgb); photoshopPackage.SetCreatedDate(DateTime.UtcNow); // Add photoshop package into XMP metadata xmpData.AddPackage(photoshopPackage); // Create an instacne of DublinCore package and set dublinCore attributes DublinCorePackage dublinCorePackage = new DublinCorePackage(); dublinCorePackage.SetAuthor("Charles Bukowski"); dublinCorePackage.SetTitle("Confessions of a Man Insane Enough to Live With the Beasts"); dublinCorePackage.AddValue("dc:movie", "Barfly"); // Add dublinCore Package into XMP metadata xmpData.AddPackage(dublinCorePackage); using (var ms = new MemoryStream()) { // Update XMP metadata into image and Save image on the disk or in memory stream image.XmpData = xmpData; image.Save(ms); ms.Seek(0, System.IO.SeekOrigin.Begin); // Load the image from moemory stream or from disk to read/get the metadata using (var img = (TiffImage)Image.Load(ms)) { // Getting the XMP metadata XmpPacketWrapper imgXmpData = img.XmpData; foreach (XmpPackage package in imgXmpData.Packages) { // Use package data ... } } } } }