Hoe afbeelding in byte te converteren, beeldbreedte en -hoogte te krijgen met behulp van Java



Dit is om elke foto in byte-indeling te converteren. U kunt het jpg- of png-formaat omzetten in byte-indeling en indien nodig opslaan in de database met behulp van Java. Dit script geeft ook beeldeigenschappen zoals werkelijke beeldbreedte en -hoogte in pixels. Yuu kan beeldeigenschappen krijgen met "width x height" -formaat in een string-indeling.

Afbeelding converteren naar byte, beeldbreedte en -hoogte verkrijgen met Java

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

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); } }

Vorige Artikel

Hoe Windows-programma's uitvoeren op Linux?

Hoe Windows-programma's uitvoeren op Linux?

De Linux-gebruikers die overstapten van het Windows-ecosysteem, missen mogelijk veel Windows-programma's die op hun computers werden gebruikt. Linux is een redelijk goed besturingssysteem dat meegaat in hun ontwikkelingscyclus. Er zijn echter nog steeds een aantal programma's die kunnen missen voor Linux-gebruikers die zijn overgestapt van Windows...

Volgende Artikel

Hoe iPhone & iPad scherm opnemen zonder app?

Hoe iPhone & iPad scherm opnemen zonder app?

Facebook tjilpen Pinterest WhatsApp Telegram Wil je een film maken met al je schermactiviteiten op je iPhone? Als u een iPad of iPhone bezit, kunt u alle schermactiviteiten van uw apparaat op uw computer opnemen. U kunt volledige schermactiviteit op uw iPhone of iPad opnemen zonder apps van derden. Hoewel je apps wilt gebruiken om je apparaatscherm op te nemen, is het moeilijk om apps in iTunes Store te vinden...