npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@enertrag/photopicker

v1.1.2

Published

Multiple selection cross-platform image picker plugin for Capacitor

Downloads

8

Readme

Capacitor (Multi-) Photopicker Plugin

version npm issues license

The Photopicker API allows the user to select one or more photos from the system-wide media library.

The selected photos can be (down)scaled and compressed. The data is provided in the form of temporary files in the user's cache directory. The API provides the URIs of the processed photos.

In order to use the photos in a Capacitor application, they have to be moved from the cache directory to the final storage location.

Installation

npm install @enertrag/photopicker

(Of course, the usual Capacitor procedure npx cap sync must be executed afterwards.)

iOS Notes

Important: this plugin requires iOS 14 or later.

iOS requires the following usage description be added and filled out for your app in Info.plist:

  • NSPhotoLibraryUsageDescription (Privacy - Photo Library Usage Description)

Read about Configuring Info.plist in the iOS Guide for more information on setting iOS permissions in Xcode

Selected images are persisted in the users cache (temporary) folder. As mentioned you should move it to the final destination.

Android Notes

To use this plugin you have to register it in your MainActivity.

import ...
import com.enertrag.plugins.photopicker.Photopicker;

public class MainActivity extends BridgeActivity {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      add(Photopicker.class);
    }});
  }
}

On your MainActivity.java file add import com.enertrag.plugins.photopicker.Photopicker; and then inside the init callback add(Photopicker.class);

This API requires the following permissions be added to your AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

The storage permissions are for reading/saving photo files.

Read about Setting Permissions in the Android Guide for more information on setting Android permissions.

Example

import { Plugins } from '@capacitor/core';
const { Photopicker } = Plugins;

...

async addPhotos() {

      const result = await Photopicker.getPhotos();
      if (result.selected) {

        for (const url of result.urls) {
            // ... do something with the url if it's not empty
            if(url) {
                // ...
            }
        }
      }
}

Alternatively, if the code completion does not work, the import can be formulated as follows:

import { EAGPhotopicker } from 'enertrag-photopicker';
const Photopicker = new EAGPhotopicker();

API

getPhotos()

getPhotos(options: PhotopickerOptions) => Promise<PhotopickerResponse>

Prompt the user to pick one or more photos from an album.

The method call may fail if the user denies the permission request.

Returns: Promise<PhotopickerResponse>

Interfaces

PhotopickerOptions

| Prop | Type | Description | | ------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | maxSize | number | The maximum length of one side of the photo. The photo is scaled according to the aspect ratio. The value 0 leaves the photo in its original resolution. The photo is never scaled up. | | quality | number | The image quality on a scale from 10 (highest compression) to 100 (best quality). |

PhotopickerResponse

| Prop | Type | Description | | -------------- | --------------------- | ------------------------------------------------------------------------------------------------------ | | selected | boolean | Shows whether the user has selected photos (true) or not (false). | | urls | string[] | The URIs of the selected and converted photos. This might contain empty elements for errornous photos. |

Implementation

The exciting parts of the source code for Android can be found here. The ones for iOS are here.

License

MIT

Copyright © 2021 ENERTRAG AG