Sanselanã使ã£ã¦TIFFãèªã¿è¾¼ã
Javaã§TIFFç»åãèªã¿è¾¼ãå¿ è¦ãæã£ãã®ã§èª¿ã¹ã¦ã¿ããImageIO辺ãã§æ¢ã«å¯¾å¿æ¸ã¿ãã¨æãã¤ã¤ã念ã®ãã対å¿ãã©ã¼ãããããã§ãã¯ãã¦ã¿ãã
public void doPrintImageFormat(){ String[] formatNames = ImageIO.getReaderFormatNames(); System.out.println("ReaderFormatNames:"); for(String s:formatNames) { System.out.print(s+", "); } }
çµæã¯ä¸è¨ã®éããæ®å¿µãªããJava SE6ã§ãæªå¯¾å¿ãããã
ReaderFormatNames:
BMP, bmp, jpg, JPG, jpeg, wbmp, png, JPEG, PNG, WBMP, GIF, gif,
JAI (Java Advanced Imaging) ã使ã£ã¦ãè¯ãã®ã ãã©ãååä½ç°å¢ã§ã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«ããªããã°ãªããªãã®ã¯é¢åã ããããã¾ã§é«æ©è½ãªãã®ã¯è¦ããªããjarãã¡ã¤ã«ä¸ã¤ã ãã§ç°¡åã«ä½¿ããã¢ãã¯ãªããã¨æ¢ãã¦ã¿ãããSanselanãè¦ã¤ãããç»åãµã¤ãºãåå¾ãããµã³ãã«ã³ã¼ãã¯ä¸è¨ã®éãã
import java.io.File; import java.io.IOException; import org.apache.sanselan.ImageFormat; import org.apache.sanselan.ImageReadException; import org.apache.sanselan.Sanselan; import org.apache.sanselan.ImageInfo; public class Main { public static void main(String[] args) throws ImageReadException, IOException { doPrintImageSize("sample.jpg"); doPrintImageSize("sample.tiff"); doPrintImageSize("sample.psd"); } public static void doPrintImageSize(String filename) throws ImageReadException, IOException{ long t1 = System.currentTimeMillis(); File srcFile = new File(filename); ImageInfo info = Sanselan.getImageInfo(srcFile); long t2 = System.currentTimeMillis(); System.out.println("- "+srcFile.getAbsolutePath()+", Width:"+info.getWidth()+", Height:"+info.getHeight()+", Time:"+(t2-t1)); } }
å®è¡çµæã¯ä¸è¨ã®éããJPEG, TIFF, PSDãªã©ã®ç»åãµã¤ãºãã¡ã¿ãã¼ã¿ããåå¾ãã¦ããããªããªãè¯ãæãã
- /Users/hoge/Console/sample.jpg, Width:1600, Height:1200, Time:228 - /Users/hoge/Console/sample.tiff, Width:1600, Height:1200, Time:6 - /Users/hoge/Console/sample.psd, Width:1600, Height:1200, Time:2
ç»åãã¼ã¿ã®èªã¿è¾¼ã¿ãç°¡åãï¼å¼ã³åºãå ã¯こちらã®コードãåç §ï¼
BufferedImage image = ImageReadExample.imageReadExample(new File("sample.tiff"));
ãã¨ã¯é常ã®ç»åãã¼ã¿ã¨åæ§ã«æ±ãããåæ§ã«JPEGç»åã®Exifãã¼ã¿åå¾ãç°¡åãï¼å¼ã³åºãå ã¯こちらãåç §ï¼
MetadataExample.metadataExample(new File("sample.jpg"));
ãã®çµæã¯ä¸è¨ã®éãã
file: sample.jpg XResolution: 180 Date Time: '2000:06:11 23:02:49' Date Time Original: '2000:06:11 23:02:49' Create Date: '2000:06:11 23:02:49' ISO: Not Found. Shutter Speed Value: 256042/65536 (3.907) Aperture Value: 194698/65536 (2.971) Brightness Value: Not Found. GPS Latitude Ref: 'R98' GPS Latitude: 48, 49, 48, 48 GPS Longitude Ref: Not Found. GPS Longitude: Not Found. item: Make: 'Canon' item: Model: 'Canon IXY DIGITAL' item: Orientation: 1 item: XResolution: 180 item: YResolution: 180 item: Resolution Unit: 2 item: Modify Date: '2000:06:11 23:02:49' item: YCbCr Positioning: 1 item: Exif Offset: 184 item: Exposure Time: 1/15 (0.067) item: FNumber: 28/10 (2.8) item: Exif Version: 48, 50, 49, 48 item: Date Time Original: '2000:06:11 23:02:49' item: Create Date: '2000:06:11 23:02:49' item: Components Configuration: 1, 2, 3, 0 item: Compressed Bits Per Pixel: 3 item: Shutter Speed Value: 256042/65536 (3.907) item: Aperture Value: 194698/65536 (2.971) item: Exposure Compensation: 0 item: Max Aperture Value: 194698/65536 (2.971) item: Subject Distance: 2615/1000 (2.615) item: Metering Mode: 2 item: Flash: 0 item: Focal Length: 173/32 (5.406) item: Maker Note: 10, 0, 1, 0, 3, 0, 19, 0, 0, 0, 120, 3, 0, 0, 2, 0, 3, 0, 4, 0, 0, 0, -98, 3, 0, 0, 3, 0, 3, 0, 4, 0, 0, 0, -90, 3, 0, 0, 4, 0, 3, 0, 15, 0, 0, 0, -82, 3, 0, 0, 0... (310) item: UserComment: '' item: Flashpix Version: 48, 49, 48, 48 item: Color Space: 1 item: Exif Image Width: 1600 item: Exif Image Length: 1200 item: Interop Offset: 1088 item: Focal Plane XResolution: 1600000/206 (7,766.99) item: Focal Plane YResolution: 1200000/155 (7,741.935) item: Focal Plane Resolution Unit: 2 item: Sensing Method: 2 item: File Source: 3 item: Interop Index: 'R98' item: Interop Version: 48, 49, 48, 48 item: Related Image Width: 1600 item: Related Image Length: 1200 item: Compression: 6 item: XResolution: 180 item: YResolution: 180 item: Resolution Unit: 2 item: Jpg From Raw Start: 1524 item: Jpg From Raw Length: 4542
Jarãã¡ã¤ã«ä¸ã¤ãå«ããã°è¯ãã ããªã®ã§ãããã¯ä¾¿å©ã«ä½¿ãããã§ããã