Package ca.carleton.gcrc.olkit.multimedia.imageMagick

Examples of ca.carleton.gcrc.olkit.multimedia.imageMagick.ImageMagickProcessor


     
      request.setThumbnailFile(thumbnailFile);
      request.setThumbnailCreated(true);

      ImageMagickInfo imInfo = ImageMagick.getInfo();
      ImageMagickProcessor im = imInfo.getProcessor(progress);
      ImageInfo thumbImageInfo = im.getImageInfo( thumbnailFile );
      request.setThumbnailHeight( thumbImageInfo.height );
      request.setThumbnailWidth( thumbImageInfo.width );
    }
  }
View Full Code Here


    ImageMagickInfo imInfo = ImageMagick.getInfo();
   
    // Get information about image
    ImageInfo imageInfo = null;
    if( imInfo.isAvailable ){
      ImageMagickProcessor imageMagick = imInfo.getProcessor();
      imageInfo = imageMagick.getImageInfo( inFile );
    }

    boolean conversionRequired = false;
    boolean resizeRequired = false;
    if( null != imageInfo ) {
      request.setInHeight( imageInfo.height );
      request.setInWidth( imageInfo.width );

      // Check if conversion is required
      conversionRequired = imageConversionThreshold.isConversionRequired(
          imageInfo.format
          ,null
          ,null
          ,null
          ,new Long(imageInfo.width)
          ,new Long(imageInfo.height)
          );
      resizeRequired = imageConversionThreshold.isResizeRequired(
          new Long(imageInfo.width)
          ,new Long(imageInfo.height)
          );
    }
   
    if( false == conversionRequired && false == resizeRequired ) {
      // Conversion not required, converted file is the uploaded file
      // Same applies if conversion is impossible because ImageMagick
      // is not present.
      request.setOutFile(inFile);
      progress.updateProgress(100);
    } else {
      File outFile = request.getOutFile();
      if( null == outFile ) {
        File parentDir = inFile.getParentFile();
        outFile = File.createTempFile("conv", ".jpg", parentDir);
      }
     
      ImageMagickProcessor im = imInfo.getProcessor(progress);
      if( resizeRequired ) {
        im.resizeImage(imageInfo, outFile, IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT);
      } else {
        im.convertImage(imageInfo, outFile);
      }
     
      request.setOutFile(outFile);
      request.setConversionPerformed(true);

      ImageInfo outImageInfo = im.getImageInfo( outFile );
      request.setOutHeight( outImageInfo.height );
      request.setOutWidth( outImageInfo.width );
    }
   
    // Create thumbnail
    if( null != imageInfo && request.isThumbnailRequested() ){
      File thumbnailFile = request.getThumbnailFile();
      if( null == thumbnailFile ) {
        File parentDir = inFile.getParentFile();

        String name = inFile.getName();
        int index = name.lastIndexOf('.');
        if( index > 0 ) {
          name = name.substring(0, index);
        }
        name = name+"_thumb.png";
       
        thumbnailFile = new File(parentDir, name);
      }

      ImageMagickProcessor im = imInfo.getProcessor(progress);
      im.resizeImage(imageInfo, thumbnailFile, IMAGE_THUMB_WIDTH, IMAGE_THUMB_HEIGHT);
     
      request.setThumbnailFile(thumbnailFile);
      request.setThumbnailCreated(true);

      ImageInfo thumbImageInfo = im.getImageInfo( thumbnailFile );
      request.setThumbnailHeight( thumbImageInfo.height );
      request.setThumbnailWidth( thumbImageInfo.width );
    }
  }
View Full Code Here

     
      request.setThumbnailFile(thumbnailFile);
      request.setThumbnailCreated(true);

      ImageMagickInfo imInfo = ImageMagick.getInfo();
      ImageMagickProcessor im = imInfo.getProcessor(progress);
      ImageInfo thumbImageInfo = im.getImageInfo( thumbnailFile );
      request.setThumbnailHeight( thumbImageInfo.height );
      request.setThumbnailWidth( thumbImageInfo.width );
    }
  }
View Full Code Here

    ImageMagickInfo imInfo = ImageMagick.getInfo();
   
    // Get information about image
    ImageInfo imageInfo = null;
    if( imInfo.isAvailable ){
      ImageMagickProcessor imageMagick = imInfo.getProcessor();
      imageInfo = imageMagick.getImageInfo( inFile );
    }

    // Check if conversion is required
    boolean conversionRequired = false;
    boolean resizeRequired = false;
    if( null != imageInfo ) {
      request.setInHeight( imageInfo.height );
      request.setInWidth( imageInfo.width );
      if( imageInfo.width > IMAGE_MAX_WIDTH ) {
        resizeRequired = true;
      } else if( imageInfo.height > IMAGE_MAX_HEIGHT ) {
        resizeRequired = true;
      }
      if( false == "JPEG".equals( imageInfo.format ) ) {
        conversionRequired = true;
      }
    }
   
    if( false == conversionRequired && false == resizeRequired ) {
      // Conversion not required, converted file is the uploaded file
      // Same applies if conversion is impossible because ImageMagick
      // is not present.
      request.setOutFile(inFile);
      progress.updateProgress(100);
    } else {
      File outFile = request.getOutFile();
      if( null == outFile ) {
        File parentDir = inFile.getParentFile();
        outFile = File.createTempFile("conv", ".jpg", parentDir);
      }
     
      ImageMagickProcessor im = imInfo.getProcessor(progress);
      if( resizeRequired ) {
        im.resizeImage(imageInfo, outFile, IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT);
      } else {
        im.convertImage(imageInfo, outFile);
      }
     
      request.setOutFile(outFile);
      request.setConversionPerformed(true);

      ImageInfo outImageInfo = im.getImageInfo( outFile );
      request.setOutHeight( outImageInfo.height );
      request.setOutWidth( outImageInfo.width );
    }
   
    // Create thumbnail
    if( null != imageInfo && request.isThumbnailRequested() ){
      File thumbnailFile = request.getThumbnailFile();
      if( null == thumbnailFile ) {
        File parentDir = inFile.getParentFile();

        String name = inFile.getName();
        int index = name.lastIndexOf('.');
        if( index > 0 ) {
          name = name.substring(0, index);
        }
        name = name+"_thumb.png";
       
        thumbnailFile = new File(parentDir, name);
      }

      ImageMagickProcessor im = imInfo.getProcessor(progress);
      im.resizeImage(imageInfo, thumbnailFile, IMAGE_THUMB_WIDTH, IMAGE_THUMB_HEIGHT);
     
      request.setThumbnailFile(thumbnailFile);
      request.setThumbnailCreated(true);

      ImageInfo thumbImageInfo = im.getImageInfo( thumbnailFile );
      request.setThumbnailHeight( thumbImageInfo.height );
      request.setThumbnailWidth( thumbImageInfo.width );
    }
  }
View Full Code Here

     
      request.setThumbnailFile(thumbnailFile);
      request.setThumbnailCreated(true);

      ImageMagickInfo imInfo = ImageMagick.getInfo();
      ImageMagickProcessor im = imInfo.getProcessor(progress);
      ImageInfo thumbImageInfo = im.getImageInfo( thumbnailFile );
      request.setThumbnailHeight( thumbImageInfo.height );
      request.setThumbnailWidth( thumbImageInfo.width );
    }
  }
View Full Code Here

    ImageMagickInfo imInfo = ImageMagick.getInfo();
   
    // Get information about image
    ImageInfo imageInfo = null;
    if( imInfo.isAvailable ){
      ImageMagickProcessor imageMagick = imInfo.getProcessor();
      imageInfo = imageMagick.getImageInfo( inFile );
    }

    boolean conversionRequired = false;
    boolean resizeRequired = false;
    boolean reorientationRequired = false;
    if( null != imageInfo ) {
      request.setInHeight( imageInfo.height );
      request.setInWidth( imageInfo.width );

      // Check if conversion is required
      conversionRequired = imageConversionThreshold.isConversionRequired(
          imageInfo.format
          ,null
          ,null
          ,null
          ,new Long(imageInfo.width)
          ,new Long(imageInfo.height)
          );
      resizeRequired = imageConversionThreshold.isResizeRequired(
          new Long(imageInfo.width)
          ,new Long(imageInfo.height)
          );
     
      if( imageInfo.orientation == ImageInfo.Orientation.REQUIRES_CONVERSION ) {
        reorientationRequired = true;
      }
    }
   
    if( false == conversionRequired
     && false == resizeRequired
     && false == reorientationRequired
     ) {
      // Conversion not required, converted file is the uploaded file
      // Same applies if conversion is impossible because ImageMagick
      // is not present.
      request.setOutFile(inFile);
      progress.updateProgress(100);
    } else {
      File outFile = request.getOutFile();
      if( null == outFile ) {
        File parentDir = inFile.getParentFile();
        outFile = File.createTempFile("conv", ".jpg", parentDir);
      }
     
      ImageMagickProcessor im = imInfo.getProcessor(progress);
      if( resizeRequired ) {
        im.resizeImage(imageInfo, outFile, IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT);
      } else if(conversionRequired) {
        im.convertImage(imageInfo, outFile);
      } else {
        im.reorientImage(imageInfo, outFile);
      }
     
      request.setOutFile(outFile);
      request.setConversionPerformed(true);

      ImageInfo outImageInfo = im.getImageInfo( outFile );
      request.setOutHeight( outImageInfo.height );
      request.setOutWidth( outImageInfo.width );
    }
   
    // Create thumbnail
    if( null != imageInfo && request.isThumbnailRequested() ){
      File thumbnailFile = request.getThumbnailFile();
      if( null == thumbnailFile ) {
        File parentDir = inFile.getParentFile();

        String name = inFile.getName();
        int index = name.lastIndexOf('.');
        if( index > 0 ) {
          name = name.substring(0, index);
        }
        name = name+"_thumb.png";
       
        thumbnailFile = new File(parentDir, name);
      }

      ImageMagickProcessor im = imInfo.getProcessor(progress);
      im.resizeImage(imageInfo, thumbnailFile, IMAGE_THUMB_WIDTH, IMAGE_THUMB_HEIGHT);
     
      request.setThumbnailFile(thumbnailFile);
      request.setThumbnailCreated(true);

      ImageInfo thumbImageInfo = im.getImageInfo( thumbnailFile );
      request.setThumbnailHeight( thumbImageInfo.height );
      request.setThumbnailWidth( thumbImageInfo.width );
    }
  }
View Full Code Here

    ImageMagickInfo imInfo = ImageMagick.getInfo();
   
    // Get information about image
    ImageInfo imageInfo = null;
    if( imInfo.isAvailable ){
      ImageMagickProcessor imageMagick = imInfo.getProcessor();
      imageInfo = imageMagick.getImageInfo( inFile );
    }

    if( null != imageInfo ) {
      request.setInHeight( imageInfo.height );
      request.setInWidth( imageInfo.width );
    }
   
    // Create thumbnail
    if( null != imageInfo && request.isThumbnailRequested() ){
      File thumbnailFile = request.getThumbnailFile();
      if( null == thumbnailFile ) {
        File parentDir = inFile.getParentFile();

        String name = inFile.getName();
        int index = name.lastIndexOf('.');
        if( index > 0 ) {
          name = name.substring(0, index);
        }
        name = name+"_thumb.png";
       
        thumbnailFile = new File(parentDir, name);
      }

      ImageMagickProcessor im = imInfo.getProcessor(progress);
      im.resizeImage(imageInfo, thumbnailFile, IMAGE_THUMB_WIDTH, IMAGE_THUMB_HEIGHT);
     
      request.setThumbnailFile(thumbnailFile);
      request.setThumbnailCreated(true);

      ImageInfo thumbImageInfo = im.getImageInfo( thumbnailFile );
      request.setThumbnailHeight( thumbImageInfo.height );
      request.setThumbnailWidth( thumbImageInfo.width );
    }
  }
View Full Code Here

     
      request.setThumbnailFile(thumbnailFile);
      request.setThumbnailCreated(true);

      ImageMagickInfo imInfo = ImageMagick.getInfo();
      ImageMagickProcessor im = imInfo.getProcessor(progress);
      ImageInfo thumbImageInfo = im.getImageInfo( thumbnailFile );
      request.setThumbnailHeight( thumbImageInfo.height );
      request.setThumbnailWidth( thumbImageInfo.width );
    }
  }
View Full Code Here

    ImageMagickInfo imInfo = ImageMagick.getInfo();
   
    // Get information about image
    ImageInfo imageInfo = null;
    if( imInfo.isAvailable ){
      ImageMagickProcessor imageMagick = imInfo.getProcessor();
      imageInfo = imageMagick.getImageInfo( inFile );
    }

    boolean conversionRequired = false;
    boolean resizeRequired = false;
    boolean reorientationRequired = false;
    if( null != imageInfo ) {
      request.setInHeight( imageInfo.height );
      request.setInWidth( imageInfo.width );

      // Check if conversion is required
      conversionRequired = imageConversionThreshold.isConversionRequired(
          imageInfo.format
          ,null
          ,null
          ,null
          ,new Long(imageInfo.width)
          ,new Long(imageInfo.height)
          );
      resizeRequired = imageConversionThreshold.isResizeRequired(
          new Long(imageInfo.width)
          ,new Long(imageInfo.height)
          );
     
      if( imageInfo.orientation == ImageInfo.Orientation.REQUIRES_CONVERSION ) {
        reorientationRequired = true;
      }
    }
   
    if( request.isSkipConversion() ){
      progress.updateProgress(100);
     
    } else if( false == conversionRequired
     && false == resizeRequired
     && false == reorientationRequired
     ) {
      // Conversion not required, converted file is the uploaded file
      // Same applies if conversion is impossible because ImageMagick
      // is not present.
      request.setOutFile(inFile);
      progress.updateProgress(100);
     
    } else {
      File outFile = request.getOutFile();
      if( null == outFile ) {
        File parentDir = inFile.getParentFile();
        outFile = File.createTempFile("conv", ".jpg", parentDir);
      }
     
      ImageMagickProcessor im = imInfo.getProcessor(progress);
      if( resizeRequired ) {
        im.resizeImage(imageInfo, outFile, IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT);
      } else if(conversionRequired) {
        im.convertImage(imageInfo, outFile);
      } else {
        im.reorientImage(imageInfo, outFile);
      }
     
      request.setOutFile(outFile);
      request.setConversionPerformed(true);

      ImageInfo outImageInfo = im.getImageInfo( outFile );
      request.setOutHeight( outImageInfo.height );
      request.setOutWidth( outImageInfo.width );
    }
   
    // Create thumbnail
    if( null != imageInfo && request.isThumbnailRequested() ){
      File thumbnailFile = request.getThumbnailFile();
      if( null == thumbnailFile ) {
        File parentDir = inFile.getParentFile();

        String name = inFile.getName();
        int index = name.lastIndexOf('.');
        if( index > 0 ) {
          name = name.substring(0, index);
        }
        name = name+"_thumb.jpeg";
       
        thumbnailFile = new File(parentDir, name);
      }

      ImageMagickProcessor im = imInfo.getProcessor(progress);
      im.resizeImage(imageInfo, thumbnailFile, IMAGE_THUMB_WIDTH, IMAGE_THUMB_HEIGHT);
     
      request.setThumbnailFile(thumbnailFile);
      request.setThumbnailCreated(true);

      ImageInfo thumbImageInfo = im.getImageInfo( thumbnailFile );
      request.setThumbnailHeight( thumbImageInfo.height );
      request.setThumbnailWidth( thumbImageInfo.width );
    }
  }
View Full Code Here

    ImageMagickInfo imInfo = ImageMagick.getInfo();
   
    // Get information about image
    ImageInfo imageInfo = null;
    if( imInfo.isAvailable ){
      ImageMagickProcessor imageMagick = imInfo.getProcessor();
      imageInfo = imageMagick.getImageInfo( inFile );
    }

    if( null != imageInfo ) {
      request.setInHeight( imageInfo.height );
      request.setInWidth( imageInfo.width );
    }
   
    // Create thumbnail
    if( null != imageInfo && request.isThumbnailRequested() ){
      File thumbnailFile = request.getThumbnailFile();
      if( null == thumbnailFile ) {
        File parentDir = inFile.getParentFile();

        String name = inFile.getName();
        int index = name.lastIndexOf('.');
        if( index > 0 ) {
          name = name.substring(0, index);
        }
        name = name+"_thumb.png";
       
        thumbnailFile = new File(parentDir, name);
      }

      ImageMagickProcessor im = imInfo.getProcessor(progress);
      im.resizeImage(imageInfo, thumbnailFile, IMAGE_THUMB_WIDTH, IMAGE_THUMB_HEIGHT);
     
      request.setThumbnailFile(thumbnailFile);
      request.setThumbnailCreated(true);

      ImageInfo thumbImageInfo = im.getImageInfo( thumbnailFile );
      request.setThumbnailHeight( thumbImageInfo.height );
      request.setThumbnailWidth( thumbImageInfo.width );
    }
  }
View Full Code Here

TOP

Related Classes of ca.carleton.gcrc.olkit.multimedia.imageMagick.ImageMagickProcessor

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.