Git Product home page Git Product logo

rafaelfess / sparrowdb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sparrowdb/sparrowdb

0.0 1.0 0.0 1.03 MB

SparrowDB is an image database that works like an append-only object store. Sparrow has tools that allow image processing and HTTP server to access images

Home Page: https://sparrowdb.github.io/sparrowdb/

License: MIT License

Go 74.21% Lua 0.51% JavaScript 11.36% HTML 13.28% Shell 0.32% Batchfile 0.33%

sparrowdb's Introduction

Golang logo

GoDoc Build Status Go Report Card

Whats is SparrowDB?

SparrowDB is an image database that works like an append-only object store. Sparrow has tools that allow image processing and HTTP server to access images.

Sparrow Object Store

Sparrow consists of three files – the actual Sparrow store file containing the images data, plus an index file and a bloom filter file.

There is a corresponding data definition record followed by the image bytes for each image in the storage file. The index file provides the offset of the data definition in the storage file.

Features

  1. Built-in HTTP API so you don't have to write any server side code to get up and running.
  2. Optimizations for image storing.
  3. Web Admin Panel.
  4. Create scripts with Lua for image processing.

Getting started

This short guide will walk you through getting a basic server up and running, and demonstrate some simple reads and writes.

Using Sparrow

Creating a database:

curl -X PUT http://127.0.0.1:8081/api/database_name

Show databases:

curl -X GET http://127.0.0.1:8081/api/_all

Sending an image to database:

curl -i -X PUT -H "Content-Type: multipart/form-data"  \
    -F "[email protected]" \
    http://127.0.0.1:8081/api/database_name/image_key

Querying an image:

curl -X GET http://127.0.0.1:8081/api/database_name/image_key

Accessing image from browser:

http://localhost:8081/g/database_name/image_key

Token

If is set in database configuration file, generate_token = true, SparrowDB will generate a token for each image uploaded. The token’s value is randomly assigned by and stored in database. The token effectively eliminates attacks aimed at guessing valid URLs for photos.

Accessing image from browser with token:

http://localhost:8081/g/database_name/image_key/token_value

Image Processing

SparrowDB uses bild to allow image processing using LUA script.

All SparrowDB scripts must be in 'scripts' folder.

Example of script with image effect:

-- If image name contains gray, use grayscale effect
if string.match(imageCtx:name(), "gray") then
    imageCtx:grayscale()
end

-- If image name contains blue, use gaussian blur effect
if string.match(imageCtx:name(), "blur") then
    imageCtx:gaussianBlur(3.0)
end

Example of script with pixel iteration:

-- create an editable image
p = sparrowRGBA.new(imageCtx)

-- get image bounds
b = p:bounds()

-- iterate over pixels
for i = 0, b['width'] do
    for j = 0, b['height'] do
        -- get current pixel color: red, green, blue, alpha
        v = p:getPixel(i, j)

        -- set current pixel color: red, green, blue, alpha
        p:setPixel(i, j, v['red'], v['green'], v['blue'], v['alpha'])
    end
end

-- set processed image as outputsss
imageCtx:setOutput(p)

License

This software is under MIT license.

sparrowdb's People

Contributors

mausimag avatar pmoneda avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.