-/* Similarity search tree... will be changed */
-struct image_tree {
- uns count; /* Number of images in the tree */
- uns depth; /* Tree depth */
- struct image_bbox bbox; /* Bounding box containing all the */
- struct image_node *nodes; /* Internal nodes */
- struct image_leaf *leaves; /* Leaves */
+struct image *image_new(struct image_thread *it, uns cols, uns rows, uns flags, struct mempool *pool);
+struct image *image_clone(struct image_thread *it, struct image *src, uns flags, struct mempool *pool);
+void image_destroy(struct image *img);
+void image_clear(struct image_thread *it, struct image *img);
+struct image *image_init_matrix(struct image_thread *it, struct image *img, byte *pixels, uns cols, uns rows, uns row_size, uns flags);
+struct image *image_init_subimage(struct image_thread *it, struct image *img, struct image *src, uns left, uns top, uns cols, uns rows);
+
+static inline int
+image_dimensions_valid(uns cols, uns rows)
+{
+ return cols && rows && cols <= IMAGE_MAX_SIZE && rows <= IMAGE_MAX_SIZE;
+}
+
+byte *color_space_to_name(enum color_space cs);
+byte *image_channels_format_to_name(uns format);
+uns image_name_to_channels_format(byte *name);
+
+struct color {
+ byte c[3];
+ byte color_space;
+} PACKED;
+
+/* scale.c */
+
+int image_scale(struct image_thread *thread, struct image *dest, struct image *src);
+void image_dimensions_fit_to_box(u32 *cols, u32 *rows, u32 max_cols, u32 max_rows, uns upsample);
+
+/* alpha.c */
+
+int image_apply_background(struct image_thread *thread, struct image *dest, struct image *src, struct color *background);
+
+/* image-io.c */
+
+enum image_format {
+ IMAGE_FORMAT_UNDEFINED,
+ IMAGE_FORMAT_JPEG,
+ IMAGE_FORMAT_PNG,
+ IMAGE_FORMAT_GIF,
+ IMAGE_FORMAT_MAX