当前位置: 首页>>代码示例>>Java>>正文


Java Sanselan类代码示例

本文整理汇总了Java中org.apache.sanselan.Sanselan的典型用法代码示例。如果您正苦于以下问题:Java Sanselan类的具体用法?Java Sanselan怎么用?Java Sanselan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Sanselan类属于org.apache.sanselan包,在下文中一共展示了Sanselan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canDecodeInput

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
public boolean canDecodeInput(Object input) throws IOException {
  if (!(input instanceof ImageInputStream)) {
    return false;
  }
  final ImageInputStream stream = (ImageInputStream)input;
  try {
    final ImageFormat imageFormat = Sanselan.guessFormat(new MyByteSource(stream));
    if (myFormats.contains(imageFormat)) {
      myFormat.set(imageFormat);
      return true;
    }
    return false;
  }
  catch (ImageReadException e) {
    throw new IOException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SanselanImageReaderSpi.java

示例2: readImageCmyk

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
/**
 * Attempt to read the image as a CYMK or YCCK file.
 *
 * @param file
 * @param reader
 * @return
 */
private BufferedImage readImageCmyk(File file, ImageReader reader) {
    colorType = COLOR_TYPE_CMYK;
    BufferedImage image;
    try {
        checkAdobeMarker(file);
        ICC_Profile profile = Sanselan.getICCProfile(file);
        WritableRaster raster = (WritableRaster) reader.readRaster(0, null);

        if (colorType == COLOR_TYPE_YCCK) {
            convertYcckToCmyk(raster);
        }

        if (hasAdobeMarker) {
            convertInvertedColors(raster);
        }

        image = convertCmykToRgb(raster, profile);
    } catch (IOException | ImageReadException | CMMException ex) {
        LOG.warn("Failed to transform image: {}, error: {}", file.getAbsolutePath(), ex.getMessage());
        image = null;
    }
    return image;
}
 
开发者ID:YAMJ,项目名称:yamj-v2,代码行数:31,代码来源:JpegReader.java

示例3: readIconData

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
private IconData readIconData(byte[] iconData, IconInfo fIconInfo)
        throws ImageReadException, IOException
{
    ImageFormat imageFormat = Sanselan.guessFormat(iconData);
    if (imageFormat.equals(ImageFormat.IMAGE_FORMAT_PNG))
    {
        BufferedImage bufferedImage = Sanselan.getBufferedImage(iconData);
        PNGIconData pngIconData = new PNGIconData(fIconInfo, bufferedImage);
        return pngIconData;
    }
    else
    {
        try
        {
            return readBitmapIconData(iconData, fIconInfo);
        }
        catch (ImageWriteException imageWriteException)
        {
            IOException ioe = new IOException();
            ioe.initCause(imageWriteException);
            throw ioe;
        }
    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:25,代码来源:IcoImageParser.java

示例4: doMetaData

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
private ImageInfo doMetaData(ParserResultItem result,
		StreamLimiter streamLimiter) throws IOException {
	try {
		ImageInfo info = Sanselan.getImageInfo(
				streamLimiter.getNewInputStream(),
				streamLimiter.getOriginalFileName());
		if (info == null)
			return null;
		int width = info.getWidth();
		int height = info.getHeight();
		long area_size = (long) width * height;
		result.addField(ParserFieldEnum.image_width, width);
		result.addField(ParserFieldEnum.image_height, height);
		result.addField(ParserFieldEnum.image_area_size, area_size);
		result.addField(ParserFieldEnum.image_number,
				info.getNumberOfImages());
		result.addField(ParserFieldEnum.image_format, info.getFormatName());
		return info;
	} catch (ImageReadException e) {
		throw new IOException(e);
	}
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:23,代码来源:ImageParser.java

示例5: cameraMake

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
/**
    * expects jpg file
    * @param file
    * @return String containing make of camera used to take jpg.
    */
private Map cameraMake(File file){
	TiffField make = null;
	HashMap<String,String> metaDataMap = new HashMap<>();
	try {
		IImageMetadata metadata = Sanselan.getMetadata(file);
		if(metadata != null){
		for(Object x : metadata.getItems()){
			String xString = x.toString();
			String[] arr = xString.split(": ");
			// make, model, time, location, Software
			if(arr[0].contains("Software") || 
					arr[0].toUpperCase().equals("MODEL") ||
					arr[0].toUpperCase().equals("MAKE") ||
					arr[0].toUpperCase().contains("CREATE DATE")){
			metaDataMap.put(arr[0], arr[1]);
			}
		}
		if (metadata instanceof JpegImageMetadata) {
		      make = ((JpegImageMetadata) metadata).findEXIFValue(ExifTagConstants.EXIF_TAG_MAKE);
		      ((JpegImageMetadata) metadata).dump();
		      
		}
		}
		} catch (Exception e) {
			e.printStackTrace();
	
		}
	
	return metaDataMap;
}
 
开发者ID:mcgyver5,项目名称:mngoat,代码行数:36,代码来源:PicturesServlet.java

示例6: displayMetaData

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
private void displayMetaData(File file){
	 try {
		IImageMetadata metadata = Sanselan.getMetadata(file);
		if (metadata instanceof JpegImageMetadata) {
			TiffImageMetadata exif = null;
			TiffOutputSet outputSet = null;
		      TiffField dateTimeValue = ((JpegImageMetadata) metadata).findEXIFValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
		      TiffField model = ((JpegImageMetadata) metadata).findEXIFValue(ExifTagConstants.EXIF_TAG_LOCALIZED_CAMERA_MODEL);
		      TiffField make = ((JpegImageMetadata) metadata).findEXIFValue(ExifTagConstants.EXIF_TAG_MAKE);
		      ((JpegImageMetadata) metadata).dump();
		      if(make != null){
		    	  System.out.println(make);
		      }
		      
		      if(model != null){
		    	  String s = model.getStringValue();
		    	 // System.out.println(s + " SHOULD BE THE MODEL");
		      }
		
		      IImageMetadata metadata2 = Sanselan.getMetadata(file);
		  	JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata2;
		  	if (jpegMetadata != null) {
		  		exif = jpegMetadata.getExif();

		  		if (exif != null) {
		  			outputSet = exif.getOutputSet();
		  			//System.out.println(exif);
		  		}
		  	}
		      
		  } else {
			  System.out.println("Looks like metadata was not instanceof");
		  }
		
	} catch (Exception e) {
		System.out.println("some kind of error about could not get metadata from ");
		e.printStackTrace();
	}
	 
}
 
开发者ID:mcgyver5,项目名称:mngoat,代码行数:41,代码来源:RetrievePicture.java

示例7: getInfo

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
private ImageInfo getInfo() throws IOException {
  if (myInfo == null) {
    try {
      myInfo = Sanselan.getImageInfo(getBytes());
    }
    catch (ImageReadException e) {
      throw new IOException(e);
    }
  }
  return myInfo;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:SanselanImageReaderSpi.java

示例8: getImages

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
private BufferedImage[] getImages() throws IOException {
  if (myImages == null) {
    try {
      final ArrayList<BufferedImage> images = Sanselan.getAllBufferedImages(getBytes());
      myImages = images.toArray(new BufferedImage[images.size()]);
    }
    catch (ImageReadException e) {
      throw new IOException(e);
    }
  }
  return myImages;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:SanselanImageReaderSpi.java

示例9: imageRead

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
/**
 * Read RGB array data from image file
 * @param fileName Image file name
 * @return RGB array data
 * @throws java.io.IOException
 * @throws org.apache.sanselan.ImageReadException
 */
public static Array imageRead(String fileName) throws IOException, ImageReadException{
    String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
    BufferedImage image;
    if (extension.equalsIgnoreCase("jpg") || extension.equalsIgnoreCase("jpeg")){
        image = ImageIO.read(new File(fileName));
    } else {
        image = Sanselan.getBufferedImage(new File(fileName));
    }
    return imageRead(image);
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:18,代码来源:ImageUtil.java

示例10: imageLoad

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
/**
 * Load image from image file
 * @param fileName Image file name
 * @return Image
 * @throws java.io.IOException
 * @throws org.apache.sanselan.ImageReadException
 */
public static BufferedImage imageLoad(String fileName) throws IOException, ImageReadException{
    String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
    BufferedImage image;
    if (extension.equalsIgnoreCase("jpg") || extension.equalsIgnoreCase("jpeg")){
        image = ImageIO.read(new File(fileName));
    } else {
        image = Sanselan.getBufferedImage(new File(fileName));
    }
    return image;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:18,代码来源:ImageUtil.java

示例11: imageSave

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
/**
 * Save image into a file
 * @param data RGB(A) data array
 * @param fileName Output image file name
 * @throws IOException 
 * @throws org.apache.sanselan.ImageWriteException 
 */
public static void imageSave(Array data, String fileName) throws IOException, ImageWriteException{
    String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
    BufferedImage image = createImage(data);  
    ImageFormat format = getImageFormat(extension);
    if (format == ImageFormat.IMAGE_FORMAT_JPEG){
        ImageIO.write(image, extension, new File(fileName));
    } else {
        Sanselan.writeImage(image, new File(fileName), format, null);       
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:18,代码来源:ImageUtil.java

示例12: process

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
@Override
public final Image process(final Image image) throws Exception {

	String imageFileName = imageDirectory + File.separatorChar  + image.getId() + '.' + image.getFormat();
	File file = new File(imageFileName);
	if(!file.exists()) {
		logger.warn("File does not exist in image directory, skipping");
		imageAnnotator.annotate(image, AnnotationType.Error, AnnotationCode.BadData, "The local file was not found, so cannot be resized");
	} else {
		try {
			ImageInfo imageInfo = Sanselan.getImageInfo(file);
			Integer width = new Integer(imageInfo.getWidth());
			Integer height = new Integer(imageInfo.getHeight());
			logger.debug("Image " + imageFileName + " dimensions: " + width + " x " + height);

			if (width > MAX_IMAGE_DIMENSION || height > MAX_IMAGE_DIMENSION) {

				// shrink to no larger than MAX_IMAGE_DIMENSION * MAX_IMAGE_DIMENSION
				MogrifyCmd mogrify = new MogrifyCmd();
				if (searchPath != null) {
					mogrify.setSearchPath(searchPath);
				}
				IMOperation resize = new IMOperation();
				resize.addImage(imageFileName);
				logger.debug("resizing to no larger than " + MAX_IMAGE_DIMENSION.intValue()  + " * " + MAX_IMAGE_DIMENSION.intValue());
				resize.resize(MAX_IMAGE_DIMENSION.intValue(), MAX_IMAGE_DIMENSION.intValue(),'>');
				resize.addImage(imageFileName);
				mogrify.run(resize);

			} else {
				logger.info("No need to resize image as it is smaller than " + MAX_IMAGE_DIMENSION + "px x " + MAX_IMAGE_DIMENSION + "px");
			}
		} catch (Exception e) {
			logger.error("There was an error resizing the image", e);
			imageAnnotator.annotate(image, AnnotationType.Error, AnnotationCode.BadData, "The file could not be resized");
		}
	}
	return image;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:40,代码来源:ImageResizerImpl.java

示例13: process

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
@Override
public Image process(Image image) throws Exception {
	String imageFileName = imageDirectory + File.separatorChar + image.getId() + '.' + image.getFormat();
	File file = new File(imageFileName);
	logger.debug("Image File " + imageFileName);
	if (!file.exists()) {
		logger.error("File {} does not exist in image directory for image ({}), {}, skipping record",
				file.getCanonicalPath(), image.getId(), image);
		imageAnnotator.annotate(image, AnnotationType.Error, AnnotationCode.BadField, "Unable to get embedded metadata as the local file was not found");
		return null;
	}
	boolean metadataFound = false;
	//Search for additional metadata
	Image embeddedMetadata = new Image();
	String xmpXml = Sanselan.getXmpXml(file);
	if (xmpXml != null && !xmpXml.isEmpty()) {
		logger.debug("Attempting to extract metadata from xmp-xml:\n" + xmpXml);
		try {
			XMPMetadata xmp = XMPMetadata.load(new InputSource(new StringReader(xmpXml)));
			for (Class schemaClass : schemas) {
				XMPSchema schema = xmp.getSchemaByClass(schemaClass);
				if (schema instanceof XMPSchemaIptc4xmpCore) {
					XMPSchemaIptc4xmpCore iptcSchema = (XMPSchemaIptc4xmpCore) schema;
					metadataFound = addIptcProperies(iptcSchema,embeddedMetadata) || metadataFound;
					logger.debug("Known schema that will be added:"	+ schema.toString() + "\n"
							+ schema.getElement().getTextContent());
				} else if (schema instanceof XMPSchemaDublinCore) {
					XMPSchemaDublinCore dcSchema = (XMPSchemaDublinCore) schema;
					metadataFound = addDcProperies(dcSchema, embeddedMetadata) || metadataFound;
					logger.debug("Known schema that will be added:"	+ schema.toString() + "\n"
							+ schema.getElement().getTextContent());
				} else if (schema instanceof XMPSchemaRightsManagement) {
					XMPSchemaRightsManagement rightsSchema = (XMPSchemaRightsManagement) schema;
					metadataFound = addRightsProprties(rightsSchema,embeddedMetadata) || metadataFound;
					logger.debug("Known schema that will be added:"	+ schema.toString() + "\n"
							+ schema.getElement().getTextContent());
				} else if (schema instanceof XMPSchemaPhotoshop) {
					XMPSchemaPhotoshop photoshopSchema = (XMPSchemaPhotoshop) schema;
					metadataFound = addPhotoshopProperties(photoshopSchema,	embeddedMetadata, image) || metadataFound;
					logger.debug("Known schema that will be added:"	+ schema.toString() + "\n"
							+ schema.getElement().getTextContent());
				} else {
					logger.info("Unable to process a schema of: " + schemaClass);
				}
			}
		} catch (IOException ioe) {
			logger.error("Exception parsing XMP XML for image (" + image.getId() + ") " + image
					+ " The XML was:\n" + xmpXml, ioe);
			imageAnnotator.annotate(image, AnnotationType.Warn, AnnotationCode.BadField, "There was an issue with the XMP metadata");
		}
	} else {
		logger.debug("Image " + file + " does not contain embedded XMP metadata");
	}

	try {
		IImageMetadata metadata = Sanselan.getMetadata(new File(imageFileName));
		if(metadata != null) {
			logger.debug("The metadata visible to Sanselan is: " +  metadata.toString("*"));
			metadataFound = addSanselanProperties(metadata, embeddedMetadata) || metadataFound;
		} else {
			logger.debug("There is no metadata available from Sanselan");
		}
	} catch (IOException | ImageReadException e) {
		logger.error("Error extracting information with Sanselan for image (" + image.getId() + ") " + image, e);
		imageAnnotator.annotate(image, AnnotationType.Warn, AnnotationCode.BadField, "There was an issue with EXIF metadata");
	}
	//Apply any supplementary metadata
	if(metadataFound && update(image, embeddedMetadata)) {
		validate(image);
		return image;
	} else {
		logger.debug("No metadata was updated, skipping");
		return null;
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:76,代码来源:ImageMetadataExtractorImpl.java

示例14: readImage

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
public BufferedImage readImage(byte[] bytes) throws IOException, ImageReadException {
    colorType = COLOR_TYPE_RGB;
    hasAdobeMarker = false;
    ImageInputStream stream = ImageIO.createImageInputStream(new ByteArrayInputStream(bytes));
    Iterator<ImageReader> iter = ImageIO.getImageReaders(stream);
    while (iter.hasNext()) {
        ImageReader reader = iter.next();
        reader.setInput(stream);

        BufferedImage image;
        ICC_Profile profile = null;
        try {
            image = reader.read(0);
        } catch (IIOException e) {
            colorType = COLOR_TYPE_CMYK;
            checkAdobeMarker(bytes);
            profile = Sanselan.getICCProfile(bytes);
            WritableRaster raster = (WritableRaster) reader.readRaster(0, null);
            if (colorType == COLOR_TYPE_YCCK)
                convertYcckToCmyk(raster);
            if (hasAdobeMarker)
                convertInvertedColors(raster);
            image = convertCmykToRgb(raster, profile);
        }

        return image;
    }

    return null;
}
 
开发者ID:nkiraly,项目名称:Java-FPDF,代码行数:31,代码来源:JpegReader.java

示例15: readImage

import org.apache.sanselan.Sanselan; //导入依赖的package包/类
public static BufferedImage readImage(File file) throws IOException, ImageReadException {
    colorType = COLOR_TYPE_RGB;
    hasAdobeMarker = false;

    ImageInputStream stream = ImageIO.createImageInputStream(file);
    Iterator<ImageReader> iter = ImageIO.getImageReaders(stream);
    while (iter.hasNext()) {
        ImageReader reader = iter.next();
        reader.setInput(stream);

        BufferedImage image;
        ICC_Profile profile = null;
        try {
            image = reader.read(0);
        } catch (IIOException e) {
            colorType = COLOR_TYPE_CMYK;
            checkAdobeMarker(file);
            profile = Sanselan.getICCProfile(file);
            WritableRaster raster = (WritableRaster) reader.readRaster(0, null);
            if (colorType == COLOR_TYPE_YCCK)
                convertYcckToCmyk(raster);
            if (hasAdobeMarker)
                convertInvertedColors(raster);
            image = convertCmykToRgb(raster, profile);
        }

        return image;
    }

    return null;
}
 
开发者ID:lklong,项目名称:imageweb,代码行数:32,代码来源:CmykImageUtil.java


注:本文中的org.apache.sanselan.Sanselan类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。