Make round card corners with transparency
Posted: 14 Aug 2017, 16:22
Hello.
I coded a script for get complete card sets into Xmage format (more info, if anyone interested: reddit.com/r/XMage/comments/6szmiu/predownload_images_for_commander_2017/dllvir7).
Many times image cards comes with ugly white or black corners, where supposed to be rounded. So using (the famous) Imagemagick I managed to get rid of it, and mantaining transparency (alpha channel, png format) so looks nice and roundy in softwares, websites...
So I think this could be useful for more people, here is the commands you need.
First, install Imagemagick in the system you're using.
Now you can execute this commands in your cmd/console (and of course, complete with your scripts).
First you need to make the "round border" overlay for the cards with this command, only need one time for the cards (if all are in the same size).
Now with this you "glue" the round overlay with the card and export. Notice that you may name it with .png extension, if not, alpha channel will not save.
P.S. For Xmage .png extension will not work, but just renaming (not converting) to ".jpg" all goes ok:
Windows:
Edit:
I also made a simply .bat to drag-n-drop a image and round it. The difference it's mainly that round-size-layer it's automated with imagemagick "identify". The rest are the same.
I coded a script for get complete card sets into Xmage format (more info, if anyone interested: reddit.com/r/XMage/comments/6szmiu/predownload_images_for_commander_2017/dllvir7).
Many times image cards comes with ugly white or black corners, where supposed to be rounded. So using (the famous) Imagemagick I managed to get rid of it, and mantaining transparency (alpha channel, png format) so looks nice and roundy in softwares, websites...
So I think this could be useful for more people, here is the commands you need.
First, install Imagemagick in the system you're using.
Now you can execute this commands in your cmd/console (and of course, complete with your scripts).
First you need to make the "round border" overlay for the cards with this command, only need one time for the cards (if all are in the same size).
- Code: Select all
convert -size 488x680 xc:none -draw "roundrectangle 0,0,488,680,25,25" mask.png
Now with this you "glue" the round overlay with the card and export. Notice that you may name it with .png extension, if not, alpha channel will not save.
- Code: Select all
convert "card.jpg" -matte mask.png -compose DstIn -composite "card.png"
- Code: Select all
convert "card.png" -resize 265x370 -alpha on "card.png"
P.S. For Xmage .png extension will not work, but just renaming (not converting) to ".jpg" all goes ok:
Windows:
- Code: Select all
ren *.png *.jpg
- Code: Select all
rename 's/.png$/.jpg/' *.png
Edit:
I also made a simply .bat to drag-n-drop a image and round it. The difference it's mainly that round-size-layer it's automated with imagemagick "identify". The rest are the same.
- Code: Select all
FOR /F "tokens=1 delims=" %%A in ('identify -format %%[fx:h] %1') do SET alto=%%A
FOR /F "tokens=1 delims=" %%A in ('identify -format %%[fx:w] %1') do SET ancho=%%A
convert -size %ancho%x%alto% xc:none -draw "roundrectangle 0,0,%ancho%,%alto%,19,19" mask.png
convert %1 -matte mask.png -compose DstIn -composite "result.png"
del mask.png
ren *.png *.jpg