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


Java Imaging.getImageInfo方法代码示例

本文整理汇总了Java中org.apache.commons.imaging.Imaging.getImageInfo方法的典型用法代码示例。如果您正苦于以下问题:Java Imaging.getImageInfo方法的具体用法?Java Imaging.getImageInfo怎么用?Java Imaging.getImageInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.imaging.Imaging的用法示例。


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

示例1: processImage

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private byte[] processImage(byte[] imageBytes, List<Rectangle> areasToBeCleaned) {
    if (areasToBeCleaned.isEmpty()) {
        return imageBytes;
    }

    try {
        BufferedImage image = Imaging.getBufferedImage(imageBytes);
        ImageInfo imageInfo = Imaging.getImageInfo(imageBytes);
        cleanImage(image, areasToBeCleaned);

        // Apache can only read JPEG, so we should use awt for writing in this format
        if (imageInfo.getFormat() == ImageFormats.JPEG) {
            return getJPGBytes(image);
        } else {
            Map<String, Object> params = new HashMap<String, Object>();

            if (imageInfo.getFormat() == ImageFormats.TIFF) {
                params.put(ImagingConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_LZW);
            }

            return Imaging.writeImageToBytes(image, imageInfo.getFormat(), params);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:27,代码来源:PdfCleanUpRenderListener.java

示例2: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("start");

    final List<File> images = getXbmImages();
    for (final File imageFile : images) {

        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)

        final Map<String, Object> params = new HashMap<>();
        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:21,代码来源:XbmReadTest.java

示例3: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final Map<String, Object> params = new HashMap<>();
    final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
    params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));

    final ImageMetadata metadata = Imaging.getMetadata(imageFile, params);
    // TODO only run this tests with images that have metadata...
    //assertNotNull(metadata);
    Debug.debug("metadata", metadata);
    
    Debug.debug("ICC profile", Imaging.getICCProfile(imageFile, params));

    final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
    assertNotNull(imageInfo);
    
    try {
        final BufferedImage image = Imaging.getBufferedImage(imageFile, params);
        assertNotNull(image);
    } catch (final ImageReadException imageReadException) {
        assertEquals("Only sequential, baseline JPEGs are supported at the moment",
                imageReadException.getMessage());
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:25,代码来源:JpegReadTest.java

示例4: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("start");

    final List<File> images = getWbmpImages();
    for (final File imageFile : images) {

        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)

        final Map<String, Object> params = new HashMap<>();
        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:21,代码来源:WbmpReadTest.java

示例5: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("start");

    final List<File> images = getPsdImages();
    for (final File imageFile : images) {

        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)

        final Map<String, Object> params = new HashMap<>();
        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
        assertNotNull(imageInfo);

        Imaging.getICCProfile(imageFile, params);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:23,代码来源:PsdReadTest.java

示例6: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws IOException, ImageReadException {
    Debug.debug("start");

    final List<File> images = getRgbeImages();

    for (final File imageFile : images) {

        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        assertNotNull(metadata);

        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:21,代码来源:RgbeReadTest.java

示例7: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("start");

    final List<File> images = getPcxImages();
    for (int i = 0; i < images.size(); i++) {

        final File imageFile = images.get(i);
        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)

        final Map<String, Object> params = new HashMap<>();
        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:22,代码来源:PcxReadTest.java

示例8: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("start");

    final List<File> images = getPamImages();
    for (int i = 0; i < images.size(); i++) {

        final File imageFile = images.get(i);
        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)

        final Map<String, Object> params = new HashMap<>();
        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:22,代码来源:PamReadTest.java

示例9: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final List<File> images = getTiffImages();
    for (final File imageFile : images) {

        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        assertNotNull(metadata);

        Debug.debug("ICC profile", Imaging.getICCProfile(imageFile));

        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:20,代码来源:TiffReadTest.java

示例10: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("start");

    final List<File> images = getXpmImages();
    for (final File imageFile : images) {

        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        Assert.assertFalse(metadata instanceof File); // Dummy check to avoid unused warning (it may be null)

        final Map<String, Object> params = new HashMap<>();
        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:21,代码来源:XpmReadTest.java

示例11: testImageInfo

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void testImageInfo() throws ImageReadException, IOException {
    final Map<String, Object> params = Collections.emptyMap();
    final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
    assertNotNull(imageInfo);
    // TODO assert more
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:8,代码来源:BmpReadTest.java

示例12: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final List<File> images = getTiffImages();
    for (final File imageFile : images) {

        Debug.debug("imageFile", imageFile);

        final ImageMetadata metadata = Imaging.getMetadata(imageFile);
        assertNotNull(metadata);

        final ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
        assertNotNull(imageInfo);

        final BufferedImage image = Imaging.getBufferedImage(imageFile);
        assertNotNull(image);

        final int[] compressions = new int[]{
                TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED,
                TiffConstants.TIFF_COMPRESSION_LZW,
                TiffConstants.TIFF_COMPRESSION_PACKBITS
        };
        for (final int compression : compressions) {
            final File tempFile = createTempFile(imageFile.getName() + "-" + compression + ".", ".tif");
            final Map<String, Object> params = new HashMap<>();
            params.put(ImagingConstants.PARAM_KEY_COMPRESSION, compression);
            Imaging.writeImage(image, tempFile, ImageFormats.TIFF,
                    params);
            final BufferedImage image2 = Imaging.getBufferedImage(tempFile);
            assertNotNull(image2);
        }
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:33,代码来源:TiffRoundtripTest.java

示例13: testPhysicalScaleMeters

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void testPhysicalScaleMeters() throws Exception {
    final Map<String, Object> optionalParams = new HashMap<>();
    optionalParams.put(PngConstants.PARAM_KEY_PHYSICAL_SCALE, PhysicalScale.createFromMeters(0.01, 0.02));

    final int[][] smallAscendingPixels = getAscendingRawData(256, 256);
    final byte[] pngBytes = Imaging.writeImageToBytes(
          imageDataToBufferedImage(smallAscendingPixels),
          ImageFormats.PNG, optionalParams);
    final PngImageInfo imageInfo = (PngImageInfo) Imaging.getImageInfo(pngBytes);
    final PhysicalScale physicalScale = imageInfo.getPhysicalScale();
    assertTrue("Invalid units", physicalScale.isInMeters());
    assertEquals("Invalid horizontal units", 0.01, physicalScale.getHorizontalUnitsPerPixel(), 0.001);
    assertEquals("Invalid vertical units", 0.02, physicalScale.getVerticalUnitsPerPixel(), 0.001);
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:16,代码来源:PngWriteReadTest.java

示例14: testPhysicalScaleRadians

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void testPhysicalScaleRadians() throws Exception {
    final Map<String, Object> optionalParams = new HashMap<>();
    optionalParams.put(PngConstants.PARAM_KEY_PHYSICAL_SCALE, PhysicalScale.createFromRadians(0.01, 0.02));

    final int[][] smallAscendingPixels = getAscendingRawData(256, 256);
    final byte[] pngBytes = Imaging.writeImageToBytes(
          imageDataToBufferedImage(smallAscendingPixels),
          ImageFormats.PNG, optionalParams);
    final PngImageInfo imageInfo = (PngImageInfo) Imaging.getImageInfo(pngBytes);
    final PhysicalScale physicalScale = imageInfo.getPhysicalScale();
    assertTrue("Invalid units", physicalScale.isInRadians());
    assertEquals("Invalid horizontal units", 0.01, physicalScale.getHorizontalUnitsPerPixel(), 0.001);
    assertEquals("Invalid vertical units", 0.02, physicalScale.getVerticalUnitsPerPixel(), 0.001);
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:16,代码来源:PngWriteReadTest.java

示例15: testNullParametersRoundtrip

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Theory
public void testNullParametersRoundtrip(final FormatInfo formatInfo) throws Exception {
    final BufferedImage testImage = TestImages.createFullColorImage(1, 1);
    final File temp1 = createTempFile("nullParameters.", "." + formatInfo.format.getExtension());
    Imaging.writeImage(testImage, temp1, formatInfo.format, null);
    Imaging.getImageInfo(temp1, null);
    Imaging.getImageSize(temp1, null);
    Imaging.getMetadata(temp1, null);
    Imaging.getICCProfile(temp1, null);
    final BufferedImage imageRead = Imaging.getBufferedImage(temp1, null);

    assertNotNull(imageRead);
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:14,代码来源:NullParametersRoundtripTest.java


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