An important caveat about lossy compression (formally transcoding), is that editing lossily compressed files causes
digital generation loss from the re-encoding. This can be avoided by only producing lossy files from (lossless) originals and only editing (copies of) original files, such as images in
raw image format instead of
JPEG. If data which has been compressed lossily is decoded and compressed losslessly, the size of the result can be comparable with the size of the data before lossy compression, but the data already lost cannot be recovered. When deciding to use lossy conversion without keeping the original, format conversion may be needed in the future to achieve compatibility with software or devices (
format shifting), or to avoid paying
patent royalties for decoding or distribution of compressed files.
Editing of lossy files By modifying the compressed data directly without decoding and re-encoding, some editing of lossily compressed files without degradation of quality is possible. Editing which reduces the file size as if it had been compressed to a greater degree, but without more loss than this, is sometimes also possible.
JPEG The primary programs for lossless editing of JPEGs are
jpegtran, and the derived exiftran (which also preserves
Exif information), and Jpegcrop (which provides a Windows interface). These allow the image to be
cropped, rotated,
flipped, and
flopped, or even converted to
grayscale (by dropping the
chrominance channel). While unwanted information is destroyed, the quality of the remaining portion is unchanged. Some other transforms are possible to some extent, such as joining images with the same encoding (composing side by side, as on a grid) or pasting images such as logos onto existing images (both via Jpegjoin), or scaling. Some changes can be made to the compression without re-encoding: • Optimizing the compression (to reduce size without change to the decoded image) • Converting between progressive and non-progressive encoding. The freeware Windows-only
IrfanView has some lossless JPEG operations in its JPG_TRANSFORM
plugin.
Metadata Metadata, such as
ID3 tags,
Vorbis comments, or
Exif information, can usually be modified or removed without modifying the underlying data.
Downsampling/compressed representation scalability One may wish to
downsample or otherwise decrease the resolution of the represented source signal and the quantity of data used for its compressed representation without re-encoding, as in
bitrate peeling, but this functionality is not supported in all designs, as not all codecs encode data in a form that allows less important detail to simply be dropped. Some well-known designs that have this capability include
JPEG 2000 for still images and
H.264/MPEG-4 AVC based
Scalable Video Coding for video. Such schemes have also been standardized for older designs as well, such as
JPEG images with progressive encoding, and
MPEG-2 and
MPEG-4 Part 2 video, although those prior schemes had limited success in terms of adoption into real-world common usage. Without this capacity, which is often the case in practice, to produce a representation with lower resolution or lower fidelity than a given one, one needs to start with the original source signal and encode, or start with a compressed representation and then decompress and re-encode it (
transcoding), though the latter tends to cause
digital generation loss. Another approach is to encode the original signal at several different bitrates, and then either choose which to use (as when streaming over the internet – as in
RealNetworks' "
SureStream" – or offering varying downloads, as at Apple's
iTunes Store), or broadcast several, where the best that is successfully received is used, as in various implementations of
hierarchical modulation. Similar techniques are used in
mipmaps,
pyramid representations, and more sophisticated
scale space methods. Some audio formats feature a combination of a lossy format and a lossless correction which when combined reproduce the original signal; the correction can be stripped, leaving a smaller, lossily compressed, file. Such formats include
MPEG-4 SLS (Scalable to Lossless),
WavPack,
OptimFROG DualStream, and
DTS-HD Master Audio in lossless (XLL) mode). ==Methods==