Skip to content

Instantly share code, notes, and snippets.

View aspose-com-kb's full-sized avatar

aspose-com-kb

View GitHub Profile
@aspose-com-kb
aspose-com-kb / Convert GIF to WEBP in Python.py
Created September 1, 2025 17:46
Convert GIF to WEBP in Python.
import aspose.imaging as imaging
import aspose.pycore as apc
from aspose.imaging import Image, License
from aspose.imaging.fileformats.gif import GifImage
from aspose.imaging.imageoptions import WebPOptions
try:
# Activate Aspose.Imaging license
license = License()
license.set_license("license.lic")
@aspose-com-kb
aspose-com-kb / Draw Rectangle in Java.java
Created August 29, 2025 12:07
Draw Rectangle in Java.
// Initialize a Bitmap class object
com.aspose.drawing.Bitmap bitmap = new com.aspose.drawing.Bitmap(1000, 800, com.aspose.drawing.imaging.PixelFormat.Format32bppPArgb);
com.aspose.drawing.Graphics graphics = com.aspose.drawing.Graphics.fromImage(bitmap);
// Create a Pen class instance
com.aspose.drawing.Pen pen = new com.aspose.drawing.Pen(com.aspose.drawing.Color.fromKnownColor(com.aspose.drawing.KnownColor.Blue), 2);
// Draw the rectangle
graphics.drawRectangle(pen, 10, 10, 900, 700);
@aspose-com-kb
aspose-com-kb / Draw Rectangle in C#.cs
Last active August 29, 2025 12:06
Draw Rectangle in C#.
// Initialize a Bitmap class object
Aspose.Drawing.Bitmap bitmap = new Aspose.Drawing.Bitmap(1000, 800, Aspose.Drawing.Imaging.PixelFormat.Format32bppPArgb);
Aspose.Drawing.Graphics graphics = Aspose.Drawing.Graphics.FromImage(bitmap);
// Create a Pen class instance
Aspose.Drawing.Pen pen = new Aspose.Drawing.Pen(Aspose.Drawing.Color.FromKnownColor(Aspose.Drawing.KnownColor.Blue), 2);
// Draw the rectangle
graphics.DrawRectangle(pen, 10, 10, 900, 700);
@aspose-com-kb
aspose-com-kb / Convert GIF to WEBP.java
Created August 27, 2025 13:22
Convert GIF to WEBP in Java.
import com.aspose.imaging.Image;
//import com.aspose.imaging.License;
import com.aspose.imaging.imageoptions.WebPOptions;
public class ConvertGifToWebp {
public static void main(String[] args) {
try {
// Apply the Aspose.Imaging license
//License license = new License();
//license.setLicense("license.lic");
@aspose-com-kb
aspose-com-kb / Convert GIF to WEBP in C#.cs
Created August 26, 2025 19:07
Convert GIF to WEBP in C#.
using System;
using Aspose.Imaging;
using Aspose.Imaging.ImageOptions;
class Program
{
static void Main()
{
License license = new License();
license.SetLicense("license.lic");
@aspose-com-kb
aspose-com-kb / Create WEBP Image.py
Created August 26, 2025 02:56
Create WEBP in Python.
import aspose.imaging as imaging
from aspose.imaging import Image, Color, Graphics, License, Pen
from aspose.imaging.imageoptions import WebPOptions
from aspose.imaging.sources import FileCreateSource
from aspose.imaging.brushes import SolidBrush
# Load license (optional but recommended)
license = License()
license.set_license("license.lic")
@aspose-com-kb
aspose-com-kb / Create WEBP in Java.java
Created August 22, 2025 03:59
Create WEBP in Java.
import com.aspose.imaging.Color;
import com.aspose.imaging.Graphics;
import com.aspose.imaging.Image;
import com.aspose.imaging.License;
import com.aspose.imaging.Pen;
import com.aspose.imaging.brushes.SolidBrush;
import com.aspose.imaging.imageoptions.WebPOptions;
import com.aspose.imaging.sources.FileCreateSource;
public class CreateWebPShapes {
@aspose-com-kb
aspose-com-kb / Convert Base64 to PDF.java
Created August 22, 2025 02:46
Convert Base64 to PDF in Java.
FileInputStream fis = new FileInputStream(dataDir + "Base64.txt");
String base64 = IOUtils.toString(fis, "UTF-8");
String base64ImageString = base64.replace("data:image/png;base64,", "");
byte[] imageBytes = java.util.Base64.getDecoder().decode(base64ImageString);
String path = dataDir + "Base64 to Image.png";
// Convert Base64 to PNG or JPG Image
FileOutputStream fos = new FileOutputStream(path);
try {
fos.write(imageBytes);
@aspose-com-kb
aspose-com-kb / Convert Base64 to PDF in C#.cs
Created August 22, 2025 02:44
Convert Base64 to PDF in C#.
// Define the file paths
string base64FilePath = dataDir + "Base64.txt";
string pdfOutputPath = dataDir + "Base64_to_PDF.pdf";
// Read the Base64 string from the file
string base64 = File.ReadAllText(base64FilePath, Encoding.UTF8);
string base64ImageString = base64.Replace("data:image/png;base64,", "");
// Decode the Base64 string to byte array
byte[] imageBytes = Convert.FromBase64String(base64ImageString);
@aspose-com-kb
aspose-com-kb / Create WEBP in C#.cs
Created August 20, 2025 17:30
Create WEBP in C#.
using Aspose.Imaging;
using Aspose.Imaging.Brushes;
using Aspose.Imaging.ImageOptions;
using Aspose.Imaging.Sources;
License licence = new License();
licence.SetLicense("license.lic");
var imageOptions = new WebPOptions
{