Reduce the size of a bitmap to a specified size in Android

I found an answer that works perfectly for me: /** * reduces the size of the image * @param image * @param maxSize * @return */ public Bitmap getResizedBitmap(Bitmap image, int maxSize) { int width = image.getWidth(); int height = image.getHeight(); float bitmapRatio = (float)width / (float) height; if (bitmapRatio > 1) { width = … Read more

How to compress image size?

You can create bitmap with captured image as below: Bitmap bitmap = Bitmap.createScaledBitmap(capturedImage, width, height, true); Here you can specify width and height of the bitmap that you want to set to your ImageView. The height and width you can set according to the screen dpi of the device also, by reading the screen dpi … Read more

Setting jpg compression level with ImageIO in Java

A more succinct way is to get the ImageWriter directly from ImageIO: ImageWriter jpgWriter = ImageIO.getImageWritersByFormatName(“jpg”).next(); ImageWriteParam jpgWriteParam = jpgWriter.getDefaultWriteParam(); jpgWriteParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); jpgWriteParam.setCompressionQuality(0.7f); ImageOutputStream outputStream = createOutputStream(); // For example implementations see below jpgWriter.setOutput(outputStream); IIOImage outputImage = new IIOImage(image, null, null); jpgWriter.write(null, outputImage, jpgWriteParam); jpgWriter.dispose(); The call to ImageWriteParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT) is needed in order to explicitly set … Read more

Image Compression tools via command line [closed]

I’m using the following tools to perform lossless image compression: pngcrush gifsicle jpegtran For each of the programs, I’ve created two shortcuts: One that does the actual compression, and shows the file size of both files One that replaces the original file with the compressed one (If I’m satisfied, I’ll do arrow-up, prefix my previous … Read more

Is it possible to tell the quality level of a JPEG?

You can view compress level using the identify tool in ImageMagick. Download and installation instructions can be found at the official website. After you install it, run the following command from the command line: identify -format ‘%Q’ yourimage.jpg This will return a value from 0 (low quality, small filesize) to 100 (high quality, large filesize). … Read more