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

TryTryAgain picture TryTryAgain · Dec 15, 2011 · Viewed 11.2k times · Source

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!

Answer

TryTryAgain picture TryTryAgain · Dec 29, 2011

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.