วิธีการแปลงรูปภาพให้เป็นไบต์รับความกว้างของภาพและความสูงโดยใช้ Java



นี่คือการแปลงภาพใด ๆ ในรูปแบบไบต์ คุณสามารถแปลงรูปแบบ jpg หรือ png เป็นรูปแบบไบต์และบันทึกลงในฐานข้อมูลหากจำเป็นต้องใช้ Java สคริปต์นี้ยังให้คุณสมบัติของภาพเช่นความกว้างและความสูงของรูปภาพที่แท้จริงในหน่วยพิกเซล Yuu สามารถรับคุณสมบัติรูปภาพด้วยรูปแบบ“ ความกว้าง x ความสูง” ในรูปแบบสตริง

แปลงรูปภาพเป็นไบต์รับความกว้างของภาพและความสูงโดยใช้ 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); } }

บทความก่อนหน้านี้

วิธีกำหนดค่าการแชร์ไฟล์บลูทู ธ บน Android 6.0

วิธีกำหนดค่าการแชร์ไฟล์บลูทู ธ บน Android 6.0

Facebook พูดเบาและรวดเร็ว Pinterest WhatsApp โทรเลข เมื่อมีความจำเป็นต้องแชร์ไฟล์อย่างรวดเร็วด้วยสมาร์ทโฟนตัวเลือกแรกที่เราจะลองคือตัวเลือกบลูทู ธ สิ่งอำนวยความสะดวกบลูทู ธ คุ้นเคยกับผู้ใช้งานสมาร์ทโฟนมากเนื่องจากการตั้งค่าและการถ่ายโอนข้อมูลอย่างรวดเร็ว อย่างไรก็ตามเราอาจประสบปัญหาเล็ก ๆ บางอย่างในขณะที่พยายามเริ่มต้นการถ่ายโอนข้อมูลกับ Android 6.0 marshmallow ที่นี่เราจะดูวิธีการถ่ายโอนไฟล์อย่างถูกต้องโดยใช้บลูทู ธ ในสมาร์ทโฟน Android ที่ทำงานกับ Marshmallow แนวคิดพื้นฐานของการถ่ายโอนข้อมูลบลูทู ธ ยังไม่เปลี่ยนแปลงตั้งแต่เปิดตัว เราจำเป็นต้องจับคู่อุปกรณ์ก่อนที่เราจะเริ่มการเชื่อมต่อการถ่ายโอ...

บทความถัดไป

วิธีทำการค้นหารูปภาพแบบย้อนกลับออนไลน์และโทรศัพท์ได้อย่างไร

วิธีทำการค้นหารูปภาพแบบย้อนกลับออนไลน์และโทรศัพท์ได้อย่างไร

คุณเคยได้ยินเกี่ยวกับ Reverse Image Search หรือไม่? มันเป็นเทคนิคที่ใช้กันอย่างแพร่หลายโดยองค์กรธุรกิจบล็อกเกอร์หรือแม้แต่ผู้ใช้เว็บทั่วไปเพื่อค้นหาแหล่งต้นฉบับของภาพที่เฉพาะเจาะจงหรือเพื่อค้นหาภาพที่คล้ายกัน นอกจากนี้ยังสามารถใช้เพื่อรับข้อมูลเพิ่มเติมเกี่ยวกับภาพเช่นผู้สร้าง หากคุณเป็นบล็อกเกอร์คุณสามารถใช้เทคนิคนี้เพื่อค้นหาว่ามีบุคคลอื่นในเว็บคัดลอกภาพของคุณหรือไม่ บางคนใช้ประโยชน์จากเทคนิคนี้เพื่อดึงภาพบางภาพที่มีคุณภาพสูงหรือล่าสุดจากเว็บ ลองมาดูเครื่องมือออนไลน์ค้นหารูปภาพที่หลากหลายและแอพภาพย้อนกลับซึ่งสามารถใช้ในการทำ Reverse Image Search ออนไลน์หรือใช้สมาร์ทโฟนที่ใช้ iPhone / Android ...