burhanrashid52 / PhotoEditor

A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.
MIT License
4.14k stars 991 forks source link

Distorted image when apply at least on filter #291

Open lillogoal opened 3 years ago

lillogoal commented 3 years ago

Hi,

i have the problem in subject. My Flow is: Download with glide a bitmap and after i will send to PhotoEditor library. When i select at least one filter (gray,rotate, ecc...) the image is distorted.

I checked size of bitmap and it is ok. I checked size of surfaceView and she changes when applying the first filter

@Override public void onSurfaceChanged(GL10 gl, int width, int height) { if (mTexRenderer != null) { Log.e("ONSURFCHANGED",width+"\nHeight:"+height); mTexRenderer.updateViewSize(width, height); } }

Before

Screenshot_1605772807

After

Screenshot_1605772871

lazy-coder-10 commented 3 years ago

You can fix this issue by saving the captured image in the gallery and use that file path because if you take an image directly from the camera then the size of that image is very small and this is the reason the image is getting destored.

lillogoal commented 3 years ago

@rohit6027 i'm downloading image with glide with code:

final GlideUrl glideUrl = GenericUtility.getGlideUrlFromData(BackendMethods.URL_IMG_TIMELINE_PATH+ picMatch.get_key(), MyApplication.getUser().getWtkn()); Glide.with(EditImageActivity.this) .load(glideUrl) .asBitmap() .into(new SimpleTarget() { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { mPhotoEditorView.getSource().setImageBitmap(resource); }});

so i'm using bitmap. do you think that correct way is going to save in sd and after ?

lazy-coder-10 commented 3 years ago

It doesn't matter how you are loading the image in image view the only thing matter is what file path are you using. how are you getting below path in onActvityResult.

GenericUtility.getGlideUrlFromData(BackendMethods.URL_IMG_TIMELINE_PATH+ picMatch.get_key(),

lillogoal commented 3 years ago

@rohit6027 mmm path is my server next i download the image and setBitmap I don't understand where the problem is

lillogoal commented 3 years ago

@rohit6027 any updates ? ty

lazy-coder-10 commented 3 years ago

@lillogoal your case is different but the problem I was facing is the same. I solved my problem after saving the actual image size in gallery when the user clicks an image from the camera.

lillogoal commented 3 years ago

@lillogoal your case is different but the problem I was facing is the same. I solved my problem after saving the actual image size in gallery when the user clicks an image from the camera.

so you suggest me to save in external directory and after loads in photoeditor view ? can you post an example of saving and loading image ? thanks

lazy-coder-10 commented 3 years ago

@lillogoal no need to save image in an external directory. It will be great if you share a complete image link that you are trying loading in the photo editor view.

lillogoal commented 3 years ago

@lillogoal no need to save image in an external directory. It will be great if you share a complete image link that you are trying loading in the photo editor view.

sorry but link required auth request with bearer.

i understud image has to save in gallery right ?

lazy-coder-10 commented 3 years ago

I am not sure it will work or not but you can try it.

lillogoal commented 3 years ago

@rohit6027 yes i can try but you can send me an example of saving in gallery and load from gallery. ty

lazy-coder-10 commented 3 years ago

In the beginning, I said I am taking an image from the camera but you are taking it from the server.

lillogoal commented 3 years ago

yes yes but after taking from server i convert in bitmap so maybe your implementation is ok. I am desperate I have tried everything

lazy-coder-10 commented 3 years ago

is it happening with every image URL which you getting from the backend ?? if yes then I will create a sample for the same issue else you can share your image URL if possible.

lazy-coder-10 commented 3 years ago

@lillogoal its working file with the URL also I am using this url -> [https://www.webconfs.com/comics/dynamic-vs-static-urls-comic.jpg]

lillogoal commented 3 years ago

My flow is: user capture image -> upload on server -> other user download image and need to modify it.

If user in the first step decide to load an image from gallery (low resolution maybe) it works. I tested with your url: "https://www.webconfs.com/comics/dynamic-vs-static-urls-comic.jpg" --> it works.

So in my opinion problem is when user capture and upload image with high resolution.

Screenshot_1609770302

lazy-coder-10 commented 3 years ago

yes you are right. how you are capturing the image ?? are you saving actual image size in local storage ??

lillogoal commented 3 years ago
  PickSetup pickSetup = new PickSetup().setWidth(600).setHeight(400).setGalleryButtonText(getString(R.string.galleria)).setTitle(getString(R.string.choose)).setCancelText(getString(R.string.annulla));
        PickImageDialog.build(pickSetup).show(this).setOnPickResult(new IPickResult() {
            @Override
            public void onPickResult(PickResult pickResult) {
                if (pickResult.getError() == null) {
                    Log.e("PATH",pickResult.getPath());
                    File file = new File(Environment.getExternalStorageDirectory()+File.separator+"img_"+System.currentTimeMillis()+".jpg");

                    UCrop.of(pickResult.getUri(), Uri.fromFile(file))
                            .start(PhotoToBetActivity.this,REQUEST_IMAGE_CROP);
                } else {

                    //Handle possible errors
                    //TODO: do what you have to do with r.getError();
                    Toast.makeText(PhotoToBetActivity.this, pickResult.getError().getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        });

I think yes, this is my code, i used a picksetup library, and after selection or capture image user can crop using UCrop library

lazy-coder-10 commented 3 years ago

remove .setWidth(600).setHeight(400) and try again may be this is the problem.

lillogoal commented 3 years ago

You are right!! I'm testing with more and more cases. After tests i will reply with result.

Somil-Jain commented 4 months ago

Hi,

I am also facing a similar issue when apply atleast a filter. The image gets stretched from both X and Y axis and seems to be distorted as well. Has anyone found a solution for this?

I have tried to get the child views to check whether we can change the Scale of Image but unable to achieve this.

Can any one help here please.