To fix that a -fuzz factor will be needed.
Next the padding do not go completely around the image. as such a straight flood-fill color replacement will not do the job. To fix that you need to add a little more padding to connect all the areas together.
This extra padding as a bonus of actually provideing an exact white color pixel for our flood fill with fuzz factor to work from EG the pixel will be definatally pure white, and not some slightly off white color.
The final solution...
Code: Select all
convert image.jpg -bordercolor white -border 1x1 -fill black \
-fuzz 25% -draw 'color 0,0 floodfill' -trim +repage image_fixed.png
The major problem you have now is that the JPG has turned the edge between the old black padding and the new white pddidng into a full range of grey scales. This will make it imposible to completely erase the border between these two areas without destroying the actual image.
You may need some hand triming and coloring to fix it entierly.