vips
| Kind | ffi-c |
|---|---|
| Capabilities | ffi |
| Categories | graphics ffi |
| Keywords | vips image processing resize thumbnail |
libvips fast image processing library bindings for Kit
Files
| File | Description |
|---|---|
.editorconfig | Editor formatting configuration |
.gitignore | Git ignore rules for build artifacts and dependencies |
.tool-versions | asdf tool versions (Zig, Kit) |
LICENSE | MIT license file |
README.md | This file |
c/kit_vips.c | C FFI wrapper |
c/kit_vips.h | C header for FFI wrapper |
examples/basic.kit | Basic usage example |
kit.toml | Package manifest with metadata and dependencies |
src/vips.kit | Kit Vips - Fast image processing library bindings |
tests/vips.test.kit | Tests for vips |
Dependencies
No Kit package dependencies.
Installation
kit add gitlab.com/kit-lang/packages/kit-vips.gitSystem Requirements
| Platform | Command |
|---|---|
| macOS | brew install vips |
| Ubuntu | sudo apt install libvips-dev |
| Fedora | sudo dnf install vips-devel |
Usage
import Kit.VIPS as Vips
main = fn =>
match Vips.init
| Ok _ -> println "libvips initialized"
| Err e -> println ("Init error: " ++ e)
match Vips.load "photo.png"
| Ok img ->
println ("Size: " ++ (show (Vips.get-width img)) ++ "x" ++ (show (Vips.get-height img)))
# Resize to 50%
match Vips.resize img 0.5
| Ok resized ->
match Vips.save resized "photo-half.png"
| Ok _ -> println "Saved resized image"
| Err e -> println ("Save error: " ++ e)
Vips.free resized
| Err e -> println ("Resize error: " ++ e)
# Generate thumbnail
match Vips.thumbnail "photo.png" 100
| Ok thumb ->
match Vips.save thumb "photo-thumb.png"
| Ok _ -> println "Saved thumbnail"
| Err e -> println ("Save error: " ++ e)
Vips.free thumb
| Err e -> println ("Thumbnail error: " ++ e)
Vips.free img
| Err e -> println ("Load error: " ++ e)
Vips.shutdown
mainDevelopment
Running Examples
Run examples with the interpreter:
kit run examples/basic.kitCompile examples to a native binary:
kit build examples/basic.kit && ./basicRunning Tests
Run the test suite:
kit testRun the test suite with coverage:
kit test --coverageRunning kit dev
Run the standard development workflow (format, check, test):
kit devThis will:
- Format and check source files in
src/ - Run tests in
tests/with coverage
Generating Documentation
Generate API documentation from doc comments:
kit docNote: Kit sources with doc comments (##) will generate HTML documents in docs/*.html
Cleaning Build Artifacts
Remove generated files, caches, and build artifacts:
kit task cleanNote: Defined in kit.toml.
Local Installation
To install this package locally for development:
kit installThis installs the package to ~/.kit/packages/@kit/vips/, making it available for import as Kit.VIPS in other projects.
License
This package is released under the MIT License - see LICENSE for details.
libvips is released under the LGPL 2.1 License.
Exported Functions & Types
init
Initialize libvips. Must be called before any other operations.
Returns:
Result Unit String
shutdown
Shut down libvips and release global resources.
Unit
load
Load an image from a file.
Parameters:
Returns:
NonEmptyString -> Result Ptr String
save
Save an image to a file. Format is determined by file extension.
Parameters:
Returns:
Ptr -> NonEmptyString -> Result Unit String
free
Free an image and release its resources.
Parameters:
Ptr -> Unit
get-width
Get the width of an image in pixels.
Parameters:
Returns:
Ptr -> Int
get-height
Get the height of an image in pixels.
Parameters:
Returns:
Ptr -> Int
get-bands
Get the number of bands (channels) in an image.
Parameters:
Returns:
Ptr -> Int
thumbnail
Generate a thumbnail from a file with smart cropping.
Parameters:
Returns:
NonEmptyString -> PositiveInt -> Result Ptr String
resize
Resize an image by a scale factor.
Parameters:
Returns:
Ptr -> PositiveFloat -> Result Ptr String
crop
Crop a rectangular region from an image.
Parameters:
Returns:
Ptr -> NonNegativeInt -> NonNegativeInt -> PositiveInt -> PositiveInt -> Result Ptr String
rotate
Rotate an image by the given angle in degrees.
Parameters:
Returns:
Ptr -> Float -> Result Ptr String
flip-horizontal
Flip an image horizontally.
Parameters:
Returns:
Ptr -> Result Ptr String
flip-vertical
Flip an image vertically.
Parameters:
Returns:
Ptr -> Result Ptr String
invert
Invert the colors of an image.
Parameters:
Returns:
Ptr -> Result Ptr String
blur
Apply a Gaussian blur to an image.
Parameters:
Returns:
Ptr -> PositiveFloat -> Result Ptr String
sharpen
Sharpen an image using unsharp masking.
Parameters:
Returns:
Ptr -> Result Ptr String
to-grayscale
Convert an image to grayscale.
Parameters:
Returns:
Ptr -> Result Ptr String
version
Get the libvips version string.
Returns:
String