Convert Figma logo to code with AI

zhihu logoMatisse

:fireworks: A well-designed local image and video selector for Android

12,516
2,067
12,516
463

Top Related Projects

34,636

An image loading and caching library for Android focused on smooth scrolling

18,710

A powerful image downloading and caching library for Android

17,070

An Android library for managing images and the memory they use.

10,727

Image loading for Android and Compose Multiplatform.

Powerful and flexible library for loading, caching and displaying images on Android.

18,777

Implementation of ImageView for Android that supports zooming, by various touch gestures.

Quick Overview

Matisse is an Android library for selecting images and videos from the device's gallery or capturing them with the camera. It provides a customizable UI for media selection, supports multiple file types, and offers various configuration options for developers to integrate into their Android applications.

Pros

  • Customizable UI with material design principles
  • Supports both image and video selection
  • Offers multiple configuration options (e.g., max selectable items, file types)
  • Easy integration with existing Android projects

Cons

  • Limited to Android platform
  • May require additional setup for certain features (e.g., camera capture)
  • Documentation is primarily in Chinese, which may be challenging for non-Chinese speakers
  • Last updated in 2019, potentially lacking support for newer Android versions

Code Examples

  1. Basic usage for selecting images:
Matisse.from(this)
    .choose(MimeType.ofImage())
    .countable(true)
    .maxSelectable(9)
    .imageEngine(GlideEngine())
    .forResult(REQUEST_CODE_CHOOSE)
  1. Configuring for video selection:
Matisse.from(this)
    .choose(MimeType.ofVideo())
    .countable(false)
    .maxSelectable(1)
    .spanCount(4)
    .imageEngine(GlideEngine())
    .forResult(REQUEST_CODE_CHOOSE)
  1. Customizing the UI theme:
Matisse.from(this)
    .choose(MimeType.ofAll())
    .theme(R.style.CustomMatisseTheme)
    .countable(true)
    .maxSelectable(5)
    .imageEngine(GlideEngine())
    .forResult(REQUEST_CODE_CHOOSE)

Getting Started

  1. Add the Matisse dependency to your app's build.gradle:
dependencies {
    implementation 'com.zhihu.android:matisse:0.5.3-beta3'
}
  1. Initialize Matisse in your activity or fragment:
private val REQUEST_CODE_CHOOSE = 23

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    findViewById<Button>(R.id.button_select).setOnClickListener {
        Matisse.from(this)
            .choose(MimeType.ofImage())
            .countable(true)
            .maxSelectable(9)
            .imageEngine(GlideEngine())
            .forResult(REQUEST_CODE_CHOOSE)
    }
}
  1. Handle the result in onActivityResult:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == REQUEST_CODE_CHOOSE && resultCode == Activity.RESULT_OK) {
        val selectedImages = Matisse.obtainResult(data)
        // Process the selected images
    }
}

Competitor Comparisons

34,636

An image loading and caching library for Android focused on smooth scrolling

Pros of Glide

  • Broader functionality: Glide is a full-featured image loading and caching library, while Matisse focuses on image/video selection
  • More active development: Glide has more recent updates and a larger community
  • Extensive documentation and examples available

Cons of Glide

  • Steeper learning curve due to its extensive features
  • Larger library size compared to Matisse's more focused functionality
  • Not specifically designed for media selection, requiring additional code for this use case

Code Comparison

Glide (image loading):

Glide.with(context)
    .load(imageUrl)
    .placeholder(R.drawable.placeholder)
    .into(imageView);

Matisse (image selection):

Matisse.from(MainActivity.this)
    .choose(MimeType.ofImage())
    .countable(true)
    .maxSelectable(9)
    .forResult(REQUEST_CODE_CHOOSE);

Summary

Glide is a comprehensive image loading and caching library with a wide range of features, while Matisse is specifically designed for image and video selection from local storage. Glide offers more flexibility for various image-related tasks but may be overkill for simple media selection. Matisse provides a streamlined solution for media picking but lacks the broader functionality of Glide. The choice between the two depends on the specific requirements of your project.

18,710

A powerful image downloading and caching library for Android

Pros of Picasso

  • Broader image loading capabilities, handling network, local, and content provider sources
  • More extensive caching and memory management features
  • Wider adoption and community support, with frequent updates and improvements

Cons of Picasso

  • Lacks built-in image selection and cropping functionality
  • More complex setup for basic image loading tasks
  • Larger library size, which may impact app size

Code Comparison

Picasso (image loading):

Picasso.get()
    .load("https://example.com/image.jpg")
    .into(imageView);

Matisse (image selection):

Matisse.from(MainActivity.this)
    .choose(MimeType.ofImage())
    .countable(true)
    .maxSelectable(9)
    .imageEngine(new GlideEngine())
    .forResult(REQUEST_CODE_CHOOSE);

Picasso focuses on efficient image loading and caching, while Matisse specializes in image selection from device storage. Picasso offers more flexibility for various image sources and advanced loading options, making it suitable for complex image handling scenarios. Matisse, on the other hand, provides a user-friendly interface for selecting and cropping images, which is not a native feature of Picasso. The choice between the two depends on the specific requirements of your project, with Picasso being more versatile for general image loading tasks and Matisse excelling in image selection and basic editing functionality.

17,070

An Android library for managing images and the memory they use.

Pros of Fresco

  • More comprehensive image loading and caching solution
  • Supports a wider range of image formats and sources
  • Better memory management and performance optimization

Cons of Fresco

  • Larger library size and more complex integration
  • Steeper learning curve for developers
  • Less focused on image selection UI compared to Matisse

Code Comparison

Fresco:

Uri uri = Uri.parse("https://example.com/image.jpg");
SimpleDraweeView draweeView = findViewById(R.id.my_image_view);
draweeView.setImageURI(uri);

Matisse:

Matisse.from(MainActivity.this)
    .choose(MimeType.ofImage())
    .countable(true)
    .maxSelectable(9)
    .imageEngine(new GlideEngine())
    .forResult(REQUEST_CODE_CHOOSE);

Key Differences

  • Fresco is a full-featured image loading library, while Matisse focuses on image selection UI
  • Fresco offers more advanced image processing capabilities
  • Matisse provides a ready-to-use image picker interface
  • Fresco is better suited for complex image loading scenarios
  • Matisse is ideal for quick implementation of image selection functionality

Use Cases

  • Choose Fresco for apps requiring advanced image loading, caching, and processing
  • Opt for Matisse when building apps that need a simple, customizable image selection interface
  • Consider using both libraries together for a comprehensive image handling solution
10,727

Image loading for Android and Compose Multiplatform.

Pros of Coil

  • Focused on image loading and caching, providing a more specialized solution
  • Kotlin-first library, offering better integration with Kotlin projects
  • Lightweight and efficient, with a smaller footprint compared to Matisse

Cons of Coil

  • Limited to image loading functionality, lacking the comprehensive media selection features of Matisse
  • May require additional libraries or custom implementations for advanced image manipulation tasks

Code Comparison

Coil (Image loading):

ImageView(context).load("https://example.com/image.jpg") {
    crossfade(true)
    placeholder(R.drawable.placeholder)
    error(R.drawable.error)
}

Matisse (Image selection):

Matisse.from(MainActivity.this)
    .choose(MimeType.ofImage())
    .countable(true)
    .maxSelectable(9)
    .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
    .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
    .thumbnailScale(0.85f)
    .imageEngine(new GlideEngine())
    .forResult(REQUEST_CODE_CHOOSE);

Summary

Coil is a lightweight, Kotlin-focused image loading library, while Matisse is a comprehensive media selection tool. Coil excels in efficient image loading and caching, making it ideal for projects primarily focused on displaying images. Matisse, on the other hand, offers a broader range of features for selecting and managing multiple media types, making it more suitable for applications requiring extensive media handling capabilities.

Powerful and flexible library for loading, caching and displaying images on Android.

Pros of Android-Universal-Image-Loader

  • More mature and established library with a longer history of development and use
  • Supports a wider range of image loading scenarios, including network, local storage, and assets
  • Offers more customization options for caching, display, and processing

Cons of Android-Universal-Image-Loader

  • No longer actively maintained, with the last update in 2016
  • Lacks modern Android features and optimizations found in newer libraries
  • More complex setup and configuration compared to Matisse

Code Comparison

Android-Universal-Image-Loader:

ImageLoader imageLoader = ImageLoader.getInstance();
DisplayImageOptions options = new DisplayImageOptions.Builder()
    .cacheInMemory(true)
    .cacheOnDisk(true)
    .build();
imageLoader.displayImage(imageUri, imageView, options);

Matisse:

Matisse.from(MainActivity.this)
    .choose(MimeType.ofImage())
    .countable(true)
    .maxSelectable(9)
    .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
    .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
    .thumbnailScale(0.85f)
    .imageEngine(new GlideEngine())
    .forResult(REQUEST_CODE_CHOOSE);

While Android-Universal-Image-Loader focuses on loading and displaying images, Matisse is primarily an image selection library. Android-Universal-Image-Loader offers more flexibility in image loading scenarios, but Matisse provides a more modern and user-friendly interface for selecting multiple images from the device.

18,777

Implementation of ImageView for Android that supports zooming, by various touch gestures.

Pros of PhotoView

  • Focused on image viewing and zooming functionality
  • Lightweight and easy to integrate into existing projects
  • Supports gesture-based interactions for smooth user experience

Cons of PhotoView

  • Limited to image viewing, lacks image selection capabilities
  • Does not provide built-in gallery or multi-image selection features
  • Requires additional implementation for image loading and caching

Code Comparison

PhotoView implementation:

PhotoView photoView = findViewById(R.id.photo_view);
photoView.setImageResource(R.drawable.image);
photoView.setScaleType(ImageView.ScaleType.CENTER_CROP);

Matisse implementation:

Matisse.from(MainActivity.this)
    .choose(MimeType.ofImage())
    .countable(true)
    .maxSelectable(9)
    .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
    .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
    .thumbnailScale(0.85f)
    .imageEngine(new GlideEngine())
    .forResult(REQUEST_CODE_CHOOSE);

Summary

PhotoView excels in providing a smooth image viewing experience with zooming capabilities, while Matisse offers a comprehensive solution for image selection and gallery functionality. PhotoView is more suitable for projects that require detailed image viewing, whereas Matisse is better suited for applications needing multi-image selection and gallery features. The code comparison demonstrates the simplicity of PhotoView's implementation for viewing a single image, contrasted with Matisse's more complex setup for image selection and gallery display.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Image

Matisse

Build Status Download

Matisse is a well-designed local image and video selector for Android. You can

  • Use it in Activity or Fragment
  • Select images including JPEG, PNG, GIF and videos including MPEG, MP4
  • Apply different themes, including two built-in themes and custom themes
  • Different image loaders
  • Define custom filter rules
  • More to find out yourself
Zhihu StyleDracula StylePreview

Download

Gradle:

repositories {
    jcenter()
}

dependencies {
    implementation 'com.zhihu.android:matisse:$latest_version'
}

Check out Matisse releases to see more unstable versions.

ProGuard

If you use Glide as your image engine, add rules as Glide's README says.
And add extra rule:

-dontwarn com.squareup.picasso.**

If you use Picasso as your image engine, add rules as Picasso's README says.
And add extra rule:

-dontwarn com.bumptech.glide.**

Attention: The above progurad rules are correct.

How do I use Matisse?

Permission

The library requires two permissions:

  • android.permission.READ_EXTERNAL_STORAGE
  • android.permission.WRITE_EXTERNAL_STORAGE

So if you are targeting Android 6.0+, you need to handle runtime permission request before next step.

Simple usage snippet


Start MatisseActivity from current Activity or Fragment:

Matisse.from(MainActivity.this)
        .choose(MimeType.allOf())
        .countable(true)
        .maxSelectable(9)
        .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K))
        .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
        .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
        .thumbnailScale(0.85f)
        .imageEngine(new GlideEngine())
        .showPreview(false) // Default is `true`
        .forResult(REQUEST_CODE_CHOOSE);

Themes

There are two built-in themes you can use to start MatisseActivity:

  • R.style.Matisse_Zhihu (light mode)
  • R.style.Matisse_Dracula (dark mode)

And Also you can define your own theme as you wish.

Receive Result

In onActivityResult() callback of the starting Activity or Fragment:

List<Uri> mSelected;

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {
        mSelected = Matisse.obtainResult(data);
        Log.d("Matisse", "mSelected: " + mSelected);
    }
}

More

Find more details about Matisse in wiki.

Contributing

Matisse is an Open Source Project

Thanks

This library is inspired by Laevatein and uses some of its source code.

License

Copyright 2017 Zhihu Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.