callstack / react-native-image-editor

A library providing an API for cropping images from the web and the local file system.
MIT License
366 stars 117 forks source link

feature: Add web support #131

Closed retyui closed 5 months ago

retyui commented 5 months ago

Summary

Make module cross-platform:

Test plan

  1. Create a new Expo project

    npx create-expo-app -t expo-template-blank-typescript
  2. Run web yarn web:

  3. Link a library yarn add /path/to/package/image-editor locally

  4. Try to crop image:

    import ImageEditor from '@react-native-community/image-editor'
    
    ImageEditor.cropImage('https://images.pexels.com/photos/842711/pexels-photo-842711.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2', {
      "resizeMode": "cover",
      "offset": {
          "x": 1125,
          "y": 750
      },
      "size": {
          "width": 1125,
          "height": 750
      },
      "quality": 0.7,
      "format": "jpeg"
    })

Video:

https://github.com/callstack/react-native-image-editor/assets/4661784/74d94d63-2df8-484b-ad74-9f919a80c8ae