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

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.

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:
Portable Network Graphics Format (PNG)
Adobe Photoshop (PSD)
Targa (TGA)
Windows Bitmap (BMP)
OS/2 Bitmap (BMP)
Macintosh PICT (PCT)
Tag Image File Format (TIFF)
X Bitmap (XBM)
X Pixmap (XPM)
Sun Rasterfile (RAS)

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)
Edge detection
Oil painting
Gamma adjustment

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.

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
DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
DXWorldEXPO LLC announced today that "Miami Blockchain Event by FinTechEXPO" has announced that its Call for Papers is now open. The two-day event will present 20 top Blockchain experts. All speaking inquiries which covers the following information can be submitted by email to [email protected] Financial enterprises in New York City, London, Singapore, and other world financial capitals are embracing a new generation of smart, automated FinTech that eliminates many cumbersome, slow, and expe...
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City. Digital Transformation (DX) is a major focus with the introduction of DXWorldEXPO 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 over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of bus...
With 10 simultaneous tracks, keynotes, general sessions and targeted breakout classes, @CloudEXPO and DXWorldEXPO are two of the most important technology events of the year. Since its launch over eight years ago, @CloudEXPO and DXWorldEXPO have presented a rock star faculty as well as showcased hundreds of sponsors and exhibitors! In this blog post, we provide 7 tips on how, as part of our world-class faculty, you can deliver one of the most popular sessions at our events. But before reading...
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...
As IoT continues to increase momentum, so does the associated risk. Secure Device Lifecycle Management (DLM) is ranked as one of the most important technology areas of IoT. Driving this trend is the realization that secure support for IoT devices provides companies the ability to deliver high-quality, reliable, secure offerings faster, create new revenue streams, and reduce support costs, all while building a competitive advantage in their markets. In this session, we will use customer use cases...
DXWorldEXPO LLC announced today that ICOHOLDER named "Media Sponsor" of Miami Blockchain Event by FinTechEXPO. ICOHOLDER give you detailed information and help the community to invest in the trusty projects. Miami Blockchain Event by FinTechEXPO has opened its Call for Papers. The two-day event will present 20 top Blockchain experts. All speaking inquiries which covers the following information can be submitted by email to [email protected] Miami Blockchain Event by FinTechEXPO also offers s...
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...
Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
Digital Transformation and Disruption, Amazon Style - What You Can Learn. Chris Kocher is a co-founder of Grey Heron, a management and strategic marketing consulting firm. He has 25+ years in both strategic and hands-on operating experience helping executives and investors build revenues and shareholder value. He has consulted with over 130 companies on innovating with new business models, product strategies and monetization. Chris has held management positions at HP and Symantec in addition to ...
Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities - ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups.
Internet-of-Things discussions can end up either going down the consumer gadget rabbit hole or focused on the sort of data logging that industrial manufacturers have been doing forever. However, in fact, companies today are already using IoT data both to optimize their operational technology and to improve the experience of customer interactions in novel ways. In his session at @ThingsExpo, Gordon Haff, Red Hat Technology Evangelist, shared examples from a wide range of industries – including en...
The standardization of container runtimes and images has sparked the creation of an almost overwhelming number of new open source projects that build on and otherwise work with these specifications. Of course, there's Kubernetes, which orchestrates and manages collections of containers. It was one of the first and best-known examples of projects that make containers truly useful for production use. However, more recently, the container ecosystem has truly exploded. A service mesh like Istio addr...
Rodrigo Coutinho is part of OutSystems' founders' team and currently the Head of Product Design. He provides a cross-functional role where he supports Product Management in defining the positioning and direction of the Agile Platform, while at the same time promoting model-based development and new techniques to deliver applications in the cloud.
Predicting the future has never been more challenging - not because of the lack of data but because of the flood of ungoverned and risk laden information. Microsoft states that 2.5 exabytes of data are created every day. Expectations and reliance on data are being pushed to the limits, as demands around hybrid options continue to grow.
Business professionals no longer wonder if they'll migrate to the cloud; it's now a matter of when. The cloud environment has proved to be a major force in transitioning to an agile business model that enables quick decisions and fast implementation that solidify customer relationships. And when the cloud is combined with the power of cognitive computing, it drives innovation and transformation that achieves astounding competitive advantage.
Poor data quality and analytics drive down business value. In fact, Gartner estimated that the average financial impact of poor data quality on organizations is $9.7 million per year. But bad data is much more than a cost center. By eroding trust in information, analytics and the business decisions based on these, it is a serious impediment to digital transformation.