Java图像处理库 Sanselan

码农软件 · 软件分类 · 图形/图像处理 · 2019-09-10 12:26:39

软件介绍

Sanselan 是一个纯 Java 的图形库,可以读写各种格式的图像文件,包括快速解析图片信息例如大小/颜色/icc以及元数据等。尽管因为是Java开发的,在处理速度上会稍微慢一 些,但具备良好的可移植性。虽然尚未发布1.0 版本,但是已经有多个项目在使用 Sanselan 来处理图像文件。

该项目目前还是 Apache 组织的一个孵化项目。

JavaDoc: http://www.apache.org/dist/incubator/sanselan/javadoc/

示例代码:

File file = someFile;
BufferedImage image_3 = Sanselan.getBufferedImage(file);
InputStream is = someInputStream;
BufferedImage image_4 = Sanselan.getBufferedImage(is);

// Write an image.
BufferedImage image = someImage;
File dst = someFile;
ImageFormat format = ImageFormat.IMAGE_FORMAT_PNG;
Map optional_params = new Hashtable();
Sanselan.writeImage(image, dst, format, optional_params);

OutputStream os = someOutputStream;
Sanselan.writeImage(image, os, format, optional_params);

// get the image's embedded ICC Profile, if it has one.
byte icc_profile_bytes[] = Sanselan.getICCProfileBytes(imageBytes);

ICC_Profile icc_profile = Sanselan.getICCProfile(imageBytes);

// get the image's width and height.
Dimension d = Sanselan.getImageSize(imageBytes);

// get all of the image's info (ie. bits per pixel, size, transparency, etc.)
ImageInfo image_info = Sanselan.getImageInfo(imageBytes);

if (image_info.getColorType() == ImageInfo.COLOR_TYPE_GRAYSCALE)
System.out.println("Grayscale image.");
if (image_info.getHeight() > 1000)
System.out.println("Large image.");

// try to guess the image's format.
ImageFormat image_format = Sanselan.guessFormat(imageBytes);
image_format.equals(ImageFormat.IMAGE_FORMAT_PNG);

// get all metadata stored in EXIF format (ie. from JPEG or TIFF).
// org.w3c.dom.Node node = Sanselan.getMetadataObsolete(imageBytes);
IImageMetadata metdata = Sanselan.getMetadata(imageBytes);

// print a dump of information about an image to stdout.
Sanselan.dumpImageFile(imageBytes);

// get a summary of format errors.
FormatCompliance format_compliance = Sanselan
.getFormatCompliance(imageBytes);

本文地址:https://www.codercto.com/soft/d/14286.html

Wikis For Dummies

Wikis For Dummies

Dan Woods、Peter Thoeny / For Dummies / 2007-7-23 / USD 24.99

Corporations have finally realized the value of collaboration tools for knowledge sharing and Wiki is the open source technology for creating collaborative Web sites, as either a public site on the In......一起来看看 《Wikis For Dummies》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

SHA 加密
SHA 加密

SHA 加密工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具