Java Image Processing: Why is the output image smaller in storage than the input image?












-1














I'm learning Java Image Processing. Here is my code:



import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class LoadImage {
public static void main(String args) {
int width = 1280;
int height = 720;

BufferedImage image = null;

// READ IMAGE
try {
File input_image = new File("E:\SELF-TAUGHT LEARNING\39. Image Processing with Java\test-image.jpg");
image = new BufferedImage (width,height,BufferedImage.TYPE_INT_ARGB);
image = ImageIO.read(input_image);
System.out.println("Read successfully");
}
catch (IOException e) {
System.out.println("Error: " + e);
}

// WRITE IMAGE
try {
File output_image = new File("E:\SELF-TAUGHT LEARNING\39. Image Processing with Java\test-image-output.jpg");
ImageIO.write(image, "jpg", output_image);
System.out.println("Writing successfully");
}
catch (IOException e) {
System.out.println("Error: "+ e);
}
}
}


So the input image is around 300kb. But the output image is only 48kb. Why? Thank you










share|improve this question




















  • 4




    WHY THE SHOUTING IN THE TITLE?
    – EJoshuaS
    Nov 21 '18 at 16:03






  • 1




    Did you check whether the written image uses the same level of JPEG compression as the original image?
    – VGR
    Nov 21 '18 at 17:05
















-1














I'm learning Java Image Processing. Here is my code:



import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class LoadImage {
public static void main(String args) {
int width = 1280;
int height = 720;

BufferedImage image = null;

// READ IMAGE
try {
File input_image = new File("E:\SELF-TAUGHT LEARNING\39. Image Processing with Java\test-image.jpg");
image = new BufferedImage (width,height,BufferedImage.TYPE_INT_ARGB);
image = ImageIO.read(input_image);
System.out.println("Read successfully");
}
catch (IOException e) {
System.out.println("Error: " + e);
}

// WRITE IMAGE
try {
File output_image = new File("E:\SELF-TAUGHT LEARNING\39. Image Processing with Java\test-image-output.jpg");
ImageIO.write(image, "jpg", output_image);
System.out.println("Writing successfully");
}
catch (IOException e) {
System.out.println("Error: "+ e);
}
}
}


So the input image is around 300kb. But the output image is only 48kb. Why? Thank you










share|improve this question




















  • 4




    WHY THE SHOUTING IN THE TITLE?
    – EJoshuaS
    Nov 21 '18 at 16:03






  • 1




    Did you check whether the written image uses the same level of JPEG compression as the original image?
    – VGR
    Nov 21 '18 at 17:05














-1












-1








-1







I'm learning Java Image Processing. Here is my code:



import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class LoadImage {
public static void main(String args) {
int width = 1280;
int height = 720;

BufferedImage image = null;

// READ IMAGE
try {
File input_image = new File("E:\SELF-TAUGHT LEARNING\39. Image Processing with Java\test-image.jpg");
image = new BufferedImage (width,height,BufferedImage.TYPE_INT_ARGB);
image = ImageIO.read(input_image);
System.out.println("Read successfully");
}
catch (IOException e) {
System.out.println("Error: " + e);
}

// WRITE IMAGE
try {
File output_image = new File("E:\SELF-TAUGHT LEARNING\39. Image Processing with Java\test-image-output.jpg");
ImageIO.write(image, "jpg", output_image);
System.out.println("Writing successfully");
}
catch (IOException e) {
System.out.println("Error: "+ e);
}
}
}


So the input image is around 300kb. But the output image is only 48kb. Why? Thank you










share|improve this question















I'm learning Java Image Processing. Here is my code:



import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class LoadImage {
public static void main(String args) {
int width = 1280;
int height = 720;

BufferedImage image = null;

// READ IMAGE
try {
File input_image = new File("E:\SELF-TAUGHT LEARNING\39. Image Processing with Java\test-image.jpg");
image = new BufferedImage (width,height,BufferedImage.TYPE_INT_ARGB);
image = ImageIO.read(input_image);
System.out.println("Read successfully");
}
catch (IOException e) {
System.out.println("Error: " + e);
}

// WRITE IMAGE
try {
File output_image = new File("E:\SELF-TAUGHT LEARNING\39. Image Processing with Java\test-image-output.jpg");
ImageIO.write(image, "jpg", output_image);
System.out.println("Writing successfully");
}
catch (IOException e) {
System.out.println("Error: "+ e);
}
}
}


So the input image is around 300kb. But the output image is only 48kb. Why? Thank you







java image






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 17:31









Kevin Workman

33.4k53969




33.4k53969










asked Nov 21 '18 at 16:01









Duc Le Tran

1




1








  • 4




    WHY THE SHOUTING IN THE TITLE?
    – EJoshuaS
    Nov 21 '18 at 16:03






  • 1




    Did you check whether the written image uses the same level of JPEG compression as the original image?
    – VGR
    Nov 21 '18 at 17:05














  • 4




    WHY THE SHOUTING IN THE TITLE?
    – EJoshuaS
    Nov 21 '18 at 16:03






  • 1




    Did you check whether the written image uses the same level of JPEG compression as the original image?
    – VGR
    Nov 21 '18 at 17:05








4




4




WHY THE SHOUTING IN THE TITLE?
– EJoshuaS
Nov 21 '18 at 16:03




WHY THE SHOUTING IN THE TITLE?
– EJoshuaS
Nov 21 '18 at 16:03




1




1




Did you check whether the written image uses the same level of JPEG compression as the original image?
– VGR
Nov 21 '18 at 17:05




Did you check whether the written image uses the same level of JPEG compression as the original image?
– VGR
Nov 21 '18 at 17:05












1 Answer
1






active

oldest

votes


















0














If the image is the same resolution and quality after saving the new version, it's likely just a difference of metadata and formatting. It's also possible, however, that you are getting a lower quality image - if the original image had a high enough quality setting, it may not be noticeable when Java saves it at a lower quality.



Some things to check:




  • do the before and after images look different?

  • is the after image smaller in size?


I'm not very knowledgeable about Java, and don't know a lot about their image processing, but I would imagine there are methods for setting image size, resolution, and quality. I do, however, work with images a lot, and I know there are a lot of optimizations (especially in JPEG images) that you can do to reduce file size without affecting visual quality noticeably.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415996%2fjava-image-processing-why-is-the-output-image-smaller-in-storage-than-the-input%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If the image is the same resolution and quality after saving the new version, it's likely just a difference of metadata and formatting. It's also possible, however, that you are getting a lower quality image - if the original image had a high enough quality setting, it may not be noticeable when Java saves it at a lower quality.



    Some things to check:




    • do the before and after images look different?

    • is the after image smaller in size?


    I'm not very knowledgeable about Java, and don't know a lot about their image processing, but I would imagine there are methods for setting image size, resolution, and quality. I do, however, work with images a lot, and I know there are a lot of optimizations (especially in JPEG images) that you can do to reduce file size without affecting visual quality noticeably.






    share|improve this answer


























      0














      If the image is the same resolution and quality after saving the new version, it's likely just a difference of metadata and formatting. It's also possible, however, that you are getting a lower quality image - if the original image had a high enough quality setting, it may not be noticeable when Java saves it at a lower quality.



      Some things to check:




      • do the before and after images look different?

      • is the after image smaller in size?


      I'm not very knowledgeable about Java, and don't know a lot about their image processing, but I would imagine there are methods for setting image size, resolution, and quality. I do, however, work with images a lot, and I know there are a lot of optimizations (especially in JPEG images) that you can do to reduce file size without affecting visual quality noticeably.






      share|improve this answer
























        0












        0








        0






        If the image is the same resolution and quality after saving the new version, it's likely just a difference of metadata and formatting. It's also possible, however, that you are getting a lower quality image - if the original image had a high enough quality setting, it may not be noticeable when Java saves it at a lower quality.



        Some things to check:




        • do the before and after images look different?

        • is the after image smaller in size?


        I'm not very knowledgeable about Java, and don't know a lot about their image processing, but I would imagine there are methods for setting image size, resolution, and quality. I do, however, work with images a lot, and I know there are a lot of optimizations (especially in JPEG images) that you can do to reduce file size without affecting visual quality noticeably.






        share|improve this answer












        If the image is the same resolution and quality after saving the new version, it's likely just a difference of metadata and formatting. It's also possible, however, that you are getting a lower quality image - if the original image had a high enough quality setting, it may not be noticeable when Java saves it at a lower quality.



        Some things to check:




        • do the before and after images look different?

        • is the after image smaller in size?


        I'm not very knowledgeable about Java, and don't know a lot about their image processing, but I would imagine there are methods for setting image size, resolution, and quality. I do, however, work with images a lot, and I know there are a lot of optimizations (especially in JPEG images) that you can do to reduce file size without affecting visual quality noticeably.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 16:07









        brandonmack

        215




        215






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415996%2fjava-image-processing-why-is-the-output-image-smaller-in-storage-than-the-input%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python