Convert PNG to GIF via Command Line

I installed a bare bones Arch Linux system today and took a screenshot.  With no graphics utilities installed, I needed a way to convert a PNG to a GIF for a Simple Machines forum template thumbnail.  I figured I’d use a command line utility to help me and ImageMagick is installed by default on most distributions.  A quick read through the ImageMagick manpage and I found the convert command and thought I’d share it with everyone.  Use convert in the following fashion:  convert [input-options] input-file [output-options] output-file

convert SMFPress.png -channel Alpha -threshold 80% -resize 120x120 thumbnail.gif

This did a quick, same-size conversion with little loss for me to display the thumbnail online.  For more information on the options I used and other options that I didn’t use, take a peek at the ImageMagick Online Help Page for convert.

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.

About

devnet has been a project manager for a Fortune 500 company, a Unix administrator, a Technical Writer, and a System Analyst during his 10 years working with Technology.

  • doug

    I love convert. Very handy for changing file types, but I’ve gotten a lot of use out of it for batch resize jobs.

    • http://linux-blog.org devnet

      It’s funny…when you use KDE and Gnome a lot you forget about many of these command line options that are just VERY powerful and quick. I had totally forgotten about convert and you’re 100% right…it’s handy in batch jobs as well :) Very handy for script writing :P

  • http://fosslib.tsakf.net tsakf

    A very interesting article that has been added to my library.
    http://fosslib.tsakf.net/record/279

  • http://fosslib.tsakf.net tsakf

    Thanks for the sections info!

  • http://www.wegif.com/ weGIF

    a very informative article and i really wanted to learn more from you….. well i am aslo in this obviously, and i usually do this on http://www.wegif.com/
    Gif Photo Animation

  • http://web2linux.com Web2Linux.com

    Nice article.. Thanks for sharing this with us :)

  • http://pramonotunggul.com Pramono

    Nice info, thanks for sharing.
    Can it be used to convert other kind of image extension, maybe “.xwd” just say it to “.jpg”?

    regards,

    PramonoTunggul.com
    .-= Pramono´s last blog ..Installing wordpress. =-.

  • http://wesleybailey.com wes

    I’ve always used mogrify -format jpg tux.png or mogrify -resize tux.jpg 120×120, also from the
    ImageMagick package. This saves an extra step, thanks for pointing out this command.

  • http://arvinlinux.blogspot.com/ Linux tips

    Its nice, this is Very use full for changing file types, more over I will get a lot of use out of it for batch resize jobs…