red background instead of a transparent background for butto

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
hknight
Posts: 32
Joined: 2007-08-02T10:16:15-07:00

red background instead of a transparent background for butto

Post by hknight »

Hello,

The following creates a 3D button. The button HAS to be a jpg (not a png).

The problem is that because the corners are transparent, when the jpg is made they turn black.

The background needs to be red. How can I make the button have a red background instead of a transparent background?

Thanks!

Code: Select all

## Thanks, Anthony!
convert -background transparent -fill transparent \
           -pointsize 12 label:'Hello Cruel World' -border 7 +repage \
           -format '%wx%w'  -write info:size1.txt \
           -format '%wx%h'  -write info:size.txt \
           info:grad.mvg

convert -background transparent -fill transparent \
           -pointsize 12 label:'Hello Cruel World' \
           -format 'viewbox 0 0 %[fx:w+7] %[fx:h+7]  \
            fill white roundRectangle 1,1 %[fx:w+5] %[fx:h+5] 5,5' \
            info:rounded_corner.mvg

convert -background black +antialias rounded_corner.mvg mask.png

convert -size `cat size1.txt` gradient:'#C27A08'-'#FE9800' -rotate -35 \
           -gravity center -crop `cat size.txt`+0+0 +repage \
           mask.png +matte  -compose CopyOpacity -composite \
          -pointsize 11 -fill black +antialias \
          -gravity Center -annotate 0 "Hello Cruel World" \
          button.png

convert button.png  -fx A  +matte -blur 0x3  -shade 110x30  -normalize \
          button.png  -compose Overlay -composite \
          button.png  -matte  -compose Dst_In  -composite -trim +repage \
          3dButton.jpg
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: red background instead of a transparent background for butto

Post by anthony »

Code: Select all

   ....   -background red -flatten  image.jpg
See IM Examples
http://www.imagemagick.org/Usage/mosaics/#flatten

Which is referenced from Common Image Formats,
JPEG transparency - NOT
http://www.imagemagick.org/Usage/formats/#jpg_trans

That should have been your first point of call!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply