If you are working on a Unix or Linux system and need to determine the dimensions for an image, there are a number of command line tools that may be available to you on the system. If you are including an image on a webpage, if you specify the file's dimensions, then visitor's to your website can view other information on your webpages while potentially large images are still being downloaded for viewing by the visitor's browser. If you specify the dimensions of the image files within your webpages, the browser will allocate the space needed to display the image and then display other parts of the webpage while it is still downloading large image files.
You can specify the image dimensions in pixels like this:
<img src="banana.jpg" alt="A banana" width="320" height="378">
One command line tool that can be used to determine a
JPEG
file's size is rdjpgcom. The
utility is used to display comments that can be embedded in
JPG files (you can insert comments with wrjpgcom), but
you can also display the dimensions for a JPG file with the --verbose
option.
$ rdjpgcom -verbose banana.jpg
JPEG image is 921w * 592h, 3 color components, 8 bits per sample
JPEG process: Baseline
If you have ImageMagick installed
on the system, you can also use the identify command to determine
the dimensions of an image file. Note: if you are using RedHat Linux, or
another version of Linux that uses
RPM to manage
software on the system, you can issue the command rpm -qi ImageMagick
to see whether it is installed.
$ identify banana.jpg
banana.jpg JPEG 921x592 DirectClass 8-bit 87kb 0.0u 0:01
The identify utility displays the width followed by the height.
Another command that may be available to you is imgsize.
$ imgsize banana.jpg
imgsize banana.jpg
width="921" height="592"
