Collection of tools to load and process image data. Available on macOS 14, iOS 17, tvOS 17 and visionOS 1.
ImageTools uses the following libraries:
- LibPNG (precompiled libpng) to load .png images.
- tinyexr v1.0.12 to load .exr images.
- stb's stb_image.h to load other commonly used image files like .jpg, .png, .tga, .bmp, .psd, .gif, .hdr and .pic.
- LittleCMS (precompiled Little-CMS) to convert between color profiles.
- ASTCEncoder to convert loaded images into ASTC-compressed textures.
tinyexr is used without its zlib implementation in miniz.c and miniz.h. Instead, ImageTools uses system provided zlib that is already linked by LibPNG.
Although both libpng and stb_image support loading .png images, libpng is prioritised, since it also loads ICC profile data that gives more color accuracy and allows precise color profile conversion with LittleCMS.
You can add this package directly to your Xcode project:
- In Xcode, open File -> Add Package Dependencies...
- Enter the package URL:
https://github.com/EvgenijLutz/ImageTools.git
- Choose your dependency rule and you're good to go!
ImageTools' interface is written in C++ and is available in the ImageToolsC module:
#include <ImageToolsC/ImageToolsC.hpp>ImageTools is also bridged to Swift using Swift C++ interoperability and is available in the ImageTools module:
import ImageToolsIt extends the C++ interface by providing asynchronous interfaces and helper methods to create CoreGraphics' CGImage:
@MainActor
var uiImage: UIImage? // or NSImage
@MainActor
func loadImage(path: String) async throws -> CGImage {
let image = try await ImageContainer.load(path: path)
uiImage = try .init(cgImage: image.cgImage)
}
In the heart of the package lays the ImageContainer. This object is thread-safe.
ImageEditor allows you to perform mutations to a copy of an ImageContainer.
Include the following libraries:
- OpenEXR or is it overkill and tinyexr is enough?
- ImageMagick ?