Page 1 of 1

Posted: 2006-03-09T18:19:21-07:00
by anthony
Well first of all the padded area is probably not exactly white or black, as JPEG does not store colors exactly. It ia a lossy format, loading and saving an image using JPEG will slowly degrade the image.

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
Note I saved to png. leave images that may be modifyed further as something other than JPEG. Archive those images and only convert them to JPEG for the web use. Basically avoid modifying to and from JPEG format multiple times.

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.