Images¶
Digital images can either be raster-based or vector-based.
Raster images¶
The image is represented as a pixel map encoded in a specific format, compressed or not.
Common formats such as JPEG
, TIFF
, PNG
, GIF
, are raster-based.
The basic spatial characteristics of a raster image are pixel size (width and height in pixels), horizontal and vertical resolution, and orientation.
Width is the number of columns and height is the number of rows of the image’s pixel map.
Resolution, measured in pixels per inch, denotes the pixel density along the horizontal or vertical axis or, in other words, the real-world dimensions of a pixel.
A derived metric is the raster image’s point size, i.e. the ‘natural’ size of the image when
printed or displayed onscreen. Point size is computed from pixel size and resolution,
and is expressed in points: point size = (pixel size / resolution) * 72
.
The point is a standard unit in the printing industry (1 inch = 72 points).
Another spatial attribute that must be taken into account for display or printing is orientation. Image orientation was not seriously considered some years ago, but became important since digital cameras, smartphones and tablets rely on it to correctly display images acquired with such devices.
Image orientation is actually stored in the image’s metadata and denotes the orientation of the device when the image was captured. Based on this information, programs can tell how the image should be transformed in order to be displayed or printed correctly.
Best described with pictures, allegedly worth a thousand words:
Value | Description |
---|---|
1 |
Normal orientation |
2 |
Flipped horizontally |
3 |
Rotated 180º |
4 |
Flipped vertically |
5 |
Rotated 90º CCW and flipped vertically |
6 |
Rotated 90º CCW |
7 |
Rotated 90º CW and flipped vertically |
8 |
Rotated 90º CW |
Image Compression¶
Most raster formats compress pixel data in order to save storage space and network bandwidth. Image compression may be lossy or lossless.
Lossy compression permanently sacrifices image quality in order to achieve high compression rates.
Compression quality is specified when the image is saved and repeated lossy recompression leads
to image deterioration because of generational quality loss (a.k.a. compression artifacts).
Lossy formats are suited for final delivery rather than archiving.
The most widely used lossy image format is JPEG
.
Lossless formats, on the other hand, produce heavier files, but original pixels are reproduced without any loss. Depending on the original pixel format (color, grayscale, or black & white), some lossless formats may achieve very high compression rates.
For example, a black & white scan of a A4 page at 300 dots per inch when saved as a TIFF
compressed with CCITT G4 (a lossless algorithm) will result to a file of just a few kilobytes
in size. The same image saved as a JPEG
with medium quality results into a file 10 times
that size.
Common lossless image formats include TIFF
, PNG
, BMP
, Photoshop
.
There are also formats that support both lossy and lossless compression schemes. JPEG 2000
is such a format. Though not widely used, the TIFF
format also supports JPEG compression.
Multi-frame Images¶
While most raster formats are single-frame, the TIFF
format supports multiple frames in a single
container file.
TIFF’s ability to store multiple frames combined with CCITT/G4 compression support, make it ideal for archiving black/white scanned documents and faxes in document management systems.
Vector images¶
The image is represented as a collection of vector descriptions, painting operations,
and possibly also bitmaps. PDF
documents, SVG
, Postscript
, and EPS
are
some common vector-based formats.
PDF documents¶
PDF is arguably the most widely used vector format today. It combines vector graphics, text, raster images, and other kinds of content into a rich format.
PDF is a multi-frame format: a document may contain many pages.
PDF pages have the following attributes that describe their geometry:
A set of boxes that describe the size of the page.
- The media box
- The crop box
- The art box
- The bleed box
The most interesting of these are the media box and the crop box: their intersection defines the size of the page and the area that a viewer should display.
All box coordinates and, consequently, the size of the page are expressed in
points
(1 inch = 72 points
).A rotation attribute.
Describes how the page must be rotated for correct display. Possible values are
0
,90
,180
, and270
.
PDF documents also support a number of security features which are set by the author when the document is created:
- Password protection: opening and displaying a document may require a password.
- Access control: copying or printing a document may be prohibited.
Supported formats¶
Q2Pix currently supports the following image formats:
Format | File name extensions | Can encode | XMP support | Notes |
---|---|---|---|---|
JPEG |
“jpeg”, “jpg”, “jpe”, “jfif”, “exif” | ✔︎ | ✔︎ | |
TIFF |
“tiff”, “tif” | ✔︎ | ✔︎ | |
PNG |
“png” | ✔︎ | ✔︎ | |
BMP |
“bmp” | ✔︎ | ✔︎ | |
GIF |
“gif” | ✘ | ✔︎ | Single-frame only. |
PDF |
“pdf” | ✔︎ | ✔︎ read-only | |
Photoshop |
“psd” | ✔︎ | ✔︎ | macOS only. |
JPEG 2000 |
“jp2”, “jpf”, “jpx”, “j2k”, “j2c” | ✔︎ | ✔︎ | macOS only. |
HEIF |
“heic” | ✘ | ✔︎ | macOS only. |