0

I want to reduce the image size while saving it to local folder. Now it is stored with its original size. I am storing the whole bitmap to path as below:

                String fileName = "image_" + count++ + ".png";

                System.out.println("file name is : " + fileName);

                File sd = Environment.getExternalStorageDirectory();
                File folder = new File(sd + "/Wallpaper Pack");
                System.out.println("folder is : " + folder);
                folder.mkdir();

                File dest = new File(folder, fileName);
                try {
                    FileOutputStream out;
                    out = new FileOutputStream(dest);
                    bitmap.compress(Bitmap.CompressFormat.PNG, 50, out);
                    out.flush();
                    out.close();

                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
Shree
  • 344
  • 2
  • 20
rs11
  • 65
  • 9

1 Answers1

0

Resize your Bitmap. Take a look at example. Also when using PNG format here (Bitmap.CompressFormat.PNG, 50, out); compression won't happen. It's always 100, so you can change output format to JPEG.

Anton Kazakov
  • 2,560
  • 3
  • 20
  • 33