Git Product home page Git Product logo

Comments (10)

duongdinh98 avatar duongdinh98 commented on June 29, 2024 1

Not work @retyui t

from react-native-image-editor.

duongdinh98 avatar duongdinh98 commented on June 29, 2024 1

@duongdinh98 also, can you omit displaySize prop from the params and check again

 displaySize: {
      width: imgSize.width,
      height: imgSize.width,
    },

Not work, I tried this before

from react-native-image-editor.

retyui avatar retyui commented on June 29, 2024 1

@duongdinh98 Could you please log the next variables (from Galaxy Note 10+ & Huawei P20 )

const photo = await camera.current.takePhoto(takePhotoOptions);
     // ^^^ - `photo` takePhoto result 
const imgSize = await getImageSize(photo.path);
      //. ^^^ `imgSize` - image size 

from react-native-image-editor.

duongdinh98 avatar duongdinh98 commented on June 29, 2024 1

I found issue, my getImageSize() function not correctly work in some Android devices, so it will return incorrect image size => cause crop incorrectly

facebook/react-native#33498

To resolve, I swith to get image size from photo object return by react-native-vision-camera

const photo = await camera.current.takePhoto(takePhotoOptions);

from react-native-image-editor.

retyui avatar retyui commented on June 29, 2024

@duongdinh98 Could you provide video/image demo of what you see on Huawei P20 (I don't have such device for testing)
also an original image, version of @react-native-community/image-editor

from react-native-image-editor.

duongdinh98 avatar duongdinh98 commented on June 29, 2024

Hi @retyui

I'm using "@react-native-community/image-editor": "^4.2.0",
This is demo video: https://www.youtube.com/shorts/gj6qNuNZVpA

In Galaxy Note 10+ and iPhone with this code above, it cropped square image perfectly like in camera preview screen, but on Huawei P20, it looks like crop without offset in the demo I shared

from react-native-image-editor.

retyui avatar retyui commented on June 29, 2024

@duongdinh98 how do you create imgSize obj ?

from react-native-image-editor.

duongdinh98 avatar duongdinh98 commented on June 29, 2024

Here is what I did

import { Image as RNImage } from 'react-native';

export const getImageSize = (
  uri: string,
): Promise<{ width: number; height: number }> => {
  return new Promise((resolve, reject) => {
    RNImage.getSize(
      uri,
      (imgWidth, imgHeight) => {
        resolve({ width: imgWidth, height: imgHeight });
      },
      reject,
    );
  });
};

// camera obj from react-native-vision-camera
const photo = await camera.current.takePhoto(takePhotoOptions);
photo.path = `file://${photo.path}`;
const imgSize = await getImageSize(photo.path);

from react-native-image-editor.

retyui avatar retyui commented on June 29, 2024

can you try to swap w & h resolve({ width: imgHeight, height: imgWidth }) ?

from react-native-image-editor.

retyui avatar retyui commented on June 29, 2024

@duongdinh98 also, can you omit displaySize prop from the params and check again

 displaySize: {
      width: imgSize.width,
      height: imgSize.width,
    },

from react-native-image-editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.