Cross-Platform Command-Line Utilities for HVIF & SVG Conversion

Hello everyone,

I’m excited to announce the release of hvif-tools, a small set of command-line utilities designed to work with the Haiku Vector Icon Format (HVIF). This project provides two main tools: hvif2svg and svg2hvif, enabling conversion between these two important formats.

A key goal of this project is cross-platform compatibility. These tools are designed to be compiled and run effectively on Linux, macOS, Windows, and of course, Haiku.

Features:

hvif2svg

  • Parses .hvif files, including header validation.
  • Renders paths (points, curves), shapes, and styles (including solid colors and gradients).
  • Supports fills and strokes (utilizing HVIF’s STROKE/CONTOUR transformers).
  • Handles linear and radial gradients, including gradientTransform attributes and correct stop opacity.
  • Operates within HVIF’s native coordinate system (viewBox 0 0 6528 6528, equivalent to 64 × 102 units).

svg2hvif

  • Parses SVG files using the lightweight, header-only NanoSVG library.
  • Normalizes SVG coordinates to fit HVIF’s 64x64 unit space and centers the content.
  • Converts SVG fill and stroke properties, including line caps, joins, miter limits, stroke widths, and opacity.
  • Supports conversion of linear and radial gradients.

Availability:

Future Development: Native Haiku GUI Application

In addition to these command-line tools, I’m also actively developing a native graphical application for Haiku. This application aims to provide a user-friendly interface for working with icons:

  • Open and view SVG icons.
  • Open HVIF icons, read them directly from application attributes, and automatically convert them to SVG for viewing.
  • Convert opened SVG/HVIF files and allow drag-and-drop onto application/file types/mime types for easy integration.
  • Automatically generate rdef arrays and C++ arrays suitable for embedding directly into applications.

The GUI application is still under development. You can see some progress in the screenshots below:


48 Likes

I regret that I have only one :heart: to give you. We have needed this for a while.

3 Likes

Great tools, I will give them a try !
Many thanks :slight_smile:

Much appreciated!
Can you explain why you decided to code these dedicated cli apps and not extend the existing HVIF and SVG translators to be able to output not just bitmaps, but SVG and HVIF respectively?

The main idea was to make them cross-platform. So that conversion could be done not only for Haiku. It will be quite easy to write translators based on ready-made classes, if someone wants - there is a very simple and convenient API.

5 Likes

In same order of idea, could it be used also to make import/export filters for Inkscape?

2 Likes

I think it will be quite simple

1 Like

Nice work 3deyes! :ok_hand:

1 Like

It turned out to be much easier than I thought:

18 Likes

Impressive work @3dEyes !

A new version of the hvif2svg and svg2hvif conversion utilities, including import and export modules for Inkscape, is already available in HaikuDepot. I also made sure that when Inkscape is installed, they are installed automatically by dependencies.

11 Likes

Isn’t it a translator?

I don’t quite understand what you mean. Let’s say I’m creating translators from svg to hvif and back, but what software do we have that will use them? Moreover, it was not for nothing that I wrote in the topic that these are cross-platform utilities that will work on any systems. You can compile this project for Linux or Windows without any problems and use them in Inkscape. I have already tested editing hvif files in Inkscape for windows and everything works fine.

3 Likes

8 Likes

Current progress. Also shown is the work of the vectorizer of raster images to SVG and HVIF.

9 Likes

There has been some progress with the img2svg utility for vectorizing bitmap images into vector images, as well as a native application for working with SVG/HVIF files and using the same vectorizer:

It shows the work of removing the background + the work of the circle geometry detector and replacing them with ideal ones:

The hole detector is shown here:

This screenshot shows a vectorized sticker exported to HVIF and opened in Icon-o-matic:

And here we see a linear gradient detector that does not work very well, buggy, requires improvement, but is already working:

16 Likes

hvif-tools is cross platform, then can we have HVIF thumbnail provider on other platforms?

For windows,

Add a step of converting HVIF to SVG, then SVG to thumbnail.

7 Likes

Should we do the same for Gnome and KDE?

1 Like

Do it for KDE (I’m not sure if GNOME has a use case for HVIF thumbnails).