Package org.im4java.core

Examples of org.im4java.core.ConvertCmd


    op.addImage(tiffPath);
    op.addImage("jp2:-");

    Pipe pipe = new Pipe(null, byteArrayOutputStream);

    ConvertCmd convert = new ConvertCmd();
    convert.setOutputConsumer(pipe);
    convert.run(op);

    OutputStream out = new FileOutputStream(jp2Path);
    out.write(byteArrayOutputStream.toByteArray());

    byteArrayOutputStream.close();
View Full Code Here


    IMOperation op = new IMOperation();
    op.addImage(tmpTiff.getAbsolutePath());
    op.resize(maxHeight, maxWidth);
    op.addImage(tmpJp2.getAbsolutePath());

    ConvertCmd convert = new ConvertCmd();
    try {
      convert.run(op);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (IM4JavaException e) {
View Full Code Here

    IMOperation op = new IMOperation();
    op.thumbnail(150);
    op.addImage(tmpJp2.getAbsolutePath());
    op.addImage(tmpTn.getAbsolutePath());

    ConvertCmd convert = new ConvertCmd();
    try {
      convert.run(op);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (IM4JavaException e) {
View Full Code Here

    }

    public boolean createThumb(Image iw, File outputFile, int size, boolean square) throws IOException {
        try {
            // create command
            ConvertCmd cmd = new ConvertCmd();

            // create the operation, add images and operators/options
            IMOperation op = new IMOperation();
            op.addImage(getFile(iw).getPath());

            if(square) {
                op.resize(size,size,"^");
                op.gravity("center");
                op.crop(size,size,0,0);
            } else {
                op.resize(size,size);
            }

            op.addImage(outputFile.getPath());

            cmd.run(op);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
View Full Code Here

    }

    public boolean cropImage(Image i, File outputFile, int top, int left, int width, int height) throws IOException {
        try {
            // create command
            ConvertCmd cmd = new ConvertCmd();

            // create the operation, add images and operators/options
            IMOperation op = new IMOperation();
            op.addImage(getFile(i).getPath());
            op.crop(width, height, left, top);
            op.addImage(outputFile.getPath());

            cmd.run(op);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
View Full Code Here

    }

    public boolean resizeImage(Image i, File outputFile, int width, int height) throws IOException {
        try {
            // create command
            ConvertCmd cmd = new ConvertCmd();

            // create the operation, add images and operators/options
            IMOperation op = new IMOperation();
            op.addImage(getFile(i).getPath());
            op.resize(width, height);
            op.addImage(outputFile.getPath());

            cmd.run(op);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
View Full Code Here

    }

    public boolean rotateImage(Image i, File outputFile, boolean clockwise) throws IOException {
        try {
            // create command
            ConvertCmd cmd = new ConvertCmd();

            // create the operation, add images and operators/options
            IMOperation op = new IMOperation();
            op.addImage(getFile(i).getPath());
            op.rotate(clockwise ? 90. : -90.);
            op.addImage(outputFile.getPath());

            cmd.run(op);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
View Full Code Here

    }
   
    public static File getThumbnailFile(File f) throws IOException, InterruptedException, IM4JavaException {
      File f2 = new File(f.getParentFile(), f.getName() + ".jpg");
      f2.deleteOnExit();
      ConvertCmd cmd = new ConvertCmd();
    IMOperation op = new IMOperation();
    op.addImage(f.getAbsolutePath());
    op.thumbnail(width, height);
    op.addImage(f2.getAbsolutePath());
        if (MediaFilterManager.isVerbose) {
        System.out.println("IM Thumbnail Param: "+op);
        }
    cmd.run(op);
    return f2;
    }
View Full Code Here

    }
   
    public static File getImageFile(File f, int page) throws IOException, InterruptedException, IM4JavaException {
      File f2 = new File(f.getParentFile(), f.getName() + ".jpg");
      f2.deleteOnExit();
      ConvertCmd cmd = new ConvertCmd();
    IMOperation op = new IMOperation();
    String s = "[" + page + "]";
    op.addImage(f.getAbsolutePath()+s);
    op.addImage(f2.getAbsolutePath());
        if (MediaFilterManager.isVerbose) {
        System.out.println("IM Image Param: "+op);
        }
    cmd.run(op);
    return f2;
    }
View Full Code Here

   *
   * @return <code>true</code> if the library is available
   */
  private boolean imageMagickAvailable() {
    try {
      ConvertCmd cmd = new ConvertCmd();
      IMOperation versionOp = new IMOperation();
      versionOp.version();
      cmd.run(versionOp);
      logger.debug("ImageMagick detected and found to be working");
      return true;
    } catch (Throwable e) {
      logger.info("ImageMagick not available: {}", e.getMessage());
      return false;
View Full Code Here

TOP

Related Classes of org.im4java.core.ConvertCmd

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.