ParameterBlockJAI 원격 서버 이미지 크기 가져오기

1314 단어 parameter
 public static String getPicSize(String url){
    	
    	 URL temp;
    	 BufferedInputStream in;
    	 int   orinWidth   =   0; 
	     int   orinHeigth   =   0;
	     FileOutputStream file;
    	 try {
    		 temp = new URL(url);
			 try {
				 String fileName="D:\\1.jpg";
				 in = new BufferedInputStream(temp.openStream());
				 file = new FileOutputStream(new File(fileName));
				 int t;
				 while ((t = in.read()) != -1) {
					 file.write(t);
				 }
				//fileload  
		        ParameterBlockJAI   loadPB   =   new   ParameterBlockJAI("fileload"); 
		        //  
		        loadPB.setParameter( "filename",fileName); 
		        PlanarImage   source   =   JAI.create( "fileload",   loadPB); 
		        //  
		        orinWidth   =   source.getWidth(); 
		        orinHeigth   =   source.getHeight();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		  return orinWidth+"*"+orinHeigth;
    }

좋은 웹페이지 즐겨찾기