Convert a Raw Camera File to PAM with cameratopam
You will finish with a PAM image made from a supported raw camera file, while keeping the original untouched and checking the conversion before you use the result elsewhere. The examples use cameratopam from Netpbm 11.5.2, installed here as Debian package version 2:11.05.02-1.1build1.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about fifteen minutes for one file. You need a readable raw camera image and the Netpbm package. The command normally runs as your ordinary user. You do not need sudo unless filesystem permissions, rather than cameratopam, prevent you reading the input or writing the destination.
1. Check the installed command
Confirm which executable is being used and record its Netpbm build. This is read-only:
$ command -v cameratopam
/usr/bin/cameratopam
$ cameratopam -version
cameratopam: Using libnetpbm from Netpbm Version: Netpbm 11.5.2
cameratopam: Built from source dated 2024-03-31 09:09:47
cameratopam: Built by Debian
...
The final lines describe the local build and may differ on another system. The installed manual is the contract to follow. It says that an input file name is optional, and that options can be abbreviated to the shortest unique prefix. Use full option names in scripts so a later change cannot make a short form ambiguous.
Checkpoint
Continue only if command -v points to the Netpbm executable you intended to test.
2. Identify the raw file before converting it
Use -identify_only when you want format detection without an output image. It reports to standard error and fails if the format is not recognised:
$ cameratopam -identify_only /path/to/PHOTO.RAW
format information is printed by cameratopam
The exact identification text depends on the camera file, so do not build a script around a particular wording. A non-zero exit status means that this file was not recognised by the installed decoder. Check the path and preserve the original while you investigate:
$ test -r /path/to/PHOTO.RAW && echo readable
readable
$ printf 'identify status: %s\n' "$?"
identify status: 0
That status check is most useful immediately after the command you are testing. Do not confuse a readable file with a supported file: permissions and format recognition are separate checks.
3. Make a first PAM conversion safely
Shell redirection writes the program's standard output to a file. Choose a new destination so a failed conversion cannot truncate a useful existing image:
$ cameratopam /path/to/PHOTO.RAW > PHOTO.pam.new
$ status=$?
$ printf 'conversion status: %s\n' "$status"
conversion status: 0
$ test "$status" -eq 0 && test -s PHOTO.pam.new && echo 'non-empty PAM candidate'
non-empty PAM candidate
A successful exit status and a non-empty file show that the command produced data. They do not prove that the image has the composition or exposure you want. Keep PHOTO.RAW; the converter reads it and does not need to modify it.
Only after checking the new file should you give it the final name. The move below replaces an existing PHOTO.pam, so treat it as a destructive step. Make a backup first if that path already contains a useful image:
$ test ! -e PHOTO.pam || cp --preserve=all PHOTO.pam PHOTO.pam.bak
$ mv PHOTO.pam.new PHOTO.pam
If you have not run the move, recover by deleting the candidate with rm PHOTO.pam.new. If you made the backup and the replacement is wrong, restore it with mv PHOTO.pam.bak PHOTO.pam. Do not remove the backup until the result has been inspected.
4. Choose interpolation for the job
The default uses a slower, high-quality adaptive interpolation algorithm. Keep that default when image quality matters and processing time is acceptable. For a quicker result, use bilinear interpolation:
$ cameratopam -quick_interpolate /path/to/PHOTO.RAW > PHOTO-quick.pam
-half_size is faster again. It reduces each 2 by 2 sensor block to one output pixel instead of interpolating, so the output is smaller. It is useful for a quick proof or a reduced working copy, not as a like-for-like full-size conversion:
$ cameratopam -half_size /path/to/PHOTO.RAW > PHOTO-half.pam
Use the four-colour RGB option only when the converted image shows false 2 by 2 mesh patterns, such as in blue sky. The manual warns that it causes a slight loss of detail:
$ cameratopam -four_color_rgb /path/to/PHOTO.RAW > PHOTO-four-colour.pam
These choices affect the output file only; they do not alter the raw source.
5. Set colour and brightness deliberately
By default, cameratopam converts to sRGB and uses a fixed balance based on a white card photographed in sunlight. For a different result, choose one balance mode explicitly:
$ cameratopam -balance_auto /path/to/PHOTO.RAW > PHOTO-auto-balance.pam
$ cameratopam -balance_camera /path/to/PHOTO.RAW > PHOTO-camera-balance.pam
-balance_camera uses the setting recorded by the camera. If that information is unavailable, cameratopam warns and falls back to its default. -balance_auto asks for automatic colour balance. Do not compare these files only by command exit status: inspect the rendered image as well.
Red and blue adjustments multiply their respective channels and default to 1.0. Brightness also defaults to 1.0:
$ cameratopam -red_scale=1.05 -blue_scale=0.95 -brightness=0.90 \
/path/to/PHOTO.RAW > PHOTO-adjusted.pam
Start with small changes and keep the unmodified conversion as a comparison. Option values can be separated with whitespace instead of an equals sign, but the equals form makes the value boundary obvious in a review.
6. Know when the specialist modes apply
-document_mode shows the raw data as a greyscale image without interpolation. Use it for a black and white document, not for a normal colour photograph. -secondary is specifically for Fuji Super CCD SR cameras: it uses the secondary sensors and effectively underexposes by four stops to reveal highlight detail. The option is silently ignored for other cameras, so do not use it as a general exposure control.
-rgb writes raw camera colours instead of the default sRGB conversion. -linear changes the sample representation for workflows that need samples proportional to light intensity. Without it, the output maxval is 255 and uses one byte per sample. With it, the maxval is 65535 and uses two bytes per sample. Confirm that the next tool understands this variation before choosing it:
$ cameratopam -linear /path/to/PHOTO.RAW > PHOTO-linear.pam
$ file PHOTO-linear.pam
PHOTO-linear.pam: ...
The exact file description varies by version. The check is there to catch an empty or unexpectedly named destination, not to replace an image viewer or PAM-aware inspection tool.
7. Turn on diagnostics when a result is unclear
Use -verbose to send processing details to standard error while the PAM data still goes to standard output:
$ cameratopam -verbose /path/to/PHOTO.RAW > PHOTO-verbose.pam
processing details are printed on standard error
Keep the two streams separate if a later command consumes the PAM bytes. Do not redirect both streams into the same file, because diagnostic text would corrupt the image. If recognition fails, return to -identify_only, check the file path and test another raw file from the same camera. A warning about camera balance is different from a decoder failure: the former has a documented fallback, while the latter produces no usable conversion.
Done means
- The installed Netpbm version and executable were checked.
-identify_onlyrecognised the raw file before conversion.- The PAM candidate was written to a new path and was non-empty.
- Interpolation, colour balance, brightness and linear mode were selected for a stated reason.
- The original raw file remains untouched, and any replacement can be restored from its backup.