ROS CompressedImage JSON Viewer – Free

This ROS CompressedImage viewer takes a message captured as JSON, rebuilds the JPEG or PNG from its data field and shows it. Use it to check what a camera topic published without starting a GUI on the robot.

How to use the ROS CompressedImage Viewer tool

  1. Paste the message object into CompressedImage JSON. It must have a top-level data field.
  2. Select View image to decode the frame.
  3. Check the preview and the Result box, which shows the byte count and the detected media type.
  4. Use the Download link to save the frame as compressed-image.jpg or compressed-image.png.

How the ROS CompressedImage viewer reads data

A CompressedImage message stores a whole image file in data. In JSON that field appears in one of two forms, depending on the software that serialized it. Some tools write a list of numbers, one per byte. JSON bridges such as rosbridge write byte arrays as a single Base64 string to save space. The viewer accepts both.

If data is an array, every element must be an integer from 0 to 255. If it is a string, it is decoded as Base64, and URL-safe characters, missing padding, line breaks and a data URL header are all tolerated. The resulting bytes are identified by their signature and handed to your browser for display.

The format field is not trusted

The viewer ignores format and header completely. It decides the type from the first bytes: the PNG signature, FF D8 FF for JPEG, GIF87a or GIF89a, or a RIFF container marked WEBP. That makes it a quick check for a common bug, a publisher that labels PNG data as jpeg or the reverse. If the Result box says image/png while your message says jpeg, the publisher is mislabeling frames. The file name of the download follows the detected type.

Example message with Base64 data

The message below carries a 70-byte PNG of 1 by 1 pixel as Base64 and deliberately claims to be a JPEG. The viewer reports the true type and names the download compressed-image.png.

{
  "header": { "stamp": { "sec": 0, "nanosec": 0 }, "frame_id": "camera" },
  "format": "jpeg",
  "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
}

Result: 70 bytes · image/png

Messages that fail and how to fix them

Most failures come from the capture step and not from the image itself.

  • YAML printed by ros2 topic echo or rostopic echo is not JSON. Convert it, or capture the message through a JSON bridge.
  • A bridge envelope with op, topic and msg has no top-level data. Paste only the object under msg, otherwise you get Expected a Base64 string.
  • Image data must contain byte values from 0 to 255 means the array holds negatives, decimals or larger numbers, often signed 8-bit values from another language.
  • Expected PNG, JPEG, GIF or WebP bytes means the data decoded but is not a plain image file. Compressed depth topics are a typical case, because they place an extra header before the PNG.
  • Enter valid Base64 points to a truncated or altered string, for example one cut off by a log line limit.

Frequently asked questions

Can I view a sensor_msgs/Image message here?

No. That message holds raw pixels with width, height and encoding, not a compressed file, so there is no JPEG or PNG signature to find. This viewer is only for CompressedImage data.

Does the viewer connect to my robot or a rosbridge server?

No. It works on text you paste and opens no connection. Capture one message to JSON with your own tooling, then paste it. The frame is decoded and displayed inside your browser.

Why does the preview show a broken image although no error is reported?

The signature was valid, so the tool accepted the bytes, but the browser could not decode the rest. The image is probably truncated or corrupted after the header. Download the file and inspect it with an image tool to confirm.

Which form of data is supported, array or Base64?

Both. A JSON array of integers from 0 to 255 is converted directly to bytes, and a string is decoded as Base64. Other shapes, such as an object with numeric keys, are not accepted.

How do I capture a CompressedImage message as JSON?

Subscribe through a JSON bridge and log one message, or write a short script that converts the message to a dictionary and dumps it with a JSON library. Make sure the output is strict JSON with double quotes.

Related tools