Комментарии:
Help me please
ОтветитьCan we add ad mob ads
ОтветитьPlease make a video to integrate ad mob in same app
Ответитьit show image is not sellected
ОтветитьI added dependency but but it does not showing any options like setMaxWidth, setMaxHeight...
Here is my code
@Override
public void onClick(View p1)
{
int quality=seekbar.getProgress();
int height=Integer.parseInt(edx1.getText().toString());
int width=Integer.parseInt(edx2.getText().toString());
compressedImage =new Compressor(MainActivity.this)
}
});
Ah i have another error! When i click the compressor btn it show me somthing went wrong and the picture didnt compress why?
ОтветитьstartActivityForResult(gallery, RESULT_IMAGE); -> is deprecated to me. Since I`m completely to those Libraries would be awesome if you had another way to do this ^^, thanks for the awesome project.
ОтветитьDexter.withPermission error occuring
Cannot resolve withPermission
when I clicked on compress button i was not work. this is my java code help me to sort out this problem.
package com.example.imagecompressorapp;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.Manifest;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.format.Formatter;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.karumi.dexter.Dexter;
import com.karumi.dexter.DexterBuilder;
import com.karumi.dexter.MultiplePermissionsReport;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.PermissionRequest;
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import id.zelory.compressor.Compressor;
public class MainActivity extends AppCompatActivity {
public static final int RESULT_IMAGE = 1;
ImageView imgOriginal,imgCompress;
TextView txtOriginal,textCompress,txtQuality;
EditText txtHeight,txtWidth;
SeekBar seekBar;
Button btnPick,btnCompress;
File originalImage,compressImage;
private static String filepath;
File path = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/myAppCompressor");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
askPermission();
imgOriginal = findViewById(R.id.imgOriginal);
imgCompress = findViewById(R.id.imgCompress);
txtOriginal = findViewById(R.id.txtOriginal);
textCompress = findViewById(R.id.txtCompress);
txtQuality = findViewById(R.id.txtQuality);
txtHeight = findViewById(R.id.txtHeight);
txtWidth = findViewById(R.id.txtWidth);
seekBar = findViewById(R.id.seekQuality);
btnPick = findViewById(R.id.btnPick);
btnCompress = findViewById(R.id.btnCompresd);
filepath = path.getAbsolutePath();
if(!path.exists())
{
path.mkdirs();
}
// seekbar
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean fromUser) {
txtQuality.setText("Quality: "+ i);
seekBar.setMax(100);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// Pick image from gallery
btnPick.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
openGallery();
}
});
// compress function start
btnCompress.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int quality = seekBar.getProgress();
int width = Integer.parseInt(txtWidth.getText().toString());
int height = Integer.parseInt(txtHeight.getText().toString());
try {
compressImage = new Compressor(MainActivity.this)
.setMaxWidth(width)
.setMaxHeight(height)
.setQuality(quality)
.setCompressFormat(Bitmap.CompressFormat.JPEG)
.setDestinationDirectoryPath(filepath)
.compressToFile(originalImage);
File finalFile = new File(filepath,originalImage.getName());
Bitmap finalBitmap = BitmapFactory.decodeFile(finalFile.getAbsolutePath());
imgCompress.setImageBitmap(finalBitmap);
textCompress.setText("Size: "+Formatter.formatShortFileSize(MainActivity.this,finalFile.length()));
Toast.makeText(MainActivity.this, "Image Compressed && Saved!!", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(MainActivity.this, "Error while Compress", Toast.LENGTH_SHORT).show();f
}
}
});
}
private void openGallery() {
Intent gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(gallery,RESULT_IMAGE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode== RESULT_OK)
{
btnCompress.setVisibility(View.VISIBLE);
final Uri imageUri = data.getData();
try {
final InputStream imageStream = getContentResolver().openInputStream(imageUri);
final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
imgOriginal.setImageBitmap(selectedImage);
originalImage = new File(imageUri.getPath().replace("raw/",""));
txtOriginal.setText("Size"+ Formatter.formatShortFileSize(this,originalImage.length()));
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(this, "Something Went Wrong!", Toast.LENGTH_SHORT).show();
}
}
else{
Toast.makeText(this, "No Image Selected!", Toast.LENGTH_SHORT).show();
}
}
private void askPermission() {
Dexter.withContext(this)
.withPermissions(Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport multiplePermissionsReport) {
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> list, PermissionToken permissionToken) {
permissionToken.continuePermissionRequest();
}
}).check();
}
}
thank you for this nice tutorial, is it compatible with android 11 scoped storage. can you test it on android 11 device. thanks
ОтветитьImage compressor original size showing o kb all time
why???
I am getting a stroke on "startActivityForResult".and even if i select an image , it says no image selected... Please Help me
ОтветитьI am getting error while saving and can't resolve it help please
ОтветитьI am not working Compressor
Please help me
Source code please.....
ОтветитьWhy it is showing error in dexter
Ответитьwhen click on an image its showing no image selected
ОтветитьNot image Selected😥
ОтветитьBro how can I select multiple images,,, please reply bro
Ответитьhey bro i watched your whole tutorial ,does everything same but when i m clickng on compressed button it is showing error.
i notice that while your were coding u used differnt emulator and after finishing u used diffrent
Image compressor original size is showing 0Kb every time. Can You please help me out!
ОтветитьBrw is this project start in empty activity
ОтветитьBrw mkdir path not working😢😢
ОтветитьStartActivityForResult is depricated
ОтветитьSir btncompress button click krne par error aa raha hai. ( Error while compressing ). Please help me sir
Ответитьimage size hamesha 0 bata rha he then show error while compressing.. help me..
ОтветитьWhen I take image it show size zero byte and when I trying to compress then it crashed. Why this things are happening?
Ответитьtnx, kindly tell me
this is java or kotlin????
i want ask you about this app, in this app using algorithm ? huffman coding ?? or something ??
Ответитьthanks for the vid , is their a link to the source code
ОтветитьBrother, you are great. Explained very nicely, Thankyou so much. I am subsribing right away.
ОтветитьCompressor()' has private access in 'id.zelory.compressor.Compressor'
when i tried to make and object its of Compressoe its showing Error
Thanks for the amazing tutorial
ОтветитьBrother, you are great but can u make a video on string compression. Please!
ОтветитьProject is awesome. I learnt so much from your Tutorial. Kindly provide source code.
ОтветитьSize of the image is not showing and compressor error can anyone tell me the solution
Ответитьsir, what algorithms is this ? Huffman or LZW ?
kindly tell me pls
Size of the image is not showing and compressor error can anyone tell me the solution??
ОтветитьKindly sir share this apk file
ОтветитьI don't show original images size please help me
Ответитьcan you answer which technique you have used in this app
ОтветитьSir, WRITE EXTERNAL STORAGE is not working above Android 10+ , what will do, please response
ОтветитьHi sir, not able to write internal storage in about Android 10+
ОтветитьIt Doesn't show the image size ...n when click on compress button it display the toast error
ОтветитьHow to get the above application source code ❗❗
ОтветитьIt is a great app. I followed you until I discovered that it is written for a java project (Minute 10 and so on). I´am a kotlin student. Thanks, anyway.
ОтветитьI have an erro, "Error while compressing image".
Ответитьerror while compressing
I think there is problem in android library, not updated yet
even not showing the size , many user has same problem in comment section⬆⬆⬆⬆
aint no way your name is evan
Ответить