Welcome!

Java IoT Authors: Pat Romanski, Roger Strukhoff, Liz McMillan, Yeshim Deniz, Elizabeth White

Related Topics: Java IoT

Java IoT: Article

The Java Image Management Interface

The Java Image Management Interface

If a picture is worth a thousand words, what words do you use when the picture is in the wrong format? Not exactly a Zen koan, but a valid question whose answer is JIMI, the Java Image Management Interface from Activated Intelligence.

JIMI is a toolkit for reading, writing, viewing and manipulating images in multiple-graphics file formats. JIMI supports an impressive number of image formats, but if your target format is not supported, JIMI's open design allows you to add your format while taking advantage of key JIMI features. As you'd hope and expect, JIMI is platform-neutral 100% Pure Java that works with Java l.0.x and 1.1.x, and with the current beta versions of Java 1.2.

This article will let you know if JIMI has the features that will lighten your load and tighten your code. The "Overview" section examines JIMI's major features and identifies how JIMI can fit into your project. The "Down to Business" section focuses on technical topics and code samples.

Overview
When you finish this overview, you'll understand JIMI's key features and be able to identify how JIMI can provide a strategic advantage to your projects and products.

JIMI Encodes and Decodes Images
Life gets pretty frustrating when you run into communication barriers. The unruly universe of the World Wide Web, with its varied platforms, browsers, languages and users, can make a programmer cry out for simplicity. Java simplifies programming across varied platforms and environments. JIMI delivers stunning simplicity to the Java programmer who needs to work with the following formats:
GIF
JPEG
Portable Network Graphics Format (PNG)
Adobe Photoshop (PSD)
Targa (TGA)
Windows Bitmap (BMP)
OS/2 Bitmap (BMP)
ICO and CUR
Macintosh PICT (PCT)
Tag Image File Format (TIFF)
X Bitmap (XBM)
X Pixmap (XPM)
Sun Rasterfile (RAS)
PCX

The following code snippet reads a Photoshop file and writes it back to disk as a PNG file. It couldn't be easier!

Image image = Jimi.getImage("myImage.PSD");
Jimi.putImage(image, "myImage.PNG");

See Listing 1 for a complete and equally simple application version of this code.

Activated Intelligence's customers are using JIMI's simple encode/decode features to add serious power to their applications. Put JIMI in your applets and applications to easily browse and view most of the images that come your way. Place JIMI in your File Upload Servlet and rest assured that it'll accept a wide range of image files for conversion to popular viewing formats. Expect the number of supported formats to grow with each release.

Image Manipulation with JIMI
You should now be confident that you can read, write and view most image formats. JIMI helps you manipulate these images simply and uniformly. Going far beyond the AWT, JIMI gives you power over your images with pixel-level access. With this feature you can write new and standard image manipulation routines. Activated packed JIMI with a few favorites, such as:
Scaling (does thumbnails)
Cropping
Color-reduction
Smoothing
Flipping
Edge detection
Embossing
Tiling
Oil painting
Blur
Gamma adjustment
Smoothing

If you choose to write a custom routine using the JIMI pixel access interface, it'll work on all the supported formats.

What Makes JIMI Special?
If reading, writing, viewing and manipulating multiple image formats across multiple platforms isn't enough for you, JIMI has more. It's the foundation for imaging within the Java environment. What makes Activated so confident in JIMI? JIMI knows Java! JIMI protects the Java programmer from some vexing conditions in the Java environment. JIMI is ready to work with the Java community and harness its power. Following are four of JIMI's special attributes:
1. Big images, little JVM: How much memory will your Java application have at runtime? You may not know. JIMI has a fast, powerful and unique virtual memory management (VMM) system that lets you do more in your little JVM than you ever imagined. Using JIMI, a developer can load a 10000x10000 image in a JVM that is allocated only the standard 16 mb of heap space. JIMI uses memory only for the parts in use at that moment. How? JIMI leverages its fine-grained control over image access to implement a highly efficient virtual memory system tailored to the needs of large images. But the developer doesn't need to know the details to use the VMM. JIMI simply has the information you need buffered for fast access.
2. Can I use JIMI on the server? Yes. JIMI can work independently of the AWT. Use JIMI in servlets, Enterprise Java-Beans or any other AWT-less server-based environment. When you have lots of image translation or manipulation to do, JIMI lets you move the processing from the client to the server.
3. JIMI is extensible! Adding a new image format? No problem. JIMI's capabilities are dynamically extensible, allowing you to add new image formats. Each new format can seamlessly take advantage of all JIMI's core features.
Because we designed JIMI to be easily and openly extended, Activated Intelligence is on the lookout for new image manipulation routines and image encoders/decoders.

Developers can contact Activated Intelligence at www.activated.com to make arrangements for review and possible equitable use of their JIMI-based code.
4. Flexible footprint: With Activated Intelligence and independent developers adding new features and formats to the JIMI system, JIMI is growing! But what if you want to use it where memory is a constraint or the code needs to be moved over a slow network? JIMI is a modular system that allows the formats and features to "Plug and Play."

Down to Business: Programming with JIMI
Now that you know what JIMI can do for you, the rest of this article will show you how to become a JIMI developer. When you finish reading, you should know how to program with JIMI.

JIMI is made up of several tightly integrated components that provide a powerful set of features in a modular and extensible architecture. Figure 1 illustrates JIMI's internals.

The JIMI core provides the central functionality to support all other components. These classes handle the transparent AWT Image import/export, seamless VMM and other advanced imaging features. With a high-level understanding of the JIMI core, the developer can concentrate on the project.

The JIMI Image Read/Write Interface
The most fundamental use for JIMI is loading and saving images. JIMI's Image Read/Write Interface includes an intuitive front end with familiar and easy-to-use methods for image load-and-save operations. See how the "Jimi" class provides intuitive one-call methods for loading and saving images:
public static Image getImage(String filename);

public static Image putImage(Image image, String filename)
throws JimiException

Developers that have loaded images using the core Java API will be familiar with the getImage method. Jimi.getImage also provides asynchronous image loading, but with JIMI's added full range of format support, on-demand VMM and animated image support. Other convenient variations of getImage are provided, including a similar getImageProducer method used to apply filters or for use in an AWT-less environment. With these variations there's always a single method you can use to load an image to suit your needs.

Not surprisingly, the putImage methods are equally easy. Give JIMI the image (or ImageProducer), tell it where to save it and JIMI does the rest. Again, putImage has all the common variations to ensure that saving your image with JIMI is a one-call operation. Images saved will also automatically inherit any properties they were loaded with, such as compression scheme and interlacing options, even if you're saving to a different format.

With these methods in your toolbox you have everything you need to quickly add basic load/save support for a diverse range of formats to your programs. JIMI takes things a step further by also enabling you to dissect and reassemble image files containing several frames of image data, such as animated GIFs. This is achieved with two new interfaces: JimiReader and JimiWriter. For more on working with multi-image files, see Listing 2.

See how easily JIMI's features enhance your programs? To get the JIMI advantage, just change the one getImage line in your code. Add one call to JIMI's "putImage" and the job is done.

The Image Manipulation Interface
Now you can easily load and save images, but how about modifying them? For this, JIMI has full compatibility with the AWT's ImageFilter model of image manipulation as well as compatibility with new JDK features like Java 2D. A common image-processing operation is applying an ImageFilter.

With JIMI you can easily load an image, apply a filter and then save the image again. This code will crop a 100x100 region of an image and then save it:

ImageProducer p1=Jimi.getImageProducer("i.gif");
ImageFilter f=new CropImageFilter(0,0,100,100);
ImageProducer p2=new FilteredImageSource(f, p1);
Jimi.putImage(p2, "i.gif");

JIMI also provides more sophisticated image manipulation tools. Without JIMI, a developer who wants to access specific pieces of image data needs to use a PixelGrabber to get an image into an array of pixel data and then create a MemoryImageSource to build the modified image. This is expensive in both time and memory. JIMI provides random access to pixel data in its images. You have the power associated with an in-memory buffer and the flexibility that comes with all of JIMI's interfaces. Access your image in comfortable chunks and still benefit from JIMI's VMM capabilities.

Two additional key interfaces are JimiRasterImage and JimiBufferedRasterImage. The former provides a uniform interface to images created by JIMI regardless of their ColorModel type and form of primitive storage, letting you access their pixel data as RGB color values. The methods for this access are:


public void getRectangleRGB(int x, int y,
int w, int h, int[] buffer,
int offset, int scansize)

public void getRowRGB(int y, int[] buffer,
int offset)

public int getPixelRGB(int x, int y)

JimiBufferedRasterImage extends this set of methods to include symmetrical "setters" for changing pixel data. The Jimi class provides a one-call method for accessing these objects. Just replace "getImage" with "getRasterImage." JIMI also provides buffered access to these images with "getBufferedRasterImage" and the JimiBufferedRasterImage object. For more detail see Listing 3.

The Encoder/Decoder Interface
Now you can load, view, save and manipulate images for all JIMI's image formats, but what if your pet format isn't supported? Using JIMI's extension API you can add a new format module, leveraging all of JIMI's features and much of the work done for you. Implementing an encoder or decoder with JIMI gives you free image production, VMM support and seamless integration with the rest of JIMI.

Although greatly simplified, implementing format modules still deserves a more thorough guide than can be given in this article. Interested developers should take a look at www.activated.com/jimi/addformat/ for a step-by-step guide.

Conclusion
Now you know: JIMI's simple elegance lets you read, write, view and manipulate most images across multiple platforms in varied Java environments. You know when and where JIMI can help bring your product to release faster and with more features. You also know enough to get started writing powerful and effective imaging code using the JIMI toolkit. So go ahead, visit us at www.activated.com, download JIMI and "get the picture."

More Stories By Michael A. Sick

Michael Sick is the Founder and President of Serene Software, a Jacksonville, Florida firm specializing in Enterprise Architecture (EA) via IT Strategy, IT Governance, IT Budgeting, Service Oriented Architectures (SOA), and IT Legacy Planning services. With over 15 years of experience, he has served as VP Development, Enterprise Architect and Lead Software Architect, while providing expertise to organizations like BAE, Sun Microsystems, Badcock Furniture, Raytheon (Future Combat Systems), the United States Air Force, USDA, BearingPoint, and other firms. Areas of interest include: SOA, IT budget optimization and planning, cloud and distributed computing, and process optimization.

More Stories By Luke Gorrie

Luke Gorrie is a Java programmer and the lead developer of JIMI at Activated Intelligence.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
doncare 02/28/08 01:35:56 AM EST

ImageProducer p3 = new FilteredImageSource(f,p1);

this line has mistake, first its the image and then the filter:

ImageProducer p3 = new FilteredImageSource(p1,f);

im not java expert and take me several hours find the mistake, i change the IDE, download the jdk again an 1000 things, check that and thats all

@ThingsExpo Stories
SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...
Digital Transformation (DX) is not a "one-size-fits all" strategy. Each organization needs to develop its own unique, long-term DX plan. It must do so by realizing that we now live in a data-driven age, and that technologies such as Cloud Computing, Big Data, the IoT, Cognitive Computing, and Blockchain are only tools. In her general session at 21st Cloud Expo, Rebecca Wanta explained how the strategy must focus on DX and include a commitment from top management to create great IT jobs, monitor ...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
Recently, WebRTC has a lot of eyes from market. The use cases of WebRTC are expanding - video chat, online education, online health care etc. Not only for human-to-human communication, but also IoT use cases such as machine to human use cases can be seen recently. One of the typical use-case is remote camera monitoring. With WebRTC, people can have interoperability and flexibility for deploying monitoring service. However, the benefit of WebRTC for IoT is not only its convenience and interopera...
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
Product connectivity goes hand and hand these days with increased use of personal data. New IoT devices are becoming more personalized than ever before. In his session at 22nd Cloud Expo | DXWorld Expo, Nicolas Fierro, CEO of MIMIR Blockchain Solutions, will discuss how in order to protect your data and privacy, IoT applications need to embrace Blockchain technology for a new level of product security never before seen - or needed.
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Digital transformation - what we knew about it in the past has been redefined. Automation is going to play such a huge role in that because the culture, the technology, and the business operations are being shifted now," stated Brian Boeggeman, VP of Alliances & Partnerships at Ayehu, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...