imgsmlr
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
imgsmlr | 1.0 | FEAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2830 | imgsmlr | No | Yes | No | Yes | No | Yes | - |
| Related | age hll rum pg_graphql pg_jsonschema jsquery pg_hint_plan hypopg |
|---|
breaks on el10
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0 | 1817161514 | imgsmlr | - |
| RPM | PIGSTY | 1.0 | 1817161514 | imgsmlr_$v | - |
| DEB | PIGSTY | 1.0 | 1817161514 | postgresql-$v-imgsmlr | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.0 el8.x86_64.pg18 : imgsmlr_18 imgsmlr_18-1.0-2PIGSTY.el8.x86_64.rpm
| PIGSTY 1.0 el8.x86_64.pg17 : imgsmlr_17 imgsmlr_17-1.0-2PIGSTY.el8.x86_64.rpm
| PIGSTY 1.0 el8.x86_64.pg16 : imgsmlr_16 imgsmlr_16-1.0-2PIGSTY.el8.x86_64.rpm
| PIGSTY 1.0 el8.x86_64.pg15 : imgsmlr_15 imgsmlr_15-1.0-2PIGSTY.el8.x86_64.rpm
| PIGSTY 1.0 el8.x86_64.pg14 : imgsmlr_14 imgsmlr_14-1.0-2PIGSTY.el8.x86_64.rpm
|
| el8.aarch64 | PIGSTY 1.0 el8.aarch64.pg18 : imgsmlr_18 imgsmlr_18-1.0-2PIGSTY.el8.aarch64.rpm
| PIGSTY 1.0 el8.aarch64.pg17 : imgsmlr_17 imgsmlr_17-1.0-2PIGSTY.el8.aarch64.rpm
| PIGSTY 1.0 el8.aarch64.pg16 : imgsmlr_16 imgsmlr_16-1.0-2PIGSTY.el8.aarch64.rpm
| PIGSTY 1.0 el8.aarch64.pg15 : imgsmlr_15 imgsmlr_15-1.0-2PIGSTY.el8.aarch64.rpm
| PIGSTY 1.0 el8.aarch64.pg14 : imgsmlr_14 imgsmlr_14-1.0-2PIGSTY.el8.aarch64.rpm
|
| el9.x86_64 | PIGSTY 1.0 el9.x86_64.pg18 : imgsmlr_18 imgsmlr_18-1.0-2PIGSTY.el9.x86_64.rpm
| PIGSTY 1.0 el9.x86_64.pg17 : imgsmlr_17 imgsmlr_17-1.0-2PIGSTY.el9.x86_64.rpm
| PIGSTY 1.0 el9.x86_64.pg16 : imgsmlr_16 imgsmlr_16-1.0-2PIGSTY.el9.x86_64.rpm
| PIGSTY 1.0 el9.x86_64.pg15 : imgsmlr_15 imgsmlr_15-1.0-2PIGSTY.el9.x86_64.rpm
| PIGSTY 1.0 el9.x86_64.pg14 : imgsmlr_14 imgsmlr_14-1.0-2PIGSTY.el9.x86_64.rpm
|
| el9.aarch64 | PIGSTY 1.0 el9.aarch64.pg18 : imgsmlr_18 imgsmlr_18-1.0-2PIGSTY.el9.aarch64.rpm
| PIGSTY 1.0 el9.aarch64.pg17 : imgsmlr_17 imgsmlr_17-1.0-2PIGSTY.el9.aarch64.rpm
| PIGSTY 1.0 el9.aarch64.pg16 : imgsmlr_16 imgsmlr_16-1.0-2PIGSTY.el9.aarch64.rpm
| PIGSTY 1.0 el9.aarch64.pg15 : imgsmlr_15 imgsmlr_15-1.0-2PIGSTY.el9.aarch64.rpm
| PIGSTY 1.0 el9.aarch64.pg14 : imgsmlr_14 imgsmlr_14-1.0-2PIGSTY.el9.aarch64.rpm
|
| el10.x86_64 | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el10.aarch64 | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| d12.x86_64 | PIGSTY 1.0 d12.x86_64.pg18 : postgresql-18-imgsmlr postgresql-18-imgsmlr_1.0-1PIGSTY~bookworm_amd64.deb
| PIGSTY 1.0 d12.x86_64.pg17 : postgresql-17-imgsmlr postgresql-17-imgsmlr_1.0-1PIGSTY~bookworm_amd64.deb
| PIGSTY 1.0 d12.x86_64.pg16 : postgresql-16-imgsmlr postgresql-16-imgsmlr_1.0-1PIGSTY~bookworm_amd64.deb
| PIGSTY 1.0 d12.x86_64.pg15 : postgresql-15-imgsmlr postgresql-15-imgsmlr_1.0-1PIGSTY~bookworm_amd64.deb
| PIGSTY 1.0 d12.x86_64.pg14 : postgresql-14-imgsmlr postgresql-14-imgsmlr_1.0-1PIGSTY~bookworm_amd64.deb
|
| d12.aarch64 | PIGSTY 1.0 d12.aarch64.pg18 : postgresql-18-imgsmlr postgresql-18-imgsmlr_1.0-1PIGSTY~bookworm_arm64.deb
| PIGSTY 1.0 d12.aarch64.pg17 : postgresql-17-imgsmlr postgresql-17-imgsmlr_1.0-1PIGSTY~bookworm_arm64.deb
| PIGSTY 1.0 d12.aarch64.pg16 : postgresql-16-imgsmlr postgresql-16-imgsmlr_1.0-1PIGSTY~bookworm_arm64.deb
| PIGSTY 1.0 d12.aarch64.pg15 : postgresql-15-imgsmlr postgresql-15-imgsmlr_1.0-1PIGSTY~bookworm_arm64.deb
| PIGSTY 1.0 d12.aarch64.pg14 : postgresql-14-imgsmlr postgresql-14-imgsmlr_1.0-1PIGSTY~bookworm_arm64.deb
|
| d13.x86_64 | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| d13.aarch64 | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| u22.x86_64 | PIGSTY 1.0 u22.x86_64.pg18 : postgresql-18-imgsmlr postgresql-18-imgsmlr_1.0-1PIGSTY~jammy_amd64.deb
| PIGSTY 1.0 u22.x86_64.pg17 : postgresql-17-imgsmlr postgresql-17-imgsmlr_1.0-1PIGSTY~jammy_amd64.deb
| PIGSTY 1.0 u22.x86_64.pg16 : postgresql-16-imgsmlr postgresql-16-imgsmlr_1.0-1PIGSTY~jammy_amd64.deb
| PIGSTY 1.0 u22.x86_64.pg15 : postgresql-15-imgsmlr postgresql-15-imgsmlr_1.0-1PIGSTY~jammy_amd64.deb
| PIGSTY 1.0 u22.x86_64.pg14 : postgresql-14-imgsmlr postgresql-14-imgsmlr_1.0-1PIGSTY~jammy_amd64.deb
|
| u22.aarch64 | PIGSTY 1.0 u22.aarch64.pg18 : postgresql-18-imgsmlr postgresql-18-imgsmlr_1.0-1PIGSTY~jammy_arm64.deb
| PIGSTY 1.0 u22.aarch64.pg17 : postgresql-17-imgsmlr postgresql-17-imgsmlr_1.0-1PIGSTY~jammy_arm64.deb
| PIGSTY 1.0 u22.aarch64.pg16 : postgresql-16-imgsmlr postgresql-16-imgsmlr_1.0-1PIGSTY~jammy_arm64.deb
| PIGSTY 1.0 u22.aarch64.pg15 : postgresql-15-imgsmlr postgresql-15-imgsmlr_1.0-1PIGSTY~jammy_arm64.deb
| PIGSTY 1.0 u22.aarch64.pg14 : postgresql-14-imgsmlr postgresql-14-imgsmlr_1.0-1PIGSTY~jammy_arm64.deb
|
| u24.x86_64 | PIGSTY 1.0 u24.x86_64.pg18 : postgresql-18-imgsmlr postgresql-18-imgsmlr_1.0-1PIGSTY~noble_amd64.deb
| PIGSTY 1.0 u24.x86_64.pg17 : postgresql-17-imgsmlr postgresql-17-imgsmlr_1.0-1PIGSTY~noble_amd64.deb
| PIGSTY 1.0 u24.x86_64.pg16 : postgresql-16-imgsmlr postgresql-16-imgsmlr_1.0-1PIGSTY~noble_amd64.deb
| PIGSTY 1.0 u24.x86_64.pg15 : postgresql-15-imgsmlr postgresql-15-imgsmlr_1.0-1PIGSTY~noble_amd64.deb
| PIGSTY 1.0 u24.x86_64.pg14 : postgresql-14-imgsmlr postgresql-14-imgsmlr_1.0-1PIGSTY~noble_amd64.deb
|
| u24.aarch64 | PIGSTY 1.0 u24.aarch64.pg18 : postgresql-18-imgsmlr postgresql-18-imgsmlr_1.0-1PIGSTY~noble_arm64.deb
| PIGSTY 1.0 u24.aarch64.pg17 : postgresql-17-imgsmlr postgresql-17-imgsmlr_1.0-1PIGSTY~noble_arm64.deb
| PIGSTY 1.0 u24.aarch64.pg16 : postgresql-16-imgsmlr postgresql-16-imgsmlr_1.0-1PIGSTY~noble_arm64.deb
| PIGSTY 1.0 u24.aarch64.pg15 : postgresql-15-imgsmlr postgresql-15-imgsmlr_1.0-1PIGSTY~noble_arm64.deb
| PIGSTY 1.0 u24.aarch64.pg14 : postgresql-14-imgsmlr postgresql-14-imgsmlr_1.0-1PIGSTY~noble_arm64.deb
|
Build
You can build the RPM / DEB packages for imgsmlr using pig build:
pig build pkg imgsmlr # build RPM / DEB packages
Install
You can install imgsmlr directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install imgsmlr; # Install for current active PG version
pig ext install -y imgsmlr -v 18 # PG 18
pig ext install -y imgsmlr -v 17 # PG 17
pig ext install -y imgsmlr -v 16 # PG 16
pig ext install -y imgsmlr -v 15 # PG 15
pig ext install -y imgsmlr -v 14 # PG 14
dnf install -y imgsmlr_18 # PG 18
dnf install -y imgsmlr_17 # PG 17
dnf install -y imgsmlr_16 # PG 16
dnf install -y imgsmlr_15 # PG 15
dnf install -y imgsmlr_14 # PG 14
apt install -y postgresql-18-imgsmlr # PG 18
apt install -y postgresql-17-imgsmlr # PG 17
apt install -y postgresql-16-imgsmlr # PG 16
apt install -y postgresql-15-imgsmlr # PG 15
apt install -y postgresql-14-imgsmlr # PG 14
Create Extension:
CREATE EXTENSION imgsmlr;
Usage
imgsmlr: similar images search for PostgreSQL using Haar wavelet transform
The imgsmlr extension implements similar image searching functionality based on Haar wavelet transforms. It provides two data types and functions for converting images into searchable signatures.
CREATE EXTENSION imgsmlr;
Data Types
| Datatype | Storage Length | Description |
|---|---|---|
pattern | 16388 bytes | Result of Haar wavelet transform on the image |
signature | 64 bytes | Short representation of pattern for fast GiST index searches |
Functions
| Function | Return Type | Description |
|---|---|---|
jpeg2pattern(bytea) | pattern | Convert JPEG image data into pattern |
png2pattern(bytea) | pattern | Convert PNG image data into pattern |
gif2pattern(bytea) | pattern | Convert GIF image data into pattern |
pattern2signature(pattern) | signature | Create signature from pattern |
shuffle_pattern(pattern) | pattern | Shuffle pattern for less sensitivity to image shift |
Operators
| Operator | Left | Right | Return | Description |
|---|---|---|---|---|
<-> | pattern | pattern | float8 | Euclidean distance between two patterns |
<-> | signature | signature | float8 | Euclidean distance between two signatures |
The signature type supports GiST indexing with KNN on the <-> operator.
Example
Create a table of patterns and signatures from JPEG images:
CREATE TABLE pat AS (
SELECT
id,
shuffle_pattern(pattern) AS pattern,
pattern2signature(pattern) AS signature
FROM (
SELECT id, jpeg2pattern(data) AS pattern
FROM image
) x
);
ALTER TABLE pat ADD PRIMARY KEY (id);
CREATE INDEX pat_signature_idx ON pat USING gist (signature);
Search for the top 10 similar images to a given image:
SELECT id, smlr
FROM (
SELECT
id,
pattern <-> (SELECT pattern FROM pat WHERE id = :id) AS smlr
FROM pat
WHERE id <> :id
ORDER BY signature <-> (SELECT signature FROM pat WHERE id = :id)
LIMIT 100
) x
ORDER BY x.smlr ASC
LIMIT 10;
The inner query selects the top 100 candidates by signature using the GiST index. The outer query refines to the top 10 by pattern distance.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.