Spectrum

Spectrum

  • About Spectrum
  • Getting Started
  • GitHub

›Contributing

Intro

  • About Spectrum

Getting Started

  • Getting Started on Android
  • Getting Started on iOS
  • Sample Apps

Concepts

  • Supported Image Flows
  • Supported Image Formats

Using Spectrum

  • Transcoding Images for Upload
  • Resizing Images
  • Cropping Images
  • Rotating Images
  • Encoding Images
  • FAQ

Contributing

  • Project Structure
  • Contributing on Android
  • Contributing on iOS

Project Structure

The repository’s structure revolves around three main components: the C++ core library and the Android and iOS wrappers. Each of them comes with unit and integration tests plus a sample app per wrapper. The core C++ library contains all the shared code. Subsequently, the Android and iOS wrappers mirror the core's API.

C++

The C++ library is depended upon by both wrappers.

  • cpp/spectrum/: Contains the core library implementation including the C++ API, internal models and all necessary code for decision making.
    • plugins/: Subfolders contain bundled codecs (e.g. JPEG, PNG & WebP). They are excluded from the main compilation target and form separate build targets.
    • test/: GTests for both the code library and bundled plugins.
    • testutils/: Additional helpers that are used by the tests.

Android

The Android wrapper is built in Java and calls the shared C++ code through a JNI layer. The build is setup using Gradle. See the Contributing on Android section for more details.

  • android/src/main/java: Contains the public Alchemist API and the calls into the JNI layer.
  • android/src/main/cpp/: The JNI integration that converts between the Java objects and C++ types.
  • android/src/test/: Unit tests for the Alchemist API.
  • android/src/androidTest/: Integration tests that both perform end-to-end tests using SSIM comparison and particular checks of JNI conversions. Not yet open-sourced.
  • android/sample/src/main/: A sample app that demonstrates how to integrate Alchemist into your project.
  • androidLibs/fbjni: Internal library in (mostly) C++ that helps to write readable and correct JNI code.
  • androidLibs/third-party: Destination for all external libraries (e.g. mozjpeg). They are downloaded during build and patched with our configuration.
  • **/CMakeLists.txt: We use the NDK’s preferred CMake build system. The CMake build files are found both for the JNI layer, external libraries, and the core library (see above) throughout the repository.

iOS

The iOS wrapper is built in Objective-C++ and calls the C++ library directly. It currently only supports CocoaPods as a dependency manager. See the Contributing on iOS section for more details.

  • ios/SpectrumKit/: The framework's root folder.
    • SpectrumKit/: Sources of the main target.
    • SpectrumKitPlugins/: Subfolders contain Objective-C bundled codecs.
    • SpectrumKitTests/: Wrapper's unit tests.
    • SpectrumKitInstrumentationTests/: Wrapper's integration tests.
    • SpectrumKitInstrumentationTestsHelpers/: Helpers for the integration tests.
  • ios/SpectrumKitSample/: SpectrumKit's sample app.
← FAQContributing on Android →
  • C++
  • Android
  • iOS
Spectrum
Docs
About SpectrumGetting StartedContributing
Community
FacebookTwitter
Legal
Terms of UseData PolicyCookie Policy
More
GitHubStar
Facebook Open Source
Copyright © 2022 Facebook