Help:Contents/JPEGs

The Cutting Room Floor's Image Guidelines state quite firmly, as rule number one, "No JPEGs." They go on to explain that there are exceptions to this rule, which is the purpose of this page. Here, we'll attempt to answer how to deal with your unruly JPEGs!

Why No JPEGs?
JPEG is named after its creators, the Joint Photographic Experts Group. From the name, you may be able to guess that JPEG is mainly meant for photographs. The goal of JPEG is to throw away a lot of information from a photo, so that the file is much smaller, easier to store and share. Hopefully, the compression will not be obvious when looking from a normal distance, but the image does have less details than it did before being saved as a JPEG.

This very specific purpose means that JPEG, which is meant for photographs, doesn't work very well when used for computer and video game graphics: basically, quality problems which may not be obvious in a photograph will show up more clearly in the bright colors of many games. Another problem for JPEG is that the file won't even be much smaller than an image compressed "losslessly"&mdash;without throwing away any information. Lastly, every time a JPEG is opened and saved again, it loses even more quality.

The image at right shows a scale of what JPEG compression looks like at different levels. On the left, most of the image information has been lost, while toward the right, the amount lost is small enough that we might not be able to tell just from looking at it. However, no part of this image looks "perfect"; all of it is missing information from the original photo which can never be restored.

The PNG (Portable Network Graphics) format, which is what we prefer here on TCRF, was designed from the beginning as a raster graphics format, which is able to save the original graphic "losslessly", which means a perfect copy which doesn't give up any details. The image can be edited as many times as you like and it will be exactly the same quality every time.

Why JPEGs?
Unfortunately, we don't always have access to the original lossless image, especially when it comes to prerelease images from old magazine scans, for example. In cases like this, it's OK to upload JPEGs to TCRF. However, sometimes you might have a small screenshot of a game on a full magazine page, or maybe you've found an image online that's upside down for some reason. You could edit it and save it again, reducing the image quality. You could edit it and save it as PNG, but then you're taking up a lot of space with an image that accurately shows the mistakes that the JPEG introduced! Maybe the best option is JPEG after all ... because we can make some edits without losing any more quality or making very large files, using special lossless JPEG editing tools.

Tools
Most JPEG editing programs are not lossless. However, with the right tools, there are some simple changes you can make to a JPEG without losing any information. These include cropping (cutting out borders), rotating and joining them together. If you need to do any of these things to a JPEG before uploading it to TCRF, we suggest you try some of the programs below. If none of these are right for your computer, you may be able to find something similar on this list of lossless JPEG editing tools or by searching.

There are some limitations to what can be done losslessly with a JPEG image. JPEG files are saved as a series of "blocks", like a giant patchwork quilt. These are almost always 8 or 16 pixels wide/tall, and as a rule, you can't make many changes "in the middle" of a block. For example, all JPEGs must begin (at the top left) on the very edge of a block. The image can end on a partial block, though: on the right and bottom sides. However, partial blocks like these cannot be rotated, so you may still lose the edges of an image if you rotate it "losslessly".

Almost all lossless JPEG editing tools are based on jpegtran, which is available as a command-line tool on all major platforms (on Linux, it's almost always bundled). If you're comfortable with or prefer a command line tool for these operations, this is the obvious choice. Otherwise, there are a number of GUI-based editors which some may find more user-friendly.

Jpegcrop
Jpegcrop is the best-known implementation of the jpegtran lossless JPEG editing suite. It allows cropping, rotating, mirroring, and flipping JPEG images without reducing their quality. By default, Jpegcrop will save images with highly optimized "Arithmetic" encoding, which is unusable in many other programs, including some web browsers. Before editing any images with Jpegcrop, you should open File > Preferences and set "Entropy Coding Method" to "Huffman optimized". The other default settings should be fine.

Once you've opened a JPEG image in Jpegcrop, you may find it helpful to click the "Block Grid" icon (or enable it via View > Block Grid). This will show you where the JPEG blocks are, so that you can more easily find where to crop. Another important option is the "Endpoint Snap" icon (or Options > Endpoint Snap), which will let you crop partial blocks at the end (right/bottom) sides of the image if necessary. Lastly, the "Transform Trim Edges" icon (or Options > Transform Trim Edges) is also worth considering if you want to rotate an image, as it will drop any partial blocks which cannot be rotated rather than leaving them sitting on the edge, immobile.

To begin a lossless crop, simply click and drag a selection box over the section that you want to keep. You can adjust the edges once you're done selecting if you need to do more fine cropping (but keep in mind that this will still be at a block level, barring the endpoint if you chose to disable "Endpoint Snap"). The zoom slider may also be useful, here. Once you've got the section you want outlined, you can click the "Save Frame" icon, right click the image and select "Save Frame As..." or use File > Save Frame As... to open a file dialogue where you can name your new cropped file. It's recommended that you give it a different file name to the original rather than saving over it, in case you need it later.

Lossless rotation can be done by clicking one of the many icons along the top of the image frame, or from the Transform menu. Once the image is in the orientation you want (and if necessary, the edges trimmed), you can still use the cropping function if you need to. Otherwise, you can use "Save Frame" to save a copy of your new losslessly rotated JPEG.

Jpegjoin
Jpegjoin is another tool by the authors of Jpegcrop which is designed to allow combining multiple JPEGs into a single image, losslessly. One reason you may want to do this is to combine two scanned magazine pages into one big image. Just like in Jpegcrop, the first thing you should do is enter File > Preferences and make sure "Entropy Coding Method" is set to the widely-compatible "Huffman optimized" setting.

To combine images, you need to open them in Jpegjoin first. For each image you want to combine, you will need to select Project > Add Frame, then select No Legend and hit OK. To check on the list of images you have loaded into the current project or remove any images you didn't mean to add, you can use Project > Show Frame List. Once all your images have been loaded into the project, select Project > Save Project As....

The dialogue that appears next is where you decide the layout of your joined images. This works like a table, with columns and rows. For example, two images side-by-side (e.g. a magazine spread) would be 2 columns and 1 row. For most cases, you should put 0 in both of the Spacing fields. The comment can simply be left blank. Once you hit OK, the file dialogue will open and you can name your newly combined file anything you like, being careful not to save over any images you might need later.

IrfanView
IrfanView is a freeware image viewer and editor with a wider focus than the above, JPEG-specific software. While it can't edit JPEGs losslessly by default, there is an official plugin, Jpg_Transform. With this plugin installed, JPEGs can be rotated or cropped similarly to the Jpegcrop tool.

To make a lossless crop, simply select the portion of the image you want to keep using the mouse and use Options > JPG Lossless Crop. This will result in a popup where you can choose to save to the same directory with _crop on the end of the file, or manually specify a directory and filename. Unlike Jpegcrop, IrfanView does not have more advanced features like the block grid or toggling of endpoint snap, so it may be harder to perform precise crop operations than in the more dedicated tool. Otherwise, it is largely similar.

For lossless rotation, use Options > JPG Lossless Rotation..., which will open a popup with the different rotation settings available. The setting for "Perfect" transformation should be left unchecked, or else the partial blocks, which cannot be rotated, will be kept on the edges without being rotated. Note that this feature will write directly over the original file, so be sure to keep a backup if you think you will need the image again later.

Xee
Xee is a trialware/paid (US $4) app for Mac OS X computers which is designed to be similar to the standard Preview app but with more advanced features. Some of these features include lossless cropping and rotation of JPEGs. Before the current "Xee 3" line, this was a free and open source app, which the developer still offers with the last free version, 2.2. For users not interested in the pay or trial versions, this may be a good alternative for lossless JPEG editing on Mac OS X.

CropGUI
CropGUI is a free and open source program for lossless cropping of JPEGs. It does not appear to have any lossless rotation functionality.