ByteArrayOutputStream byteArrayBitmapStream = new ByteArrayOutputStream(); bitmapPicture.compress(Bitmap.CompressFormat.JPEG, COMPRESSION_QUALITY, byteArrayBitmapStream); byte[] b = byteArrayBitmapStream.toByteArray(); #### if ( open ( PICTF,"> smepath/file.jpeg" ) ) { binmode PICTF; print PICTF $contentpic; close (PICTF); } my ($x, $y, $info) = imgsize("somepath/file.jpeg");