Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save, export, or convert an Android XML Drawable as a PNG image file?

I have a gradient I really like but I created it using XML drawable:

<gradient
    android:startColor="#DD181C18"
    android:endColor="#809C7D5A"
    android:angle="90"/>

What would be an easy way to create this to a png or something similar?

What I'm really looking for is: a tool that can and instructions using that tool to make gradients using an #aarrggbb format as it's input alpha/color (90 degree angle, angles in general, would be a plus).

Thanks for any help.

EDIT: D'oh! I totally just realized ImageMagick should be able to do this. I will post the code that is my answer shortly, unless someone wants to beat me to it and receive the whole bounty!

like image 327
TryTryAgain Avatar asked Dec 15 '11 12:12

TryTryAgain


1 Answers

In the end it was a one liner using ImageMagick!

I can't believe I didn't think to use ImageMagick before, Duh!!!

convert -size 480x84 gradient:'rgba(156, 125, 90, 0.52)'-'rgba(24, 28, 24, 0.86)' tmp.png

For reference, I used this to create a .png image file using my Android XML drawable ##AARRGGBB values. ImageMagick FTW!!!

Thanks for everyone's input.

like image 59
TryTryAgain Avatar answered Sep 20 '22 22:09

TryTryAgain