import james.*; import image.Bmp; import java.awt.*; import java.io.*; import java.util.*; import java.lang.*; public class Embed { public static void StandardUsage() { System.out.println("F5/JpegEncoder for Java(tm)"); System.out.println(""); System.out.println("Program usage: java Embed [Options] \"InputImage\".\"ext\" [\"OutputFile\"[.jpg]]"); System.out.println(""); System.out.println("You have the following options:"); System.out.println("-e \tdefault: embed nothing"); System.out.println("-p \t\tdefault: \"abc123\", only used when -e is specified"); System.out.println("-q \tdefault: 80"); System.out.println("-c \t\tdefault: \"JPEG Encoder Copyright 1998, James R. Weeks and BioElectroMech. \""); System.out.println(""); System.out.println("\"InputImage\" is the name of an existing image in the current directory."); System.out.println(" (\"InputImage may specify a directory, too.) \"ext\" must be .tif, .gif,"); System.out.println(" or .jpg."); System.out.println("Quality is an integer (0 to 100) that specifies how similar the compressed"); System.out.println(" image is to \"InputImage.\" 100 is almost exactly like \"InputImage\" and 0 is"); System.out.println(" most dissimilar. In most cases, 70 - 80 gives very good results."); System.out.println("\"OutputFile\" is an optional argument. If \"OutputFile\" isn't specified, then"); System.out.println(" the input file name is adopted. This program will NOT write over an existing"); System.out.println(" file. If a directory is specified for the input image, then \"OutputFile\""); System.out.println(" will be written in that directory. The extension \".jpg\" may automatically be"); System.out.println(" added."); System.out.println(""); System.out.println("Copyright 1998 BioElectroMech and James R. Weeks. Portions copyright IJG and"); System.out.println(" Florian Raemy, LCAV. See license.txt for details."); System.out.println("Visit BioElectroMech at www.obrador.com. Email James@obrador.com."); System.out.println("Steganography added by Andreas Westfeld, westfeld@inf.tu-dresden.de"); System.exit(0); } public static void main(String args[]) { Image image = null; FileOutputStream dataOut = null; File file, outFile; JpegEncoder jpg; int i, Quality = 80; // Check to see if the input file name has one of the extensions: // .tif, .gif, .jpg // If not, print the standard use info. boolean haveInputImage = false; String embFileName=null; String comment="JPEG Encoder Copyright 1998, James R. Weeks and BioElectroMech. "; String password="abc123"; String inFileName=null; String outFileName=null; if (args.length < 1) StandardUsage(); for (i=0; i 100) System.exit(0); } */ file = new File(inFileName); if (file.exists()) { try { dataOut = new FileOutputStream(outFileName,false); } catch(IOException e) {} if (inFileName.endsWith(".bmp")) { Bmp bmp = new Bmp(inFileName); image = bmp.getImage(); } else image = Toolkit.getDefaultToolkit().getImage(inFileName); jpg = new JpegEncoder(image, Quality, dataOut, comment); if (false) jpg.Compress(); else { try { if (embFileName==null) jpg.Compress(); else jpg.Compress(new FileInputStream(embFileName), password); } catch (Exception e) { e.printStackTrace(); } } try { dataOut.close(); } catch(IOException e) {} } else { System.out.println("I couldn't find " + inFileName + ". Is it in another directory?"); } System.exit(0); } }