Welcome!

Adobe Flex Authors: Matthew Lobas, PR.com Newswire, Shelly Palmer, Kevin Benedict

Related Topics: Adobe Flex

Adobe Flex: Article

Optimizing Your JPEG Slices in Fireworks

Optimizing Your JPEG Slices in Fireworks

When you want to make an image available on the Web, there are two important constraints. It needs to look its best and it must download fast. Those two rarely, if ever, go together. Better image quality means a larger file size, which translates to longer download times. Broadband connections help reduce download times but not eveyone is sitting behind a fat pipe that is sucking up the internet.

This month I'll discuss the JPEG format (pronounced "jay-peg"). When I sat down to write this article, a voice in my head kept screaming "this is so "97", and in a way I must admit it is. Then again, why is it that so many folks today still choose wrong image formats? Or don't know how to use selective JPEG compression in Fireworks? Um, selective what? Where? I seriously hope you didn't ask the last question.

The Basics
JPEG is a standardized image compression mechanism designed to compress full-color or grayscale images of natural, real-world scenes. The JPEG file structure splits the data into two parts - monochrome and color information - and applies different compressions to each of them. The monochrome portion defines the objects in a picture — it provides detail and brightness. The human eye is more sensitive to small brightness variations than it is to color variations. So discarding color information is less noticeable to the human eye than discarding monochrome information. JPEG exploits this fact. It compresses color information more than its monochromatic counterpart, and as a result it produces smaller file sizes without sacrificing their viewing quality —at least the way the human eye understands it. For the same reason, JPEG does a poor job when blocks of solid color are present, resulting in visible artifacts.

JPEG is "lossy," meaning when you use it to compress an image, information is lost permanently. The resulting image is not the same as the image you start with. If you keep editing that JPEG and export it back as a JPEG as you make edits to it, image degradation will be obvious before too long.

The Joint Photographic Experts Group was the committee that wrote the standard, and this is how this acronym came about.

Compression Levels
You control the data you lose as you compress an image by altering its compression level. Higher compression levels result in smaller images with less image quality. You can trade off file size for image quality.

The compression levels are not standard in all the imaging applications that use JPEG. Some use a rating of 1-10, others 0-100. Some use this rating to refer to image quality while others use it to refer to compression level. Fireworks uses a rating for image quality between 0 and 100. Zero means minimum quality (maximum compression) and 100 means maximum quality (minimum compression). But don't let the scale trick you. Setting image quality to 80, for example, doesn't mean you will get 80% of the quality of the original image. It simply means that if 100 is the maximum quality then 80 is 20 clicks lower.

A common question is, "how much compression should I use?" There aren't any magic numbers. Experiment by adjusting the values until you get a result that has enough image quality and a satisfactory file size for your application. Fireworks defines two presets: JPEG - Better Quality and JPEG - Smaller Size that you can use as your starting point. Often they may be just right. However, you should experiment and compare results if you want to squeeze the most out of your JPEGs.

Optimize Panel
The Optimize panel (Window > Optimize) gives you access to various settings for each slice. With a JPEG slice selected, your Optimize panel will look similar to the one shown in Image I.

 

As I mentioned earlier, Fireworks uses a 0-100 rating for the JPEG image quality. You can adjust this value using Quality on the panel.

Selective quality is available when a JPEG mask is present. In a nutshell, it allows you to apply two different compression settings. You can, for example, have low compression (high quality) in areas of the image that are important, and high compression (low quality) in areas of lower importance. We will discuss this in detail later.

I've talked about how JPEG compresses the color information of an image more aggressively than its monochrome information. This way we get smaller files and the data lost is not visible as much, if at all. Of course this means that you can compress an image with little detail more and quality loss will not be obvious.

Smoothing specifies a threshold value for blurring the edges of the image. By reducing the details of the image, it becomes more compressible. A value of zero will not make any changes to the edges of the image. A value of eight (maximum value) will reduce details in the image heavily and the resulting JPEG will achieve a higher compression level, resulting in smaller file size.

I try to avoid resorting to smoothing to reduce file size since the images produced are "soft." There are cases, however, when the trade-off is acceptable and smoothing by 1 or 2 does not have a large impact and I can squeeze a couple of Ks out of it. It's all about trial and error.

Another option for a JPEG slice is sharpening the edges. This increases the details of the JPEG by sharpening it, which based on what we already know results in an image that appears to have more detail since our eye is more sensitive to brightness changes. At the same time, since the edges of the image are more pronounced, the image can't be compressed as much and maintain acceptable quality. You can locate this setting under the options menu of the Optimize panel (see Image II).

 

I suggest toggling that option on and off while in Preview so you can see how much it affects the quality of the image and the file size.

Progressive JPEG
Another choice for your JPEG slices in Fireworks is Progressive JPEG. A simple JPEG is stored as one top-to-bottom scan of the file. The decoder (that is, the browser when viewing the image on the Web) performs a single scan of the image and displays it. Progressive JPEG divides the file into a series of scans. The first scan shows the image at a low quality (heavily compressed) that has small file size and can show up quickly. Each scan that follows adds to the quality of the image. A Progressive JPEG is slightly larger in file size compared to a simple JPEG, but loading over a network seems faster.

You can set a JPEG slice as a Progressive JPEG in Fireworks using the options menu of the Optimize panel (see Image II).

Selective JPEG Compression
When you define a JPEG slice some areas may be more important than others. One such example is a portrait photograph where the background is out of focus. In a case like this you want to keep your subject's quality high; the rest, which is not as important, can be compressed more.

Although it is not the best approach to include text in a JPEG (remember our discussion about edges) sometimes you just have to. You can apply low compression around the text and a higher compression to the rest of the image. This way you can keep your text crisp, and achieve a small file size.

The technique of applying different compression levels in different areas of an image is called Selective JPEG Compression. Fireworks makes it easy to use selective compression.

Let's say I have this photo and I must include a label on it. I can compress it a lot and still get acceptable results, but the text looks horrible (see Image III).

 

Selective JPEG compression to the rescue! With the JPEG slice, select Selective JPEG compression and bring up the Optimize panel. The Selective quality field is disabled. Click on the edit button next to it and the Selective JPEG Settings dialog comes up (see Image IV).

 

Check Enable selective quality and Preserve text quality. By doing so, any text block in the selected slice will have different compression levels. In my example I have a JPEG for which I can use quality 40 and selective quality 90. You can see how much difference it makes to the clarity of text in Image III.

Let's look at an example where we can define the area to apply selective quality manually. I'll start with the photo on the left in Image V.

 

In this case I want to keep as much quality as I can on the subject but I don't care about the quality of the foliage in the background. My first step is to create a selection of the area I am interested in. In this case I created a selection of the background (middle photo, Image V) and using Select > Select Invert I got the subject selected. With the selection active, choose Modify > Selective JPEG > Save Selection as JPEG Mask. In the last photo of Image V, the area with the red overlay is the JPEG Mask I've created.

Now I can create a JPEG slice for that photo and set its Quality low while the Selective quality is at a higher value. This way I compress the background more than the subject, dropping data from the less important areas of the photo.

Again, there are no magic numbers. Experiment with the values and find the ones that produce the best results for your test or the file size requirements you may have.

Under Selective JPEG, you'ill find other options that become available after you enable it. Use Restore JPEG Mask as Selection to restore your selection and manipulate it further. Then save this new selection again as the JPEG Mask you want to use. Of course, if you change your mind and want to start fresh, you use Remove JPEG Mask.

More Stories By Kleanthis Economou

Kleanthis Economou has been a Web developer/software engineer since 1995 and specializes in .NET Framework solutions. He is a contributing author of various Fireworks publications and is the technical editor of the Fireworks MX Bible. As an extension developer, Kleanthis contributed two extensions to the latest release of Fireworks.

Comments (0)

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.


IoT & Smart Cities Stories
The challenges of aggregating data from consumer-oriented devices, such as wearable technologies and smart thermostats, are fairly well-understood. However, there are a new set of challenges for IoT devices that generate megabytes or gigabytes of data per second. Certainly, the infrastructure will have to change, as those volumes of data will likely overwhelm the available bandwidth for aggregating the data into a central repository. Ochandarena discusses a whole new way to think about your next...
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
DXWorldEXPO LLC announced today that Big Data Federation to Exhibit at the 22nd International CloudEXPO, colocated with DevOpsSUMMIT and DXWorldEXPO, November 12-13, 2018 in New York City. Big Data Federation, Inc. develops and applies artificial intelligence to predict financial and economic events that matter. The company uncovers patterns and precise drivers of performance and outcomes with the aid of machine-learning algorithms, big data, and fundamental analysis. Their products are deployed...
All in Mobile is a place where we continually maximize their impact by fostering understanding, empathy, insights, creativity and joy. They believe that a truly useful and desirable mobile app doesn't need the brightest idea or the most advanced technology. A great product begins with understanding people. It's easy to think that customers will love your app, but can you justify it? They make sure your final app is something that users truly want and need. The only way to do this is by ...
CloudEXPO | DevOpsSUMMIT | DXWorldEXPO 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.
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 ...
Cell networks have the advantage of long-range communications, reaching an estimated 90% of the world. But cell networks such as 2G, 3G and LTE consume lots of power and were designed for connecting people. They are not optimized for low- or battery-powered devices or for IoT applications with infrequently transmitted data. Cell IoT modules that support narrow-band IoT and 4G cell networks will enable cell connectivity, device management, and app enablement for low-power wide-area network IoT. B...
The hierarchical architecture that distributes "compute" within the network specially at the edge can enable new services by harnessing emerging technologies. But Edge-Compute comes at increased cost that needs to be managed and potentially augmented by creative architecture solutions as there will always a catching-up with the capacity demands. Processing power in smartphones has enhanced YoY and there is increasingly spare compute capacity that can be potentially pooled. Uber has successfully ...
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...