# Debugging image resources

I work a lot with image processing. There is a lot of transformations and sub images extraction. Often, it would be great to actually see those images when debugging. Quick Google search pointed me to the dump command present in gdb.

In short, to get the memory dump, you would do something like this:

set $source=pointer_to_the_memory set$size_of_the_dump=4096
dump memory filename.bin $source$source+size_of_the_dump


You have to know the size of your data. For an image it means: width, height, color depth.

Next step was to actually visualize this data as an image. I’ve put together a small Python script. The goal was to make it as simple as possible - I was in a rush. This solution is pretty cumbersome compared to what a workflow like that could be…

import pathlib
from PIL import Image
import sys

full_path = pathlib.Path(sys.argv[1])
width = int(sys.argv[2])
height = int(sys.argv[3])