[Test availability], pngjpg

Source: Internet
Author: User

[Test availability], pngjpg

This example describes how to convert a png image to a jpg image in Java. We will share this with you for your reference. The details are as follows:

Import java. awt. color; import java. awt. image. bufferedImage; import java. io. file; import java. io. IOException; import javax. imageio. imageIO; public class ConvertImageFile {public static void main (String [] args) {BufferedImage bufferedImage; try {// read image file bufferedImage = ImageIO. read (new File ("c: \ java.png"); // create a blank, RGB, same width and height, and a white // background BufferedImage newBufferedImage = new BufferedImage (bufferedImage. getWidth (), bufferedImage. getHeight (), BufferedImage. TYPE_INT_RGB); // TYPE_INT_RGB: creates an RBG image with 24-bit depth. The 32-Bit Bitmap is successfully converted into a 24-bit newBufferedImage. createGraphics (). drawImage (bufferedImage, 0, 0, Color. WHITE, null); // write to jpeg file ImageIO. write (newBufferedImage, "jpg", new File ("c: \ java.jpg"); System. out. println ("Done");} catch (IOException e) {e. printStackTrace ();}}}

PS: here we recommend several online image processing tools for your reference:

Online image format conversion (jpg/bmp/gif/png) tool:
Http://tools.jb51.net/aideddesign/picext

Online image cropping/generation tools:
Http://tools.jb51.net/aideddesign/imgcut

ICO icon generation tool:
Http://tools.jb51.net/aideddesign/ico_img

Online low polygon graphics generation tool:
Http://tools.jb51.net/aideddesign/img_lowpoly

For more java-related content, refer to this topic: java image operation skills summary, java Date and Time Operation Skills summary, Java operation DOM node skills summary, Java file and directory operation skills summary, and Java data structure and algorithm tutorial.

I hope this article will help you with java programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.