Command-Line / ImageMagick Help

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-03-09T18:19:21-07:00

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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Post Reply