Load, edit, and save image files on Linux or macOS

GemBox.Imaging is a standalone .NET component with cross-platform support. This means developers can use it on non-Windows platforms like Linux and macOS.

The following example shows how to load and edit image files using GemBox.Imaging on Linux (Ubuntu).

Prerequisites

After installing the requirements listed above you can follow these steps using Visual Studio Code (VS Code) to create a simple Console project and a C# code that generates DOCX and PDF files.

1. Open a project folder

  • Open VS Code.
  • Click "Open Folder" on the EXPLORER panel.
  • Select the folder you want your console project to be in, in our case the GemBoxExample folder.
Selecting the folder you want your console project to be in
Screenshot of Visual Studio Code folder selection

2. Create a new console project

  • Open the Integrated Terminal in VS Code by clicking "View" > "Terminal" or using the CTRL + ` shortcut.
  • In the terminal window, execute the following command: dotnet new console
  • This command will create a code file (Program.cs) and a project file (GemBoxExample.csproj) inside the opened folder.
Creating a C# console project
Screenshot of Visual Studio Code new console command

3. Edit project files

  • Add a reference to GemBox.Imaging and its dependencies in GemBoxExample.csproj file:
    <ItemGroup>
      <PackageReference Include="GemBox.Imaging" Version="*" />
      <PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="*" />
    </ItemGroup>
  • Edit C# code in Program.cs file:
    using GemBox.Imaging;
    
    class Program
    {
        static void Main()
        {
            // If using the Professional version, put your serial key below.
            ComponentInfo.SetLicense("FREE-LIMITED-KEY");
    
            using (var image = Image.Load("FragonardReader.jpg"))
            {
                image.Resize(64, 64);
                image.Save("Resized.png");
            }
        }
    }
    
    Imports GemBox.Imaging
    
    Module Program
    
        Sub Main()
    
            ' If using the Professional version, put your serial key below.
            ComponentInfo.SetLicense("FREE-LIMITED-KEY")
    
            Using image As Image = Image.Load("FragonardReader.jpg")
                image.Resize(64, 64)
                image.Save("Resized.png")
            End Using
    
        End Sub
    
    End Module
    

4. Run the console project

  • In the terminal window, execute the following command: dotnet run
  • This command will run your Console application and load, edit, save image files that you can open in any image application.
Running a C# console project
Screenshot of Visual Studio Code run command

See also


Next steps

GemBox.Imaging is a .NET component that provides an easy way to load, edit, save images. GemBox.Imaging also supports file format conversions and image transformations (resize, crop, rotate and flip).

Download Buy