public static void main(String[] args) { Image image = null; try { //colored image path BufferedImage colored_image = ImageIO.read(new File("D:\\logo.jpg")); //getting width and height of image double image_width = colored_image.getWidth(); double image_height = colored_image.getHeight(); BufferedImage img = colored_image; //drawing a new image BufferedImage bimg = new BufferedImage((int)image_width, (int)image_height, BufferedImage.TYPE_BYTE_GRAY); Graphics2D gg = bimg.createGraphics(); gg.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null), null); //saving black and white image onto drive String temp = "logo in blackAndwhite.jpeg"; File fi = new File("D:\\ " + temp); ImageIO.write(bimg, "jpg", fi); } catch (Exception e) { System.out.println(e); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)