PDF to JPEG Conversion in Omnis Studio using Process Worker

A useful discovery from the Omnis community---demonstrating how to convert a PDF into a JPEG image file using macOS or Windows command-line tools, and integrating it with Omnis Studio via a Process Worker.


macOS — Using sips

The built‑in sips command in macOS can convert a single‑page PDF to a JPEG image with good resolution.

sips -s format jpeg input.pdf --out output.jpg

You can adjust size with optional parameters like pixelWidth and pixelHeight if you want to constrain the output (e.g., 80×80).
For many uses---such as Kelly’s ImageBox external or a PICT field in a complex grid---you may simply display the full image at a constrained size, keeping the original resolution intact.

To automate it within Omnis Studio, use a Process Worker:

Calculate command as "sips -s format jpeg /path/to/input.pdf --out /path/to/output.jpg"
Do processWorker.$init(command)
Do processWorker.$run()
Do processWorker.$readlines(kOProcessStdout) Returns list
Calculate PictFile as list.1.stdout

This runs the command and captures the output filename from the process results.


macOS — Handling Binary Output (Advanced)

The sips command does not output binary image data to STDOUT, which means a Process Worker cannot capture raw image bytes directly.
To work around this limitation, you can convert the output image to Base64, which is safe to return via STDOUT in Omnis.

Example command:

sips -s format png input.icns -o __temp_sips_output.png && base64 __temp_sips_output.png && rm __temp_sips_output.png

What the steps do

This allows Omnis to receive the image data entirely through STDOUT as text, which you can decode back to binary inside Omnis if needed.

Notes


Windows — Using ImageMagick

On Windows, use ImageMagick, which supports PDF-to-JPEG conversion:

magick input.pdf output.jpg

Integrate via Process Worker exactly as on macOS by adjusting the command string.


Contributors

Very cool 👍