wasabeef / glide-transformations

An Android transformation library providing a variety of image transformations for Glide.
Apache License 2.0
9.9k stars 1.41k forks source link

How to export blurred image using Glide on Android? #134

Open majinman opened 6 years ago

majinman commented 6 years ago

I wanna export blurred image using Glide. And then send image to my firebase storage.

the below is my code.

Glide.with(this)
            .asFile()
            .load(imgUri)
            .apply(bitmapTransform(new BlurTransformation(50)))
            .into(new SimpleTarget<File>(){
                @Override
                public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {
                    Log.d("result", "resource :" + resource.getAbsolutePath());

                    blurUri = Uri.fromFile(resource);
                    UploadTask uploadTask = riversRef.putFile(blurUri);
                    uploadTask.addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception e) {
                            Toast.makeText(getContext(), "사진을 업로드하는 데 실패하였습니다. 다시 시도해주세요", Toast.LENGTH_SHORT).show();
                        }
                    }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                        @Override
                        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                            Uri downloadUrl = taskSnapshot.getDownloadUrl();
                            Log.d("result", "file Uri: " + taskSnapshot.getDownloadUrl());
                        }
                    }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
                        @Override
                        public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
                            double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
                            Log.d("result", "Upload is " + progress + "% done");

                        }
                    }).addOnPausedListener(new OnPausedListener<UploadTask.TaskSnapshot>() {
                        @Override
                        public void onPaused(UploadTask.TaskSnapshot taskSnapshot) {
                            Log.d("result", "Upload is paused");
                            Toast.makeText(getContext(), "사진을 업로드가 중단되었습니. 다시 시도해주세요", Toast.LENGTH_SHORT).show();
                        }
                    });

However, it didn't work. the image stored in firebase storage wasn't blurred. It was just original image I selected.

Please, help me.