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
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
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...
Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
Whenever a new technology hits the high points of hype, everyone starts talking about it like it will solve all their business problems. Blockchain is one of those technologies. According to Gartner's latest report on the hype cycle of emerging technologies, blockchain has just passed the peak of their hype cycle curve. If you read the news articles about it, one would think it has taken over the technology world. No disruptive technology is without its challenges and potential impediments t...
If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...
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...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...