
Converteer TIFF naar JPG-afbeelding in C #
- [TIFF naar JPG conversie bibliotheek installatie][5]
- [Converteer TIFF naar JPG-afbeelding in C#][6]
Installatie van TIFF naar JPG-conversiebibliotheek
In dit gedeelte wordt de installatieprocedure van deze .NET-bibliotheek gedemonstreerd. Dus, [download][7] de DLL of installeer deze bibliotheek door de volgende opdracht uit te voeren in de [NuGet][8] pakketbeheerder.
Install-Package Aspose.Imaging
Converteer TIFF naar JPG-afbeelding in C
Om TIFF naar JPG-conversie te implementeren, kunt u de onderstaande stappen en het onderstaande codefragment volgen: Volg de onderstaande stappen en het onderstaande codefragment:
- Roep de methode [Image.Load][9] aan om het TIFF-afbeeldingsbestand te laden en wijs het toe aan de instantie van de klasse [TiffImage][10].
- Doorloop de [frames][11] van de TIFF-afbeelding.
- Initialiseer een instantie van de klasse [JpegOptions][12].
- Maak een object van de klasse [ResolutionSetting][13] om de resolutie in te stellen voor opties voor het opslaan van afbeeldingen.
- Stel de resolutie-eenheid expliciet in door de waarde van de eigenschap [ResolutionUnit][14] in te stellen.
- Gebruik de methode [save][15] om de TIFF-afbeelding op te slaan in de JPG-afbeeldingsindeling.
Kopieer en plak de volgende code in uw hoofdbestand:
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
using Aspose.Imaging; using Aspose.Imaging.Exif; using Aspose.Imaging.Exif.Enums; using Aspose.Imaging.FileFormats.Bmp; using Aspose.Imaging.FileFormats.Dicom; using Aspose.Imaging.FileFormats.Djvu; using Aspose.Imaging.FileFormats.Emf; using Aspose.Imaging.FileFormats.Eps; using Aspose.Imaging.FileFormats.Eps.Consts; using Aspose.Imaging.FileFormats.Gif; using Aspose.Imaging.FileFormats.Gif.Blocks; using Aspose.Imaging.FileFormats.Jpeg; using Aspose.Imaging.FileFormats.Jpeg2000; using Aspose.Imaging.FileFormats.Pdf; using Aspose.Imaging.FileFormats.Png; using Aspose.Imaging.FileFormats.Psd; using Aspose.Imaging.FileFormats.Svg; using Aspose.Imaging.FileFormats.Tga; using Aspose.Imaging.FileFormats.Tiff.Enums; using Aspose.Imaging.ImageFilters.FilterOptions; using Aspose.Imaging.ImageOptions; using Aspose.Imaging.Sources; using Aspose.Imaging.Xmp; using Aspose.Imaging.Xmp.Schemas.Dicom; using System; using System.IO; using System.Linq; using System.Reflection; using System.Threading.Tasks; // Invoke the Image.Load method to load the TIFF image file and assign it to the image of the TiffImage class. using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Load("sample.tiff")) { // Loop through the frames of the TIFF image. int i = 0; foreach (Aspose.Imaging.FileFormats.Tiff.TiffFrame tiffFrame in tiffImage.Frames) { // Initialize an instance of the JpegOptions class. Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions(); // Create an object of the ResolutionSetting class to set the resolution for image save options. saveOptions.ResolutionSettings = new ResolutionSetting(tiffFrame.HorizontalResolution, tiffFrame.VerticalResolution); if (tiffFrame.FrameOptions != null) { // Set the resolution unit explicitly by setting the value of the ResolutionUnit property. switch (tiffFrame.FrameOptions.ResolutionUnit) { case Aspose.Imaging.FileFormats.Tiff.Enums.TiffResolutionUnits.None: saveOptions.ResolutionUnit = ResolutionUnit.None; break; case Aspose.Imaging.FileFormats.Tiff.Enums.TiffResolutionUnits.Inch: saveOptions.ResolutionUnit = ResolutionUnit.Inch; break; case Aspose.Imaging.FileFormats.Tiff.Enums.TiffResolutionUnits.Centimeter: saveOptions.ResolutionUnit = ResolutionUnit.Cm; break; default: throw new System.NotSupportedException(); } } // Invoke the save method to save the TIFF image to the JPG image format. tiffFrame.Save( "tiff-to-jpg.jpg", saveOptions); } }
Ontvang een gratis licentie
U kunt gebruik maken van een [gratis tijdelijke licentie][16] om de API zonder evaluatiebeperkingen uit te proberen.
Opsommen
Hiermee zijn we aan het einde van deze blogpost gekomen. Ik hoop dat je hebt geleerd hoe je TIFF programmatisch converteert naar JPG-afbeelding in C#. Deze TIFF naar JPG-conversie-bibliotheek biedt vele andere methoden. Verder kunt u de [documentatie][17] bezoeken om kennis te maken met andere functies. Bovendien raden we u aan onze [Aan de slag-gids][18] te volgen. Ten slotte schrijft [conholdate.com][19] nieuwe blogposts. Blijf dus in contact voor regelmatige updates.
Een vraag stellen
U kunt uw vragen of opmerkingen aan ons doorgeven op ons [forum][20].
Veelgestelde vragen
Hoe converteer ik TIFF naar JPG in C#? Volg deze [link][6] voor meer informatie over de TIFF naar JPG-conversie in C#.
Zie ook
- [Een miniatuur maken van een JPG-afbeelding in C#][21]
- [GIF converteren naar PNG in C#][22] [1]: https://blog.conholdate.com/nl/total/how-to-convert-jpg-to-tiff-in-csharp/ [2]: https://docs.fileformat.com/image/tiff/ [3]: https://docs.fileformat.com/image/jpeg/ [4]: https://products.aspose.com/imaging/net/ [5]: #TIFF-to-JPG-conversion-library [6]: #Convert-TIFF-to-JPG-image-in-Csharp [7]: https://releases.aspose.com/imaging [8]: https://www.nuget.org/packages/Aspose.Imaging [9]: https://reference.aspose.com/imaging/net/aspose.imaging/image/ [10]: https://reference.aspose.com/imaging/net/aspose.imaging.fileformats.tiff/tiffimage/tiffimage/ [11]: https://reference.aspose.com/imaging/net/aspose.imaging.fileformats.tiff/tiffimage/frames/ [12]: https://reference.aspose.com/imaging/net/aspose.imaging.imageoptions/jpegoptions/ [13]: https://reference.aspose.com/imaging/net/aspose.imaging/resolutionsetting/ [14]: https://reference.aspose.com/imaging/net/aspose.imaging/resolutionunit/ [15]: https://reference.aspose.com/imaging/net/aspose.imaging/image/save/#imagesave-method-3-of-6 [16]: https://purchase.conholdate.com/temporary-license [17]: https://docs.aspose.com/imaging/net/ [18]: https://docs.aspose.com/imaging/net/getting-started/ [19]: https://conholdate.com/ [20]: https://forum.conholdate.com/ [21]: https://blog.conholdate.com/nl/total/how-to-make-a-thumbnail-from-jpg-image-in-csharp/ [22]: https://blog.conholdate.com/nl/total/how-to-convert-gif-to-png-in-csharp/