GithubHelp home page GithubHelp logo

happyseafox / sail Goto Github PK

View Code? Open in Web Editor NEW
306.0 7.0 22.0 21.42 MB

The missing small and fast image decoding library for humans (not for machines) ⛵ https://sail.software

License: MIT License

C 77.23% CMake 4.46% C++ 18.32%
image-decoding image-encoding jpeg png apng image-library tiff image-codecs gif gif-animation bmp avif webp tga jpeg2000 svg pcx qoi

sail's Introduction

Squirrel Abstract Image Library

The missing fast and easy-to-use image decoding library for humans (not for machines).

Travis Build Status Latest release Buy me a coffee

Target AudienceFeaturesImage FormatsGetting StartedFAQ

SAIL is a format-agnostic cross-platform image decoding library providing rich APIs, from one-liners to complex use cases with custom I/O sources. It enables a client to load and save static, animated, multi-paged images along with their meta data and ICC profiles. ⛵

GIF Demo Screenshot

Target audience

  • Image viewers
  • Game developers
  • Anyone who needs to load or save images in different image formats with a clean and comprehensive API

Features overview

  • Easy-to-use thread-safe C and C++ interfaces
  • Versatile APIs: junior, advanced, deep diver, and technical diver
  • Input/output: files, memory, custom I/O streams
  • Load by file suffixes, paths, and magic numbers
  • Save pixels as close as possible to the source
  • Codec-specific tuning options like PNG filters. See FORMATS
  • Meta data support: text comments, EXIF, ICC profiles
  • Access to the image properties w/o decoding pixels (probing)
  • Access to the source image properties
  • Adding or updating image codecs with ease demonstrated by Intel [*]
  • The best MIME icons in the computer industry 😄

* One day Intel demonstrated the advantages of their IPP technology in speeding up decoding JPEG and JPEG 2000 images with the help of ksquirrel-libs, the predecessor of SAIL.

Features NOT provided

  • Image editing capabilities (filtering, distortion, scaling, etc.)
  • Color space conversion functions
  • Color management functions (applying ICC profiles etc.)
  • EXIF rotation

Supported image formats

N Image format Operations Dependencies
1 APNG R libpng+APNG patch
2 AVIF R libavif
3 BMP R
4 GIF R giflib
.. ...
6 JPEG RW libjpeg-turbo
7 JPEG 2000 R jasper
8 JPEG XL R libjxl
9 PCX R
10 PNG RW libpng
.. ...
12 PSD R
13 QOI RW
14 SVG R resvg
15 TGA R
16 TIFF RW libtiff
.. ...
18 WEBP R libwebp
.. ...

See the full list here. Work to add more image formats is ongoing.

Benchmarks

Benchmark

Time to load and output default pixels (without explicit conversion) was measured. See BENCHMARKS.

Preferred installation method

  • Windows: Conan, vcpkg
  • macOS: brew, Conan, vcpkg
  • Linux: native packages if available, Conan, vcpkg

See BUILDING.

APIs overview

SAIL provides four levels of APIs, depending on your needs. Let's have a quick look at the junior level.

C:

struct sail_image *image;

SAIL_TRY(sail_load_from_file(path, &image));

/*
 * Handle the image pixels here.
 * Use image->width, image->height, image->bytes_per_line,
 * image->pixel_format, and image->pixels for that.
 *
 * In particular, you can convert it to a different pixel format with functions
 * from libsail-manip. With sail_convert_image(), for example.
 */

sail_destroy_image(image);

C++:

sail::image image(path);

// Handle the image and its pixels here.
// Use image.width(), image.height(), image.bytes_per_line(),
// image.pixel_format(), and image.pixels() for that.
//
// In particular, you can convert it to a different pixel format with image::convert().

It's pretty easy, isn't it? 😄 See also FAQ.

Programming languages

Programming language: C11
Bindings: C++11

Competitors

Differences from other image decoding libraries

  • Easily extensible with new image format plugins
  • Easy-to-use API providing expected business entities - images, palettes, pixels etc.
  • Access to source pixel data (supported by the most codecs)
  • Access to the image properties w/o decoding pixel data (probing)

Have questions or issues?

Opening a GitHub issue is the preferred way of communicating and solving problems.

See FAQ for more.

Architecture overview

SAIL is written in pure C11 w/o using any third-party libraries (except for codecs). It also provides bindings to C++.

SAIL codecs

SAIL codecs is the deepest level. This is a set of standalone, dynamically loaded codecs (SO on Linux and DLL on Windows). They implement actual decoding and encoding capabilities. End-users never work with codecs directly. They always use abstract, high-level APIs in libsail for that.

Every codec is accompanied with a so called codec info (description) file which is just a plain text file. It describes what the codec can actually do: what pixel formats it can load and output, what compression types it supports, and more.

By default, SAIL loads codecs on demand. To preload them, use sail_init_with_flags(SAIL_FLAG_PRELOAD_CODECS).

libsail-common

libsail-common holds common data types (images, pixel formats, I/O abstractions etc.) and a small set of functions shared between SAIL codecs and the high-level APIs in libsail.

libsail

libsail is a feature-rich, high-level API. It provides comprehensive and lightweight interfaces to decode and encode images. End-users implementing C applications always work with libsail.

libsail-manip

libsail-manip is a collection of image manipulation functions. For example, conversion functions from one pixel format to another.

libsail-c++

libsail-c++ is a C++ binding to libsail. End-users implementing C++ applications may choose between libsail and libsail-c++. Using libsail-c++ is always recommended, as it's much more simple to use in C++ applications.

Building

See BUILDING.

Philosophy

Philosophy of SAIL is modularization and simplicity.

Image codecs are architectured to be standalone dynamically loaded files. Any future hypothetical improvements will be implemented as separate client libraries. So a user is always able to choose what to use (i.e. to link against) and what not to use.

Support

If you like the project, please consider starring the repository.

Author

Dmitry Baryshev

License

Released under the MIT license.

Copyright (c) 2020-2023 Dmitry Baryshev

The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

sail's People

Contributors

happyseafox avatar lgtm-migrator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sail's Issues

vcpkg include directories incorrect

It seems that when installing using vcpkg, the headers expect that the include root is in the sail directory, but vcpkg places the includes under sail. To include something in your own project, you need

#include <sail/sail-c++/sail-c++.h>

but the sail headers includes other sail headers as

#include <sail-c++/...>

Am I missing something here? Was this project updated since it was set up for vcpkg that caused this?

[Documentation / FAQ] Could a short subsection be added for ksquirrel versus sail?

Hey there,

I just found this project. I had ksquirrel in my local database for programs; ruby handles this.

I noticed I have not updated ksquirrel in 7 years so I checked whether it was still alive.

That was how I found sail. Now I have not yet tried to compile sail, will do in a bit,
but do you think it may be possible to briefly mention the main differences between
ksquirrel and sail in the FAQ?

https://github.com/smoked-herring/sail/blob/master/FAQ.md

This does not have to be long; just perhaps a sentence or two explaining the main
differences (I assume qt version and kde version?) and perhaps any other larger
difference between the two projects. Thank you for reading and perhaps considering!

Implement more tests

Ideas:

  • check all codecs have the same layout version
  • check all codecs could be loaded
  • decode/encode with reference data
  • all codecs have RGB and RGBA output
  • mem and file I/O sources output the same data

Lua style custom allocators

Tried a search for alloc but that brought up a lot of junk results that didn't match what I was looking for, when lua is first initialised in C it provides the option of setting a custom allocator and user data where the allocator is of the form void * Alloc( void *ud, void *ptr, size_t size, size_t want ) where ud is ignored by the default allocator and only used by a user supplied allocator, this is helpful when multi-threading as I can pass the threads object to the ud parameter which can then communicate the desire for memory to the main thread which handles the allocations instead, avoiding potential collisions when 2 or more threads try to re-allocate memory as they can just all have the same pointer & size reported to them after each re-allocation request is processed, also makes garbage collection easier.

Does SAIL have something similar? If not I'll have to write my own custom image loading functions, I'd prefer to not do that though as I'm trying to keep my graphic studies to just the graphics and not the formats (only recently learned how to use index buffers and am now trying to learn how to use textures).

SAIL_ERROR_CODEC_NOT_FOUND when installing via vckpkg on windows

config.h shows that the codecs should be stored in path "...\vcpkg\packages\sail_x64-windows-static\lib\sail\codecs"
However no such folder or file named sail\codecs exists in path "...\vcpkg\packages\sail_x64-windows-static\lib\"

I am just trying to read a jpg or png file, but I keep getting the codec not found error. I have only tried x64-windows-static and x64-windows versions however.

Refactor enumerating codecs in combined mode

Now it's required to open sail-codecs.dll on Windows and the current module on Linux to enumerate codec functions. What about building a list of these functions during build and generating a source file with them? This way we can avoid opening any DLLs. Like that

{
  "JPEG", { jpeg_sail_read_init_v5, ...},
}

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.