josealejandro2928 / react-image-picker-editor

React library for the selection, edition and compression of images in png, jpeg and webp formats This package is made completely with html and css without any extra components or npm packages. It's based in functional components based in hooks, for optimization were used memo, useMemo and useCalback for avoiding any extra-renders.
https://www.npmjs.com/package/react-image-picker-editor
MIT License
27 stars 21 forks source link

How to change Default Compression when initial `imageSrcProp` provided? #3

Closed pkrinesh closed 1 year ago

pkrinesh commented 1 year ago

According to the source code, Quality is aggressively set to 92 when imageSrcProp is provided and not be able to set via config.compressInitial. But for imageSrcProps = "" we can set quality by config.compressInitial.

josealejandro2928 commented 1 year ago

Fixed, Try now

pkrinesh commented 1 year ago

Yes, It is working. Thank you.

pkrinesh commented 1 year ago

Again, when pass imageSrcProps = window.URL.createObjectURL(file) it changes its format to .jpeg. And passing a file directly does not work as it only accepts string. Is there another way?

josealejandro2928 commented 1 year ago

No from the moment. The imgSrcProp only accepts the string url of the img. It's designed to support when you load a image from your backend or from the web. But you always can fork the project an provide a solution to address your problem as a PR

Satyad146 commented 1 year ago

I have an Array of images to edit on Click of a image I need to open the image with image-editor. but it is not working it is only pointing to the 1st clicked image regardless of the state change I am doing

josealejandro2928 commented 1 year ago

Please provide the code to see the state management that you are performing. Without the code I cannot help you

Satyad146 commented 1 year ago

consider this simple code my image is changing with state but editor image is not changing

import logocar from "../image/Teams-Leader_Eric-Barnes.webp"; import logocar2 from "../image/logo_car.png"

const [check,setCheck]=useState(logocar)

  <button onClick={()=>setCheck(logocar2)}>Change Click</button>
  <img src={check}/>

<ReactImagePickerEditor config={config2} imageSrcProp={check} imageChanged={(newDataUri) => setImageSrc(newDataUri)} />

josealejandro2928 commented 1 year ago

And what is the issue related to ?

Satyad146 commented 1 year ago

And what is the issue related to ?

The issue is relate to react-image-picker-editor is somehow keeping the previous state value which is given at 1st

josealejandro2928 commented 1 year ago

Ok I will have a look at it

josealejandro2928 commented 1 year ago

Done, here in the demo it put exacly your kind of example https://react-image-picker-editor.surge.sh/

Satyad146 commented 1 year ago

Can I get the code base of it It look's some what to my scenario?

josealejandro2928 commented 1 year ago

I have updated the package, first update the npm package, then just fork the project from GitHub, but you only have to update the package and it will work when you change the initial image

Satyad146 commented 1 year ago

Thanks Man It Worked!

josealejandro2928 commented 1 year ago

Leave a ⭐ and share it. That helps me 🚀🚀🚀