Skip to content

Instantly share code, notes, and snippets.

@Nervovred
Nervovred / magick.rb
Last active June 15, 2017 04:18
ImageMagick resize with round edges
in_pic = "in.jpg"
out_pic = "out.jpg"
radius = 25
size = "500x500"
bgcolor = "white" #JPG doesn't support alpha channel, write "None" if you want transparent edges for PNG files
cmd = "convert #{in_pic} " +
"-resize #{size}! " + #comment out this line if you don't want to resize
"\\( +clone -alpha extract " +
"\\( -size #{radius}x#{radius} xc:black -draw 'fill white circle #{radius},#{radius} #{radius},0' " +
"-write mpr:arc +delete \\) " +
in_pic = "in.jpg"
out_pic = "out.jpg"
radius = 25
size = "500x500"
bgcolor = "None" #JPG doesn't support alpha channel, write "None" if you want transparent edges for PNG files
cmd = "convert #{in_pic} " +
"-resize #{size}! " + #comment out this line if you don't want to resize
"\\( +clone -alpha extract " +
"\\( -size #{radius}x#{radius} xc:black -draw 'fill white circle #{radius},#{radius} #{radius},0' -write mpr:arc +delete \\) " +
"\\( mpr:arc \\) -gravity northwest -composite " +