public Frame(String fileName,float quality) throws IOException{
		//String dirName = System.getProperty("user.dir");
		//String fName = dirName + "/data/" + fileName;
		System.out.println(fileName);
		
		
		File imageFile = new File(fileName);
		
		InputStream is = new FileInputStream(imageFile);
		
		// create a BufferedImage as the result of decoding the supplied InputStream
		BufferedImage image = ImageIO.read(is);
		
		// get all image writers for JPG format
		Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");

		if (!writers.hasNext())
			throw new IllegalStateException("No writers found");

		
		ImageWriter writer = (ImageWriter) writers.next();

		ImageWriteParam param = writer.getDefaultWriteParam();

		// compress to a given quality
		param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
		param.setCompressionQuality(quality);
		
		IIOImage tempImg = new IIOImage(image, null, null); 
		ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
		writer.setOutput(ImageIO.createImageOutputStream(byteArrayOut));
		// appends a complete image stream containing a single image and
		//associated stream and image metadata and thumbnails to the output
		writer.write(null, tempImg, param);
		
//		System.out.print(byteArrayOut.toString());
		
		// get byte[] from byteArrayOut
		// this.baos = byteArrayOut; 
		this.bytearray = byteArrayOut.toByteArray();
		
		// convert IIOImage tempImg into RenderedImage
		RenderedImage rImg = tempImg.getRenderedImage(); 

		// get height and width from RenderedImage
		this.height = rImg.getHeight();
		this.width = rImg.getWidth();
//		System.out.print(this.bytearray);
//		
//		System.out.print(this.height);
//		System.out.print( this.width);
//		System.out.println("\n");
//		byte[] bytes = {-1, 0, 1, 2, 3 };
	    StringBuilder sb = new StringBuilder();
	    int i=0;
	    for (byte b : this.bytearray) {
	    	if(i==this.width){
//	    		sb.append("\n");
//	    		System.out.println("");
	    		i=0;

	    	}
	        sb.append(String.format("%02X ", b));
	        System.out.print(String.format("%02X ", b));
	        i=i+1;
	    }
	    
//	    System.out.println("\n");
//	    for(i=0;i<this.height;i++){
//	    	System.out.println(sb.substring(255*i, 255*(i+1)).toString());
//	    }
	    
	    
//	    System.out.println("\n");
//	    System.out.println("\n");
//	    System.out.println("\n");
//	    System.out.println("\n");
	    
		// close all streams
		is.close();
		writer.dispose();
		
	}