Last active
August 29, 2015 14:02
-
-
Save kodiyan/a908e6997f2892ace44b to your computer and use it in GitHub Desktop.
Converting Picture to Byte from Local Folder and Printe in Console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.main; | |
import javax.imageio.ImageIO; | |
import org.apache.commons.io.IOUtils; | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.FileInputStream; | |
public class ImageUtil { | |
public static String imageWH() { | |
File imageFile = new File ("C:\\test50.png"); | |
FileInputStream fisLocal = new FileInputStream(imageFile); | |
byte[] imageByteLocal = IOUtils.toByteArray(fisLocal); | |
//converting file format | |
FileInputStream fis = new FileInputStream(imageFile); | |
//Get Image height and width | |
BufferedImage bimg = ImageIO.read(fis); | |
int width = bimg.getWidth(); | |
int height = bimg.getHeight(); | |
return (width + "x" + height); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is to convert any picture into byte format. You can save this picture into byte format and save to data base if required. This script also measuring the image actual width and height in pixels.