Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
GIF es un formato de imagen popular que se utiliza con frecuencia en la publicación web. Con Aspose.HTML for .NET, puede convertir EPUB a formato GIF mediante programación con control total sobre una amplia gama de parámetros de conversión. En este artículo, encontrará información sobre cómo convertir EPUB a GIF usando los métodos ConvertEPUB() de la clase Converter y cómo aplicar ImageSaveOptions y parámetros ICreateStreamProvider.
Puede comprobar la funcionalidad de la API Aspose.HTML for .NET y convertir EPUB en tiempo real. Cargue un archivo EPUB desde el sistema de archivos local, seleccione el formato de salida y ejecute el ejemplo. En el ejemplo, las opciones de guardar están configuradas de forma predeterminada. Recibirá inmediatamente el resultado en un archivo separado.
Si desea convertir EPUB a GIF mediante programación, consulte los siguientes ejemplos de código C#.
Usar los métodos Converter.ConvertEPUB() es la forma más común de convertir archivos EPUB a varios formatos. Debes seguir algunos pasos:
Eche un vistazo al siguiente fragmento de código C# que muestra el proceso de conversión de EPUB a GIF usando Aspose.HTML for .NET.
1// Convert EPUB to GIF using C#
2
3// Open an existing EPUB file for reading
4using FileStream stream = File.OpenRead(DataDir + "input.epub");
5
6// Prepare a path to save the converted file
7string savePath = Path.Combine(OutputDir, "input-output.gif");
8
9// Create an instance of the ImageSaveOptions class
10ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Gif);
11
12// Call the ConvertEPUB() method to convert EPUB to GIF
13Converter.ConvertEPUB(stream, options, savePath);Puede descargar los ejemplos completos y los archivos de datos desde GitHub.
Aspose.HTML permite convertir EPUB a GIF utilizando opciones de guardado predeterminadas o personalizadas. El uso de ImageSaveOptions le permite ajustar el proceso de renderizado. Puede especificar el tamaño de la página, los márgenes, la resolución horizontal/vertical, etc.
| Property | Description |
|---|---|
| Compression | Sets Tagged Image File Format (TIFF) Compression. By default, this property is LZW. |
| CSS | Gets a CssOptions object which is used for configuration of CSS properties processing. |
| Format | Sets the ImageFormat (JPG, PNG, BMP, TIFF, or GIF). By default, this property is PNG. |
| BackgroundColor | This property sets the color that will fill the background. By default, this property is Transparent. |
| PageSetup | This property gets a page setup object and uses it for configuration output page-set. |
| HorizontalResolution | Sets horizontal resolution for output images in pixels per inch. The default value is 300 dpi. |
| VerticalResolution | Sets vertical resolution for output images in pixels per inch. The default value is 300 dpi. |
| UseAntialiasing | This property sets the image rendering quality. Antialiasing is enabled by default. |
| Text | Gets a TextOptions object which is used for configuration of text rendering. |
Para obtener más información sobre la clase ImageSaveOptions, lea el artículo Convertidores de ajuste fino.
Para convertir EPUB a GIF especificando ImageSaveOptions, debe seguir algunos pasos:
El siguiente fragmento de código C# muestra cómo convertir EPUB a GIF usando opciones de guardado personalizadas:
1// Convert EPUB to GIF in C# with custom settings
2
3// Open an existing EPUB file for reading
4using FileStream stream = File.OpenRead(DataDir + "input.epub");
5
6// Prepare a path for converted file saving
7string savePath = Path.Combine(OutputDir, "input-options.gif");
8
9// Initialize ImageSaveOptions
10ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Gif)
11{
12 UseAntialiasing = true,
13 HorizontalResolution = 400,
14 VerticalResolution = 400,
15 BackgroundColor = System.Drawing.Color.AliceBlue
16};
17options.PageSetup.AnyPage = new Page(new Aspose.Html.Drawing.Size(800, 500), new Margin(30, 20, 10, 10));
18
19// Call the ConvertEPUB() method to convert EPUB to GIF
20Converter.ConvertEPUB(stream, options, savePath);El constructor
ImageSaveOptions() inicializa una instancia de la clase ImageSaveOptions que se pasa al método ConvertEPUB(). El método ConvertEPUB() toma la stream, las options, la ruta del archivo de salida savePath y realiza la operación de conversión.
En el ejemplo usamos:
HorizontalResolution y VerticalResolution que establecen la resolución horizontal/vertical para las imágenes de salida en píxeles por pulgada. De forma predeterminada, estas propiedades son 300 ppp.UseAntialiasing que establece la calidad de renderizado de esta imagen.BackgroundColor que especifica el color con el que se rellenará el fondo. El BackgroundColor predeterminado es Transparente.PageSetup que especifica el
page size y los
margins en píxeles.Puede descargar los ejemplos completos y los archivos de datos desde GitHub.
Aspose.HTML ofrece un Convertidor de EPUB a GIF gratuito en línea que convierte imágenes EPUB a GIF con alta calidad, fácil y rápido. ¡Simplemente cargue, convierta sus archivos y obtenga resultados en unos segundos!
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.