23#pragma region image handling
33 TINYIMG_FORMAT_UNKNOWN = 0,
34 TINYIMG_FORMAT_PNG = 1,
35 TINYIMG_FORMAT_JPEG = 2,
36 TINYIMG_FORMAT_BMP = 3,
37 TINYIMG_FORMAT_GIF = 4,
38 TINYIMG_FORMAT_TIFF = 5,
39 TINYIMG_FORMAT_WEBP = 6,
40 TINYIMG_FORMAT_AVIF = 7,
41 TINYIMG_FORMAT_HEIF = 8,
259 TinyImage* image, uint32_t width, uint32_t height, uint8_t channels
275 const uint8_t* buffer,
size_t buffer_size,
TinyImageInfo* info
294 TinyImage* image,
const uint8_t* buffer,
size_t buffer_size
319 TinyImage* image,
const uint8_t* buffer,
size_t buffer_size,
320 uint32_t max_width, uint32_t max_height
342 TinyImage* image,
const uint8_t* buffer,
size_t buffer_size, uint32_t x,
343 uint32_t y, uint32_t width, uint32_t height
359 TinyImage* image,
const uint8_t* buffer,
size_t buffer_size,
449 const TinyImage* image,
char* extension,
size_t max_length
471 const TinyImage* image, uint32_t x, uint32_t y, uint8_t* pixel
489 TinyImage* image, uint32_t x, uint32_t y,
const uint8_t* pixel
554#pragma region image drawing
647 TinyImage* image, int32_t x1, int32_t y1, int32_t x2, int32_t y2,
663 TinyImage* image, int32_t x1, int32_t y1, int32_t x2, int32_t y2,
679 TinyImage* image, int32_t x, int32_t y, uint32_t width, uint32_t height,
695 TinyImage* image, int32_t x, int32_t y, uint32_t width, uint32_t height,
713 TinyImage* image, int32_t x, int32_t y, uint32_t width, uint32_t height,
714 uint32_t radius,
const uint8_t* pixel
734 TinyImage* image, int32_t x1, int32_t y1, int32_t x2, int32_t y2,
735 uint32_t thickness,
const uint8_t* pixel
749 TinyImage* image, int32_t center_x, int32_t center_y, uint32_t radius,
764 TinyImage* image, int32_t center_x, int32_t center_y, uint32_t radius,
780 TinyImage* image, int32_t center_x, int32_t center_y, uint32_t radius_x,
781 uint32_t radius_y,
const uint8_t* pixel
796 TinyImage* image, int32_t center_x, int32_t center_y, uint32_t radius_x,
797 uint32_t radius_y,
const uint8_t* pixel
811 TinyImage* image,
const int32_t* x_points,
const int32_t* y_points,
812 size_t num_points,
const uint8_t* pixel
826 TinyImage* image,
const int32_t* x_points,
const int32_t* y_points,
827 size_t num_points,
const uint8_t* pixel
843 TinyImage* image,
const int32_t* x_points,
const int32_t* y_points,
844 size_t num_points,
const uint8_t* pixel,
TinyFillRule rule,
859 TinyImage* image,
const uint8_t* old_color,
const uint8_t* new_color,
860 const uint8_t* tolerance
954 TinyImage* image, int32_t x0, int32_t y0, int32_t x1, int32_t y1,
955 const uint8_t* from,
const uint8_t* to
971 TinyImage* image, int32_t center_x, int32_t center_y, uint32_t radius,
972 const uint8_t* inner,
const uint8_t* outer
986 TinyImage* image,
float angle,
float start,
float end
998 TinyImage* image, uint32_t border_width,
const uint8_t* pixel
1017 TinyImage* image, uint32_t left, uint32_t top, uint32_t right,
1018 uint32_t bottom,
const uint8_t* pixel
1041 TinyImage* image, int32_t x, int32_t y,
const uint8_t* mask, uint32_t width,
1047#pragma region image display list
1050#define TINYIMG_DISPLAY_MAX_SHAPES 64
1053#define TINYIMG_DISPLAY_MAX_POINTS 256
1056#define TINYIMG_DISPLAY_MAX_DEPTH 8
1227 const uint8_t* color
1244 float radius,
const uint8_t* color
1259 TinyDisplayList* list,
float center_x,
float center_y,
float radius_x,
1260 float radius_y,
const uint8_t* color
1277 float thickness,
const uint8_t* color
1294 size_t num_points,
const uint8_t* color,
TinyFillRule rule
1349#pragma region image manipulation
1371 TinyImage* image, uint32_t new_width, uint32_t new_height
1391 TinyImage* image, uint32_t x, uint32_t y, uint32_t crop_width,
1392 uint32_t crop_height
1413 TinyImage* image, uint32_t center_x, uint32_t center_y, uint32_t radius
1436 TinyImage* image, uint32_t center_x, uint32_t center_y, uint32_t radius_x,
1460 TinyImage* image,
const uint32_t* x_points,
const uint32_t* y_points,
1546#pragma region image transformations
1837 TinyImage* image, uint32_t target_width, uint32_t target_height,
1863 TinyImage* image, uint32_t target_width, uint32_t target_height,
1896 TinyImage* image, uint32_t target_width, uint32_t target_height,
1898 const uint8_t* background_color
1913 TinyImage* image, uint32_t target_width, uint32_t target_height,
2001 TinyImage* image, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
2027 TinyImage* image, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
2067 TinyImage* image,
float radius,
float strength,
const uint8_t* color
2090 TinyImage* image,
const uint8_t* color,
float opacity
2121 TinyImage* image, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
2122 const uint8_t* color,
float opacity
2127#pragma region image effects
2210 TinyImage* image,
const uint8_t* red,
const uint8_t* green,
2229 TinyImage* image,
const uint8_t* x_points,
const uint8_t* y_points,
2310 TinyImage* image,
const uint8_t* shadow,
const uint8_t* highlight
2323 TinyImage* image,
const uint8_t* shadow,
const uint8_t* highlight,
2385 TinyImage* image,
float in_black,
float in_white,
float gamma,
2386 float out_black,
float out_white
2402 TinyImage* image, uint8_t channel,
float in_black,
float in_white,
2403 float gamma,
float out_black,
float out_white
2416 TinyImage* image,
const float* shadows,
const float* midtones,
2417 const float* highlights
2439 TinyImage* image,
float red,
float green,
float blue
2475#pragma region image spatial effects
2488 TinyImage* image,
float sigma,
float amount,
float threshold
2538 TinyImage* image, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
2645 TinyImage* image, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
2664 TinyImage* image, int32_t offset_x, int32_t offset_y,
float sigma,
2665 const uint8_t* color
2741#pragma region image auto correction
2808 TinyImage* image,
float shadows,
float highlights
2822#pragma region image warps
2837 TinyImage* image,
float shear_x,
float shear_y,
const uint8_t* background
2854 TinyImage* image,
float degrees,
const uint8_t* background
2869 TinyImage* image,
const float* quad,
const uint8_t* background
2922#pragma region image analysis
2934 const TinyImage* image, uint8_t channel, uint32_t* bins
2959 const TinyImage* image, uint32_t count, uint8_t* palette
3048#pragma region image metadata
3067 TinyImage* image,
const char* exif_data,
size_t exif_size
3088 const TinyImage* image,
char** exif_data,
size_t* exif_size
3134 TinyImage* image,
const char* key,
const char* value
3155 const TinyImage* image,
const char* key,
char** value
3202#pragma region image conversion
int tiny_image_draw_image_ex(TinyImage *dest_image, const TinyImage *src_image, int32_t x, int32_t y, float opacity, TinyDrawMode mode, TinyBlendMode blend)
Draws one image onto another with an opacity, a placement and a blend mode.
int tiny_image_rotate_270(TinyImage *image)
Rotates an image 270 degrees clockwise (or 90 degrees counterclockwise).
int tiny_display_bounds(const TinyDisplayList *list, int32_t *x, int32_t *y, uint32_t *width, uint32_t *height)
The rectangle every shape in the list falls inside.
uint32_t tiny_display_sizeof(void)
Size of a TinyDisplayList, for a host allocating one.
int tiny_image_rotate_90(TinyImage *image)
Rotates an image 90 degrees clockwise.
int tiny_image_glow(TinyImage *image, float sigma, float strength)
Adds a blurred copy of the image to itself, which is a bloom.
uint32_t tiny_image_getheight(const TinyImage *image)
Height of an image in pixels.
int tiny_image_apply_lut(TinyImage *image, const uint8_t *lut)
Applies a 256 entry table of the caller's own to every channel.
int tiny_image_to_grayscale(TinyImage *image)
Converts the image to grayscale.
TinyImageFormat
Image formats supported by TinyImage for conversion and saving.
Definition image.h:32
int tiny_image_strip_exif(TinyImage *image)
Strips the EXIF metadata from the image.
int tiny_image_getpixel(const TinyImage *image, uint32_t x, uint32_t y, uint8_t *pixel)
Retrieves the pixel value at the specified (x, y) coordinates in the image.
int tiny_image_opacity(TinyImage *image, float opacity)
Adjusts the opacity of an image by modifying its alpha channel.
int tiny_image_emboss(TinyImage *image, float strength)
Turns the image into a relief lit from the upper left.
int tiny_image_darken(TinyImage *image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, float factor)
Darkens a specified rectangular region of the image by the given factor.
uint32_t tiny_display_culled(const TinyDisplayList *list)
How many shapes the last render dropped as outside the target.
int tiny_image_swirl(TinyImage *image, float degrees)
Twists the image about its center, most at the center.
int tiny_image_pixelate_region(TinyImage *image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t size)
The same, inside a rectangle.
int tiny_display_polygon(TinyDisplayList *list, const float *x_points, const float *y_points, size_t num_points, const uint8_t *color, TinyFillRule rule)
Adds a polygon.
int tiny_image_film_grain(TinyImage *image, float amount)
Adds noise weighted toward the midtones, which is how film grains.
uint32_t tiny_image_sizeof(void)
Size of a TinyImage, for a host allocating one across the wasm boundary.
int tiny_image_threshold(TinyImage *image, uint8_t level)
Drives every channel to nothing or to full scale.
int tiny_image_fit_with_gravity(TinyImage *image, uint32_t target_width, uint32_t target_height, TinyImageFit fit_mode, TinyImageGravity gravity, const uint8_t *background)
Fits the image to a target, keeping the part the gravity names.
int tiny_image_barrel(TinyImage *image, float amount)
Corrects or introduces lens distortion.
int tiny_image_perspective(TinyImage *image, const float *quad, const uint8_t *background)
Maps the image's four corners onto four arbitrary points.
TinyImageFormat tiny_format_sniff(const uint8_t *buffer, size_t buffer_size)
Identifies a format from a buffer's magic bytes.
int tiny_image_halftone(TinyImage *image, uint32_t cell)
Turns tone into dot area within a cell.
int tiny_image_polar(TinyImage *image, int inverse)
Maps between rectangular and polar coordinates.
int tiny_image_set_transparent(TinyImage *image, int enable_transparency)
Sets the transparency of the image.
int tiny_image_brightness(TinyImage *image, float factor)
Adjusts the brightness of the image.
int tiny_image_color_balance(TinyImage *image, const float *shadows, const float *midtones, const float *highlights)
Shifts the color of the shadows, midtones and highlights apart.
int tiny_display_render(TinyDisplayList *list, TinyImage *image)
Draws every shape onto an image, in one pass over the list.
int tiny_image_colorblind_assist(TinyImage *image, TinyColorblindKind kind)
Moves the colors a given color blindness cannot separate apart.
int tiny_image_radial_blur(TinyImage *image, float degrees)
Averages along arcs about the center.
int tiny_image_fill_ellipse(TinyImage *image, int32_t center_x, int32_t center_y, uint32_t radius_x, uint32_t radius_y, const uint8_t *pixel)
Fills an axis-aligned ellipse.
uint32_t tiny_display_covered(const TinyDisplayList *list)
How many shapes the last render dropped as covered by a later opaque one.
int tiny_image_hline(TinyImage *image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, const uint8_t *pixel)
Draws a horizontal run of pixels.
int tiny_image_tilt_shift(TinyImage *image, float sigma, float band)
Blurs away from a horizontal band left sharp.
int tiny_image_unpremultiply(TinyImage *image)
Divides each color channel by its alpha.
int tiny_image_morphology_open(TinyImage *image, uint32_t radius)
Erodes then dilates, which removes bright specks.
int tiny_display_restore(TinyDisplayList *list)
Pops the transform saved last.
int tiny_image_blur_faces(TinyImage *image, float sigma)
Blurs whatever the detector finds and nothing else.
int tiny_display_ellipse(TinyDisplayList *list, float center_x, float center_y, float radius_x, float radius_y, const uint8_t *color)
Adds an ellipse.
uint32_t tiny_image_info_sizeof(void)
Size of a TinyImageInfo, for a host allocating one across the wasm boundary.
uint32_t tiny_image_getsize(const TinyImage *image)
Bytes an image's pixel data occupies.
int tiny_image_phash(const TinyImage *image, uint64_t *hash)
A 64 bit perceptual hash.
int tiny_image_crop_ellipse(TinyImage *image, uint32_t center_x, uint32_t center_y, uint32_t radius_x, uint32_t radius_y)
Crops an image to an elliptical region defined by the center (center_x, center_y) and the specified r...
int tiny_image_negate(TinyImage *image)
Subtracts every color channel from full scale.
int tiny_display_init(TinyDisplayList *list)
Empties a display list and resets its transform to the identity.
int tiny_image_setpixel(TinyImage *image, uint32_t x, uint32_t y, const uint8_t *pixel)
Writes the pixel value at the specified (x, y) coordinates in the image.
TinyImagePixelType
What the channels of an image mean.
Definition image.h:51
@ TINYIMG_PIXEL_GRAY
One channel, luminance.
Definition image.h:55
@ TINYIMG_PIXEL_RGB
Three channels, red then green then blue.
Definition image.h:63
@ TINYIMG_PIXEL_RGBA
Four channels, red then green then blue then alpha.
Definition image.h:67
@ TINYIMG_PIXEL_GRAY_ALPHA
Two channels, luminance then alpha.
Definition image.h:59
int tiny_image_draw_line(TinyImage *image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t thickness, const uint8_t *pixel)
Draws a line of the given thickness.
int tiny_display_scale(TinyDisplayList *list, float x, float y)
Scales the current transform.
int tiny_image_sobel(TinyImage *image)
Replaces the image with its Sobel gradient magnitude.
int tiny_image_temperature(TinyImage *image, float amount)
Shifts the white point along the blue to amber axis.
struct TinyImageMeta TinyImageMeta
Metadata carried alongside the pixels.
Definition image.h:76
int tiny_image_get_metadata(const TinyImage *image, const char *key, char **value)
Retrieves the value associated with a custom metadata key from the image.
int tiny_image_fill_polygon(TinyImage *image, const int32_t *x_points, const int32_t *y_points, size_t num_points, const uint8_t *pixel)
Fills a polygon by the even-odd rule.
int tiny_image_gradient_radial(TinyImage *image, int32_t center_x, int32_t center_y, uint32_t radius, const uint8_t *inner, const uint8_t *outer)
Fills the image with a radial gradient.
int tiny_image_remove_background(TinyImage *image, uint8_t tolerance)
Clears the background, making it transparent.
int tiny_image_encode(const TinyImage *image, TinyImageFormat format, const TinyEncodeOpts *opts, TinyWriter *writer)
Encodes an image into a growing byte sink.
int tiny_image_white_balance(TinyImage *image, float temperature, float tint)
Shifts the white point along both axes at once.
int tiny_image_hue(TinyImage *image, float angle)
Adjusts the hue of the image.
TinyFillRule
Which points a polygon fill considers inside.
Definition image.h:601
@ TINYIMG_FILL_NONZERO
Inside when the signed crossings do not cancel.
Definition image.h:614
@ TINYIMG_FILL_EVEN_ODD
Inside when a ray to the point crosses an odd number of edges.
Definition image.h:607
int tiny_image_set_exif(TinyImage *image, const char *exif_data, size_t exif_size)
Sets the EXIF metadata for the image.
int tiny_image_color_overlay_rect(TinyImage *image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, const uint8_t *color, float opacity)
Applies a color overlay to a specified rectangular region of the image with the given color and opaci...
int tiny_image_colorize(TinyImage *image, const uint8_t *color, float strength)
Mixes every pixel toward one color, keeping its luminance.
int tiny_image_dehaze(TinyImage *image, float strength)
Removes a veiling haze by the dark-channel prior.
int tiny_image_levels_channel(TinyImage *image, uint8_t channel, float in_black, float in_white, float gamma, float out_black, float out_white)
The same, on one channel.
int tiny_image_flip_vertical(TinyImage *image)
Flips an image vertically, mirroring it along the horizontal axis.
int tiny_image_convert(TinyImage *image, TinyImageFormat format)
Records the format the image should be written as, dropping anything that format cannot carry.
int tiny_image_average_color(const TinyImage *image, uint8_t *color)
The mean of every pixel, per channel.
int tiny_image_gaussian_blur(TinyImage *image, float sigma)
Applies a Gaussian blur effect to the image.
int tiny_display_blend(TinyDisplayList *list, TinyBlendMode blend)
Sets the blend mode the next shapes are added with.
uint32_t tiny_image_getwidth(const TinyImage *image)
Width of an image in pixels.
int tiny_image_fill_circle(TinyImage *image, int32_t center_x, int32_t center_y, uint32_t radius, const uint8_t *pixel)
Fills a circle.
int tiny_image_convert_channels(TinyImage *image, uint8_t channels)
Converts the image to a given channel count.
int tiny_image_channel_gain(TinyImage *image, float red, float green, float blue)
Scales each channel independently.
int tiny_image_auto_gamma(TinyImage *image)
Applies the gamma that brings the mean luminance to mid gray.
int tiny_display_save(TinyDisplayList *list)
Pushes the current transform.
int tiny_image_scanlines(TinyImage *image, uint32_t period, float strength)
Darkens every nth row.
int tiny_image_crop_circle(TinyImage *image, uint32_t center_x, uint32_t center_y, uint32_t radius)
Crops an image to a circular region defined by the center (center_x, center_y) and the specified radi...
int tiny_image_exposure(TinyImage *image, float stops)
Scales every channel by a power of two.
int tiny_image_flip_horizontal(TinyImage *image)
Flips an image horizontally, mirroring it along the vertical axis.
int tiny_image_outline(TinyImage *image, uint32_t radius)
The difference between a dilation and an erosion.
int tiny_image_auto_levels(TinyImage *image)
Stretches each channel to the full range independently.
TinyColorblindKind
The forms of color blindness the simulation and the assist cover.
Definition image.h:2137
@ TINYIMG_COLORBLIND_PROTANOPIA
Definition image.h:2139
@ TINYIMG_COLORBLIND_DEUTERANOPIA
Definition image.h:2141
@ TINYIMG_COLORBLIND_TRITANOPIA
Definition image.h:2143
@ TINYIMG_COLORBLIND_ACHROMATOPSIA
Definition image.h:2145
int tiny_image_resize(TinyImage *image, uint32_t new_width, uint32_t new_height)
Resamples an image to the specified new width and height.
int tiny_draw_coverage(TinyImage *image, int32_t x, int32_t y, const uint8_t *mask, uint32_t width, uint32_t height, const uint8_t *color, TinyBlendMode blend)
Blends one color through an 8-bit coverage mask.
int tiny_image_motion_blur(TinyImage *image, float length, float angle)
Averages along a straight path.
int tiny_image_noise(TinyImage *image, float amount, int monochrome)
Adds pseudorandom noise.
int tiny_image_gamma_correction(TinyImage *image, float gamma)
Applies gamma correction to the image.
int tiny_image_vignette(TinyImage *image, float radius, float strength, const uint8_t *color)
Applies a vignette effect to the image.
int tiny_image_auto_brightness(TinyImage *image)
Moves the mean luminance to the middle of the range.
#define TINYIMG_DISPLAY_MAX_DEPTH
Definition image.h:1056
int tiny_image_apply_luts(TinyImage *image, const uint8_t *red, const uint8_t *green, const uint8_t *blue)
Applies one table per color channel.
int tiny_image_draw_ellipse(TinyImage *image, int32_t center_x, int32_t center_y, uint32_t radius_x, uint32_t radius_y, const uint8_t *pixel)
Draws the outline of an axis-aligned ellipse.
TinyShapeKind
Definition image.h:1060
@ TINYIMG_SHAPE_POLYGON
Definition image.h:1072
@ TINYIMG_SHAPE_NONE
Definition image.h:1062
@ TINYIMG_SHAPE_RECT
Definition image.h:1064
@ TINYIMG_SHAPE_LINE
Definition image.h:1070
@ TINYIMG_SHAPE_ELLIPSE
Definition image.h:1068
@ TINYIMG_SHAPE_ROUND_RECT
Definition image.h:1066
int tiny_display_rect(TinyDisplayList *list, float x, float y, float width, float height, const uint8_t *color)
Adds a rectangle.
int tiny_image_replace_color(TinyImage *image, const uint8_t *old_color, const uint8_t *new_color, const uint8_t *tolerance)
Replaces every pixel close to one color with another.
int tiny_display_line(TinyDisplayList *list, float x1, float y1, float x2, float y2, float thickness, const uint8_t *color)
Adds a line.
int tiny_image_apply_matrix(TinyImage *image, const float *matrix)
Applies a color matrix of the caller's own.
int tiny_display_round_rect(TinyDisplayList *list, float x, float y, float width, float height, float radius, const uint8_t *color)
Adds a rectangle with rounded corners.
int tiny_image_rotate_180(TinyImage *image)
Rotates an image 180 degrees.
int tiny_image_load_region(TinyImage *image, const uint8_t *buffer, size_t buffer_size, uint32_t x, uint32_t y, uint32_t width, uint32_t height)
Loads one rectangle of an image.
int tiny_image_gradient_linear(TinyImage *image, int32_t x0, int32_t y0, int32_t x1, int32_t y1, const uint8_t *from, const uint8_t *to)
Fills the image with a linear gradient.
int tiny_image_shear(TinyImage *image, float shear_x, float shear_y, const uint8_t *background)
Slants the image along one or both axes.
int tiny_image_blur(TinyImage *image, float radius)
Applies a blur effect to the image.
int tiny_image_fit_with_padding_and_background(TinyImage *image, uint32_t target_width, uint32_t target_height, TinyImageFit fit_mode, const uint8_t *padding_color, const uint8_t *background_color)
Resizes an image to fit within the specified target width and height according to the specified fit m...
int tiny_image_decode(TinyImage *image, const uint8_t *buffer, size_t buffer_size, const TinyDecodeOpts *opts)
Loads an image with full control over region, scale and channel count.
int tiny_image_getextension(const TinyImage *image, char *extension, size_t max_length)
Retrieves the file extension associated with the image format.
int tiny_image_gettype(const TinyImage *image, TinyImagePixelType *type)
Retrieves the type of the image (grayscale, grayscale with alpha, RGB or RGBA).
int tiny_image_draw_circle(TinyImage *image, int32_t center_x, int32_t center_y, uint32_t radius, const uint8_t *pixel)
Draws the outline of a circle.
int tiny_image_expand(TinyImage *image, uint32_t left, uint32_t top, uint32_t right, uint32_t bottom, const uint8_t *pixel)
Grows the image by a border around it.
int tiny_image_zoom_blur(TinyImage *image, float strength)
Averages along rays from the center.
uint32_t tiny_image_getchannels(const TinyImage *image)
Channels per pixel.
int tiny_image_rectangle(TinyImage *image, int32_t x, int32_t y, uint32_t width, uint32_t height, const uint8_t *pixel)
Draws the outline of a rectangle, one pixel wide.
int tiny_image_draw_image(TinyImage *dest_image, const TinyImage *src_image, int32_t x, int32_t y)
Draws one image onto another.
int tiny_display_translate(TinyDisplayList *list, float x, float y)
Moves the current transform.
TinyEffort
How much computation an operation may spend to do its best work.
Definition image.h:204
@ TINYIMG_EFFORT_FANCY
Spend what it takes to do the best work available.
Definition image.h:210
@ TINYIMG_EFFORT_FAST
Bound the search, take the cheaper kernel, stay inside a floor.
Definition image.h:218
int tiny_image_fit_with_padding(TinyImage *image, uint32_t target_width, uint32_t target_height, TinyImageFit fit_mode, const uint8_t *padding_color)
Resizes an image to fit within the specified target width and height according to the specified fit m...
int tiny_image_load(TinyImage *image, const uint8_t *buffer, size_t buffer_size)
Loads an image, decoding every pixel.
int tiny_image_palette(const TinyImage *image, uint32_t count, uint8_t *palette)
The colors a palette of the given size would hold.
int tiny_image_despeckle(TinyImage *image)
Replaces each pixel with the median of its 3x3 neighborhood.
int tiny_image_quality(TinyImage *image, int quality)
Sets the quality of the image for lossy formats (e.g., JPEG).
int tiny_image_polygon(TinyImage *image, const int32_t *x_points, const int32_t *y_points, size_t num_points, const uint8_t *pixel)
Draws the edges of a polygon, closing it.
int tiny_image_set_metadata(TinyImage *image, const char *key, const char *value)
Sets a custom metadata key-value pair for the image.
int tiny_image_split_tone(TinyImage *image, const uint8_t *shadow, const uint8_t *highlight, float balance)
Tints the shadows and the highlights differently.
int tiny_image_to_rgba(TinyImage *image)
Converts the image to RGBA format, adding an opaque alpha channel if there was none.
int tiny_image_corner_radius(TinyImage *image, uint32_t radius)
Rounds the image's corners by clearing what falls outside them.
int tiny_image_crop_polygon(TinyImage *image, const uint32_t *x_points, const uint32_t *y_points, size_t num_points)
Crops an image to a polygonal region defined by a series of points (x_points, y_points).
#define TINYIMG_DISPLAY_MAX_SHAPES
Definition image.h:1050
int tiny_image_gradient_fade(TinyImage *image, float angle, float start, float end)
Fades the image toward transparency along a direction.
TinyBlendMode
How a shape's color is combined with what is already there.
Definition image.h:565
@ TINYIMG_BLEND_ADD
Definition image.h:589
@ TINYIMG_BLEND_DARKEN
Definition image.h:577
@ TINYIMG_BLEND_HARD_LIGHT
Definition image.h:585
@ TINYIMG_BLEND_NORMAL
Definition image.h:567
@ TINYIMG_BLEND_OVERLAY
Definition image.h:575
@ TINYIMG_BLEND_DIFFERENCE
Definition image.h:581
@ TINYIMG_BLEND_SUBTRACT
Definition image.h:591
@ TINYIMG_BLEND_MULTIPLY
Definition image.h:571
@ TINYIMG_BLEND_LIGHTEN
Definition image.h:579
@ TINYIMG_BLEND_REPLACE
Definition image.h:569
@ TINYIMG_BLEND_EXCLUSION
Definition image.h:583
@ TINYIMG_BLEND_SOFT_LIGHT
Definition image.h:587
@ TINYIMG_BLEND_SCREEN
Definition image.h:573
int tiny_image_border(TinyImage *image, uint32_t border_width, const uint8_t *pixel)
Draws a border inside the image's edges.
int tiny_image_lighten(TinyImage *image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, float factor)
Lightens a specified rectangular region of the image by the given factor.
int tiny_image_auto_color(TinyImage *image)
Scales each channel so their means agree, which is a gray-world balance.
int tiny_image_dilate(TinyImage *image, uint32_t radius)
Replaces each pixel with the brightest in a radius.
TinyImagePreset
The named looks, each a fixed stack of the adjustments above.
Definition image.h:2156
@ TINYIMG_PRESET_MONO
Definition image.h:2162
@ TINYIMG_PRESET_NOIR
Definition image.h:2158
@ TINYIMG_PRESET_FADE
Definition image.h:2164
@ TINYIMG_PRESET_CHROME
Definition image.h:2160
@ TINYIMG_PRESET_TONAL
Definition image.h:2174
@ TINYIMG_PRESET_COOL
Definition image.h:2170
@ TINYIMG_PRESET_VIVID
Definition image.h:2166
@ TINYIMG_PRESET_WARM
Definition image.h:2168
@ TINYIMG_PRESET_INSTANT
Definition image.h:2172
int tiny_image_get_metadata_count(const TinyImage *image, size_t *count)
Retrieves the count of custom metadata key-value pairs in the image.
TinyImageFit
How an image is made to fit a target width and height.
Definition image.h:1702
@ TINYIMG_FIT_ASPECT_CROP
Crops to the target's extent without resampling.
Definition image.h:1739
@ TINYIMG_FIT_SCALE_DOWN
Fits inside the target without cropping or padding, and never enlarges.
Definition image.h:1711
@ TINYIMG_FIT_STRETCH
Scales each axis independently to the target, distorting the image.
Definition image.h:1768
@ TINYIMG_FIT_ASPECT_CONTAIN
Pads to the target's aspect ratio without resampling.
Definition image.h:1747
@ TINYIMG_FIT_CROP
Fills the target exactly, cropping the overflow, and never enlarges.
Definition image.h:1732
@ TINYIMG_FIT_PAD
Fits inside the target, then pads the shortfall with the background.
Definition image.h:1761
@ TINYIMG_FIT_FILL
Fills the target exactly, cropping the overflow, and never shrinks.
Definition image.h:1776
@ TINYIMG_FIT_SCALE_UP
Fits inside the target without cropping or padding, and never shrinks.
Definition image.h:1783
@ TINYIMG_FIT_CONTAIN
Fits inside the target without cropping or padding.
Definition image.h:1718
@ TINYIMG_FIT_ASPECT_COVER
Crops to the target's aspect ratio without resampling.
Definition image.h:1754
@ TINYIMG_FIT_COVER
Fills the target exactly, cropping whichever axis overflows.
Definition image.h:1724
int tiny_image_focus(const TinyImage *image, TinyImageGravity gravity, float *x, float *y)
Where the part of an image worth keeping is.
int tiny_image_auto_contrast(TinyImage *image)
Stretches the luminance so that a small fraction clips at each end.
int tiny_image_vibrance(TinyImage *image, float amount)
Raises saturation, and least where it is already high.
int tiny_image_fill_rounded_rectangle(TinyImage *image, int32_t x, int32_t y, uint32_t width, uint32_t height, uint32_t radius, const uint8_t *pixel)
Fills a rectangle whose corners are rounded.
int tiny_image_unsharp_mask(TinyImage *image, float sigma, float amount, float threshold)
Adds back a multiple of what a blur removed.
int tiny_image_remove_metadata(TinyImage *image, const char *key)
Removes a specific custom metadata key-value pair from the image.
uint32_t tiny_phash_distance(uint64_t first, uint64_t second)
How many bits two perceptual hashes differ in.
int tiny_image_colorblind_simulate(TinyImage *image, TinyColorblindKind kind)
Shows the image as a given color blindness would see it.
int tiny_image_drop_shadow(TinyImage *image, int32_t offset_x, int32_t offset_y, float sigma, const uint8_t *color)
Grows the image and puts a blurred silhouette of it behind.
int tiny_image_contrast(TinyImage *image, float factor)
Adjusts the contrast of the image.
int tiny_image_posterize(TinyImage *image, uint32_t levels)
Rounds every channel to a number of evenly spaced levels.
int tiny_image_zoom(TinyImage *image, float zoom_factor)
Zooms in or out of the image by the specified zoom factor.
int tiny_image_chromatic_aberration(TinyImage *image, float amount)
Offsets the red and blue channels radially.
#define TINYIMG_DISPLAY_MAX_POINTS
Definition image.h:1053
int tiny_image_apply_sepia(TinyImage *image)
Applies a sepia tone effect to the image.
int tiny_image_probe(const uint8_t *buffer, size_t buffer_size, TinyImageInfo *info)
Reads an image's header without decoding any pixels.
int tiny_image_get_exif(const TinyImage *image, char **exif_data, size_t *exif_size)
Retrieves the EXIF metadata from the image.
int tiny_image_invert(TinyImage *image)
Inverts the colors of an image, producing a negative effect.
int tiny_image_blackwhite(TinyImage *image)
Replaces every color channel with the pixel's luminance, keeping the channel count.
int tiny_image_trim(TinyImage *image, uint8_t tolerance)
Removes a uniform border by cropping to what differs from it.
int tiny_image_fill_polygon_with(TinyImage *image, const int32_t *x_points, const int32_t *y_points, size_t num_points, const uint8_t *pixel, TinyFillRule rule, TinyBlendMode blend)
Fills a polygon by a named rule, blended.
int tiny_image_fill_rectangle(TinyImage *image, int32_t x, int32_t y, uint32_t width, uint32_t height, const uint8_t *pixel)
Fills a rectangle.
int tiny_image_duotone(TinyImage *image, const uint8_t *shadow, const uint8_t *highlight)
Maps the tonal range between two colors.
int tiny_image_levels(TinyImage *image, float in_black, float in_white, float gamma, float out_black, float out_white)
Maps an input range onto an output range through a gamma.
TinyImageGravity
Which part of an image a crop keeps, or where a pad puts it.
Definition image.h:1795
@ TINYIMG_GRAVITY_EAST
Definition image.h:1805
@ TINYIMG_GRAVITY_CENTER
Definition image.h:1797
@ TINYIMG_GRAVITY_SOUTH_EAST
Definition image.h:1813
@ TINYIMG_GRAVITY_SOUTH_WEST
Definition image.h:1811
@ TINYIMG_GRAVITY_NORTH_EAST
Definition image.h:1809
@ TINYIMG_GRAVITY_NORTH
Definition image.h:1799
@ TINYIMG_GRAVITY_AUTO
Definition image.h:1815
@ TINYIMG_GRAVITY_NORTH_WEST
Definition image.h:1807
@ TINYIMG_GRAVITY_SOUTH
Definition image.h:1801
@ TINYIMG_GRAVITY_WEST
Definition image.h:1803
@ TINYIMG_GRAVITY_FACE
Definition image.h:1817
int tiny_image_has_metadata(const TinyImage *image, const char *key)
Checks if the image has a specific custom metadata key.
const char * tiny_format_extension(TinyImageFormat format)
Retrieves the conventional file extension of a format, leading dot included.
int tiny_image_composite(TinyImage *dest_image, const TinyImage *src_image, TinyBlendMode blend)
Composites one image over another in place, Porter-Duff source-over.
int tiny_image_premultiply(TinyImage *image)
Multiplies each color channel by its alpha.
int tiny_image_fit(TinyImage *image, uint32_t target_width, uint32_t target_height, TinyImageFit fit_mode)
Resizes an image to fit within the specified target width and height according to the specified fit m...
int tiny_image_dominant_color(const TinyImage *image, uint8_t *color)
The color the most pixels are closest to.
const char * tiny_format_name(TinyImageFormat format)
Retrieves the short name of a format, such as "png" or "jpeg".
int tiny_image_tint(TinyImage *image, const uint8_t *color, float strength)
Adds a color cast without touching the luminance.
int tiny_image_istransparent(const TinyImage *image)
Checks if the image has an alpha channel (transparency).
int tiny_image_crop(TinyImage *image, uint32_t x, uint32_t y, uint32_t crop_width, uint32_t crop_height)
Crops an image to the specified rectangle defined by the top-left corner (x, y) and the desired width...
int tiny_image_create(TinyImage *image, uint32_t width, uint32_t height, uint8_t channels)
Creates a new image with the specified width, height and channel count.
int tiny_image_erode(TinyImage *image, uint32_t radius)
Replaces each pixel with the darkest in a radius.
int tiny_image_arc(TinyImage *image, float degrees, const uint8_t *background)
Bends the image along an arc.
int tiny_image_shadows_highlights(TinyImage *image, float shadows, float highlights)
Recovers detail at both ends of the range.
int tiny_image_color_overlay(TinyImage *image, const uint8_t *color, float opacity)
Applies a color overlay to the image with the specified color and opacity.
TinyDrawMode
How a source image larger or smaller than its target is placed.
Definition image.h:621
@ TINYIMG_DRAW_CENTER
Definition image.h:627
@ TINYIMG_DRAW_TILE
Definition image.h:625
@ TINYIMG_DRAW_ONCE
Definition image.h:623
int tiny_image_curves(TinyImage *image, const uint8_t *x_points, const uint8_t *y_points, size_t num_points)
Applies a tone curve through the caller's control points.
int tiny_image_vline(TinyImage *image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, const uint8_t *pixel)
Draws a vertical run of pixels.
int tiny_image_destroy(TinyImage *image)
Destroys an image, freeing its associated memory.
int tiny_image_pixelate_faces(TinyImage *image, uint32_t size)
Pixelates whatever the detector finds and nothing else.
int tiny_image_improve(TinyImage *image)
Applies the auto corrections a photograph usually wants together.
int tiny_image_preset(TinyImage *image, TinyImagePreset preset)
Applies a named look.
int tiny_image_has_exif(const TinyImage *image)
Checks if the image has EXIF metadata.
int tiny_display_set_transform(TinyDisplayList *list, const float *matrix)
Sets the current transform outright.
int tiny_display_rotate(TinyDisplayList *list, float degrees)
Turns the current transform.
int tiny_image_pixelate(TinyImage *image, uint32_t size)
Averages the image over square blocks.
int tiny_image_sharpen(TinyImage *image, float amount)
Applies a sharpen effect to the image.
int tiny_image_dpr(TinyImage *image, float dpr)
Scales an image by a device pixel ratio.
int tiny_image_load_scaled(TinyImage *image, const uint8_t *buffer, size_t buffer_size, uint32_t max_width, uint32_t max_height)
Loads an image at the cheapest scale that still covers the given box.
int tiny_image_fill_light(TinyImage *image, float amount)
Lifts the shadows without moving the highlights.
TinyImageFormat tiny_image_getformat(const TinyImage *image)
Retrieves the format of the image.
int tiny_image_morphology_close(TinyImage *image, uint32_t radius)
Dilates then erodes, which fills dark specks.
int tiny_image_to_rgb(TinyImage *image)
Converts the image to RGB format.
int tiny_image_dither(TinyImage *image, uint32_t levels)
Quantizes through an ordered threshold matrix.
int tiny_image_rotate(TinyImage *image, float degrees, const uint8_t *background)
Turns the image by any angle.
uint8_t * tiny_image_getdata(const TinyImage *image)
Pointer to an image's pixel data.
int tiny_image_solarize(TinyImage *image, uint8_t level)
Inverts only the channels above a level.
int tiny_image_histogram(const TinyImage *image, uint8_t channel, uint32_t *bins)
Counts how many pixels fall in each of 256 buckets.
int tiny_image_blur_region(TinyImage *image, uint32_t x, uint32_t y, uint32_t width, uint32_t height, float sigma)
Blurs inside a rectangle only.
int tiny_image_saturation(TinyImage *image, float factor)
Adjusts the saturation of the image.
int tiny_image_clarity(TinyImage *image, float amount)
Raises local contrast, which is an unsharp mask at a large radius.
int tiny_image_channel_mixer(TinyImage *image, const float *matrix)
Rebuilds each output channel from a weighted sum of the inputs.
Options a decoder honors when only part of an image is wanted.
Definition image.h:151
uint32_t y
Definition image.h:155
uint8_t scale_den
Definition image.h:161
uint8_t effort
How much computation the decoder may spend; a TinyEffort.
Definition image.h:182
uint32_t height
Definition image.h:159
uint32_t x
Definition image.h:153
uint8_t channels
Definition image.h:163
uint32_t width
Definition image.h:157
A list of shapes that rasterizes once.
Definition image.h:1114
TinyBlendMode blend
Definition image.h:1133
uint32_t count
Definition image.h:1116
float transform[6]
Definition image.h:1126
TinyShape shapes[TINYIMG_DISPLAY_MAX_SHAPES]
Definition image.h:1118
float stack[TINYIMG_DISPLAY_MAX_DEPTH][6]
Definition image.h:1130
uint32_t culled
Definition image.h:1136
uint32_t depth
Definition image.h:1128
uint32_t points
Definition image.h:1121
uint32_t covered
Definition image.h:1138
float point[TINYIMG_DISPLAY_MAX_POINTS *2]
Definition image.h:1123
Options an encoder honors.
Definition image.h:224
uint8_t lossless
Definition image.h:228
uint8_t effort
How much computation the encoder may spend; a TinyEffort.
Definition image.h:239
uint8_t quality
Definition image.h:226
uint8_t strip_metadata
Definition image.h:232
uint8_t progressive
Definition image.h:230
What a format's header says about an image, before any pixel is decoded.
Definition image.h:119
uint8_t progressive
Definition image.h:135
TinyImageFormat format
Definition image.h:127
uint32_t frames
Definition image.h:125
uint8_t bit_depth
Definition image.h:131
uint8_t has_alpha
Definition image.h:133
uint32_t width
Definition image.h:121
uint32_t height
Definition image.h:123
uint8_t channels
Definition image.h:129
Represents an image with its width, height, and pixel data.
Definition image.h:90
TinyImageMeta * meta
Definition image.h:104
uint8_t quality
Definition image.h:98
TinyImageFormat format
Definition image.h:100
uint8_t channels
Definition image.h:96
uint32_t height
Definition image.h:94
uint8_t * data
Definition image.h:102
uint32_t width
Definition image.h:92
TinyShapeKind kind
Definition image.h:1078
float transform[6]
The transform in force when the shape was added, as a 2x3 affine.
Definition image.h:1098
uint32_t point_count
Definition image.h:1084
uint32_t point_first
Definition image.h:1082
TinyBlendMode blend
Definition image.h:1088
float geometry[5]
Definition image.h:1080
TinyFillRule rule
Definition image.h:1090
uint8_t color[4]
Definition image.h:1086
A grow on demand byte sink.
Definition util.h:389
Umbrella header, version and error codes.
Math shims, lookup table builders, checksums and bit level IO.