imgproxy v4: Better SVG minification, RAW formats support, and colorspace preservation
This is the third part of a series of blog posts about the new features in imgproxy v4. In this post, we will tell you about the improvements in SVG minification, RAW formats support, and colorspace preservation introduced in imgproxy v4 and how they can enhance your image processing workflow.
imgproxy v4 announcements:
- Internal Cache and changes to conditional request behavior
- Parallel image downloading
- Better SVG minification, RAW formats support, and colorspace preservation
Better SVG minification Pro
SVG is a popular vector image format used for icons, logos, and illustrations. However, SVG files exported from design tools are usually non-optimal: they contain unnecessary metadata, comments, groups, and attributes that increase the file size. It’s important to minify SVG files before serving them to users, as it improves loading speed.
imgproxy Pro has been supporting SVG minification since v2. However, the set of optimizations was pretty basic, and we weren’t very happy with the minifier we were using. Unfortunately, every other option we tried had issues and didn’t pass our tests. SVGO seemed to be the only reliable SVG minifier, but embedding a JavaScript runtime in imgproxy is a huge overkill.
In imgproxy Pro v4, we have implemented our own SVG minifier that is tailored to our needs. It is both faster and more efficient than the solution we had before, supporting much wider range of optimizations. We have tested it on a large dataset of SVG files to ensure that it produces optimal results without breaking the images. The results are impressive: the new minifier optimizes SVG files more than two times better than the previous one and does it almost twice as fast!
RAW formats support Pro
“RAW” is a common name for a wide family of uncompressed image formats used by digital cameras to store the raw sensor data (also known as “digital negatives”). RAW images are not what an average web application would deal with. However, if photographers are your target audience, they may like to upload their photos in RAW format, and you may want to support it.
In imgproxy Pro v4, we have added support for RAW formats. Now you can just upload RAW images to your storage, and imgproxy will process them just like any other image. The RAW support is based on LibRaw, a powerful and widely used library for reading RAW files. We have tested it with a variety of RAW formats from different camera manufacturers to ensure that it works well with all of them.
Colorspace preservation
Historically, imgproxy has processed and served all images in the sRGB color space. This was a reasonable choice, as sRGB is the most common color space on the web and ensures that images look consistent across devices and browsers. However, it also means that if the source image is greyscale, converting it to sRGB will most likely increase the file size.
In imgproxy v4, we changed this behavior. Now it preserves greyscale images in their original colorspace, if no operations add color (e.g., watermarking, colorizing, applying gradients, etc.).
Additionally, we added the IMGPROXY_PRESERVE_HDR config option. By default, imgproxy converts all images to 8-bit per channel, which is good for file size savings. However, if you prefer preserving colors over a smaller file size, you can enable this option, and imgproxy will keep the source image’s original bit depth.
imgproxy v4 improves the way it handles images in several ways. Better SVG minification means that your SVG files will be smaller and load faster. RAW formats support allows you to process and serve RAW images without any additional steps. Colorspace preservation ensures that colors are kept as close as possible to the source image.
More announcements are on the way, so stay tuned! And if you want to test these features in practice, just apply to our Early Access program!