ImageGlass tools

ImageGlass provides an API for third-party app integration. By utilizing the ImageGlass.Tools library, developers can expand the functionality of ImageGlass, creating a highly customizable and versatile tool for all image viewing needs.

You can download tools for ImageGlass 9 at: https://imageglass.org/tools.

Build tools for ImageGlass

Prerequisites:

  • IDE: Visual Studio 2022
  • Programming language: C#
  • .NET 6 or above

Follow these simple steps to use the APIs from ImageGlass.Tools:

  1. Create a new project in Visual Studio.
  2. Install ImageGlass.Tools nudget package, or add ImageGlass.Tools.csproj as a reference to your software.
  3. Create a new instance of ImageGlassTool:
private readonly ImageGlassTool _igTool = new ImageGlassTool();
  1. Add event listeners to ImageGlass:
_igTool.ToolMessageReceived += IgTool_ToolMessageReceived;
_igTool.ToolClosingRequest += IgTool_ToolClosingRequest;
  1. Handle event from ImageGlass:
private void IgTool_ToolMessageReceived(object? sender, MessageReceivedEventArgs e)
{
  if (string.IsNullOrEmpty(e.MessageData)) return;

  if (e.MessageName == ImageGlassEvents.IMAGE_LOADED)
  {
    Trace.WriteLine("Image is loaded");
    Trace.WriteLine(e.MessageData);
  }
}
  1. Start connecting to ImageGlass:
await _igTool.ConnectAsync();

Now you have created an app that connects and handles events from ImageGlass. You can also explore a complete app in the DemoApp project.

Add your tool to ImageGlass

You can integrate external apps as ImageGlass Tools and assign hotkeys for them in ImageGlass 9. These tools will appear under the Tools menu. To achieve this, you can use the app settings UI or directly edit the user config file (igconfig.json).

Using app settings UI

  • Open ImageGlass Settings and click on the "Tools" tab.
  • Click the "Add..." button to add a new tool.
  • Fill in all the fields accordingly.
    • In Argument text box, fill <file> to have ImageGlass send the full path of the currently viewed image file to the tool.
    • Check the option "Integrated with ImageGlass.Tools" if the tool has an implementation of ImageGlass.Tools.
    • Use the command preview to verify the correctness of your inputs.
  • Click the "OK" button to close the dialog, and then click "OK" or "Apply" to save the changes. Use ImageGlass setting to add external tool

Editing the user config file (igconfig.json)

  1. Make sure the ImageGlass app is not running.
  2. Open the igconfig.json file with a text editor such as Notepad or VS Code.
  3. In the Tools section of the igconfig.json file, add the following code:
// in igconfig.json
"Tools": [
  {
    "ToolId": "Tool_MyDemoApp", // a unique ID
    "ToolName": "My Demo app", // name of the tool
    "Executable": "path\\to\\the\\DemoApp.exe",
    "Argument": "<file>", // file path to pass to the tool
    "Hotkeys": ["X", "Ctrl+E"], // press X or Ctrl+E to open/close the tool
    "IsIntegrated": true|false // true: if the tool supports 'ImageGlass.Tools'
  }
]
  1. Save the file and launch ImageGlass.