Jpg with round corner and white background

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
YvesTan

Jpg with round corner and white background

Post by YvesTan »

Hello,

I try to generate photos thumbnails jpg with white background. I use this command :

Code: Select all

convert -size 100x100 xc:none -draw 'roundRectangle 0,0 100,100 15,15' -fill white original.jpg -compose SrcIn -composite thumbnail.jpg
But I dont understand why it's not working (I obtain black corner).

It's great with png out but the image is too bigger ! 40 Ko for 100x100 simple png...

Thanks !

YvesTan (french user)
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Jpg with round corner and white background

Post by Bonzo »

I do not know if this is a valid way to use ImageMagick and I could not get all the code on one line:

Code: Select all

composite -compose Dst_in ( convert -size 100x100 xc:none -fill black -draw "roundRectangle 0,0 100,100 15,15" ) house.jpg -matte thumbnail.png

convert -size 100x100 xc:white thumbnail.png -composite output.jpg
Your black corners are still comming from the transparency.
YvesTan

Re: Jpg with round corner and white background

Post by YvesTan »

Thanks to your answer. I've use a similar way with 2 command line.

The first on my previous post and

Code: Select all

convert thumbnail.png -background white -flatten thumbnail_out.jpg
And after "rm thumbnail.png" ;)

Bye !
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Jpg with round corner and white background

Post by anthony »

while flatten will not work with mogrify for in-place image modification, (it is a multi-image layers operator after all. an alturnative is border.

mogrify -bordercolor white -border 0x0 thumbnail.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply