Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7830869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:26:25+00:00 2026-06-02T11:26:25+00:00

I am sending an image over the network via wifi or the mobile network

  • 0

I am sending an image over the network via wifi or the mobile network to be stored in a server and retrieved again. I’ve done that but due to the size of images taken by the camera it’s making my app slow, just to point out I’m opening the gallery and taking the pictures from there and not taking the picture directly from the app. I have noticed that images from whatsapp that have been taken from the camera and gallery have been compressed to approx. 100kb.

At the moment my code takes a file and converts it to bytes and then sends it. Here is the method for taking a file and converting it to bytes.

private void toBytes(String filePath){
    try{
        File file = new File(filePath);
        InputStream is = new BufferedInputStream(new FileInputStream(file));  
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        bytes = new byte[(int) filePath.length()];
        int bytes_read;
        while((bytes_read = is.read(bytes, 0, bytes.length)) != -1){
            buffer.write(bytes, 0, bytes_read);
        }
        is.close();               
        bytes = buffer.toByteArray();
    }catch(Exception err){
        Toast.makeText(getApplicationContext(), err.toString(), Toast.LENGTH_SHORT).show();
    }
}

So my question is how would I go about compressing my image before sending? Also I don’t need the image to retain a high pixel count as when the app uses the image it will only take up half of the devices screen.

Thank you for any help given.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:26:27+00:00Added an answer on June 2, 2026 at 11:26 am

    The BitMap http://developer.android.com/reference/android/graphics/Bitmap.html class have a compress method.
    But you might need to scale the image createScaledBitmap, also available in the same class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sending mail along with embedded image using asp.net I have already used following but
I am Sending Serialized large Image Object over UDP Socket .When I write all
I'm encoding a single generated image on a PC to H.264, sending it over
in a question(here Placing an image in an object, sending the object over rpc
I am sending an image via-email using mfmailcomposeviewcontroller: [mailComposer addAttachmentData:UIImageJPEGRepresentation(self.editedImageView.image, 1.0f) mimeType:@image/jpeg fileName:@yourPhotoWithBestGlasses.jpg]; The
I am sending an image to the server by converting the NSData object into
I have an application where I am sending image data on server through ftp
I am sending an image from android phone to the server which hanldes it
The server is sending a list of urls of images when the application loads.
Sending XML from C# Server and receiving it it in Android Java client This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.