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

expo-image-crop-editor

v1.8.0

Published

A super simple image cropping and rotation tool for Expo that runs on iOS, Android and Web!

Downloads

205

Readme

🌁 Expo Image Editor

A super simple image cropping and rotation tool for Expo that runs on iOS, Android and Web!

| Screenshot_20201013-161416 | Screenshot_20201013-161447 | Screenshot_20201013-161347 | | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |

Check out the demo on Netlify here

Installation

To get started install the package in your Expo project by running:

yarn add expo-image-crop-editor

or

npm i expo-image-crop-editor

Usage

The package exports a single component ImageEditor that can be placed anywhere in your project. This renders a modal that then returns the editing result when it is dismissed.

// ...
import { ImageEditor } from "expo-image-crop-editor";

function App() {
  const [imageUri, setImageUri] = useState(undefined);

  const [editorVisible, setEditorVisible] = useState(false);

  const selectPhoto = async () => {
    // Get the permission to access the camera roll
    const response = await ImagePicker.requestCameraRollPermissionsAsync();
    // If they said yes then launch the image picker
    if (response.granted) {
      const pickerResult = await ImagePicker.launchImageLibraryAsync();
      // Check they didn't cancel the picking
      if (!pickerResult.cancelled) {
        launchEditor(pickerResult.uri);
      }
    } else {
      // If not then alert the user they need to enable it
      Alert.alert(
        "Please enable camera roll permissions for this app in your settings."
      );
    }
  };

  const launchEditor = (uri: string) => {
    // Then set the image uri
    setImageUri(uri);
    // And set the image editor to be visible
    setEditorVisible(true);
  };

  return (
    <View>
      <Image
        style={{ height: 300, width: 300 }}
        source={{ uri: imageData.uri }}
      />
      <Button title="Select Photo" onPress={() => selectPhoto()} />
      <ImageEditor
        visible={editorVisible}
        onCloseEditor={() => setEditorVisible(false)}
        imageUri={imageUri}
        fixedCropAspectRatio={16 / 9}
        lockAspectRatio={aspectLock}
        minimumCropDimensions={{
          width: 100,
          height: 100,
        }}
        onEditingComplete={(result) => {
          setImageData(result);
        }}
        mode="full"
      />
    </View>
  );
}

Props

| Name | Type | Description | | --------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | visible | boolean | Whether the editor should be visible or not. | | asView | boolean | If true this will remove the modal wrapper and return the image editor in a regular <View /> | | mode | string | Which mode to use the editor in can be either full or crop-only. | | onCloseEditor | function | Callback when the editor is dimissed - use this to set hide the editor. | | imageUri | string | The uri of the image to be edited | | fixedCropAspectRatio | number | The starting aspect ratio of the cropping window. | | lockAspectRatio | boolean | Whether the cropping window should maintain this aspect ratio or not. | | minimumCropDimensions | object | An object of {width, height} specifying the minimum dimensions of the crop window. | | onEditingComplete | function | function that will return the result of the image editing which is an object identical to imageData | | throttleBlur | boolean | Whether to throttle the WebGL update of the blur while adjusting (defaults to false) - useful to set to true on lower performance devices | | allowedTransformOperations | string[] | Which transform operations you want to exclusively allow to be used. Can include crop and rotate e.g. ['crop'] to only allow cropping | | allowedAdjustmentOperations | string[] | Which image adjustment operations you want to exclusively allow to be used. Only blur can be specified at the minute e.g. ['blur'] yo only allow blur as an image adjustment |