Cropping *.Gif Images.

Art tutorials only please. Anything else will be moved into Art & Signatures

Cropping *.Gif Images.

Postby Xerxes on Sun Jan 31, 2010 4:46 am

Prerequisites; ImageMagick installation. See here for installation instructions.

So, we want to get a gif that's an odd size cut down to something signature friendly, or remove some unsightly part of it. Easily done with ImageMagick, so let's go through the steps:

    1. Find your image. For this example we will use the following (by Mattthesamurai), renamed as "GifExample.gif".


    2. Save it somewhere easy to navigate to, like the Desktop.

    3. Open up the command line by going to "start..." --> "run..." and typing in "cmd", then press enter. On Vista/7 you can just type "cmd" in the search bar to start it. For help on other platforms, consult the IM documentation. Navigate to the location you saved the image to. For the desktop, just type "cd desktop" to get to that directory.

    4. Now, you need to work out how much you want to remove. Think of this like a window that the gif will be seen through; anything outside the window will be lost. So, either guess or work out how large the dimensions of the window should be, and the displacement (offset of location) for the window. Don't worry if this is the wrong size (in terms of pixels) for what you finally want as long as it's the content you want to keep in the right aspect- we can resize later.

    In this example I want to grab the red area demonstrated below. This corresponds to 455 pixels in width and 182 in height. The displacement of this is +0 pixels in the X direction (from left to right) and +259 in the Y direction (up and down). Note that the displacement is specified from the top left of the image and right and down are always positive values.


    5. Right, so we have the things we need, let's remove the parts we don't want:
      Generic command!
    convert <input>.gif -crop <X>x<Y>+<X Displacement>+<Y Displacement> -trim +repage <output>.gif

    Where <input> is the input image, <X> is the width of the window, <Y> is the height of the window, <X Displacement> is the offset in width, <Y Displacement> is the offset in height and <Output> is some output name.

    For our example it looks like:
    convert gifexample.gif -crop 455x182+0+259 -trim +repage gifexample2.gif

    As we are cropping to a window of 455 pixels by 182, with an offset of +0 pixels in X and +259 in the Y direction.

    So we get:

    Great! It's trimmed everything like we wanted and it's retained the image as a gif at the same framerate as the original image. If you have it the size you want already, you're done. If you want to resize, you can do so with the resizing gifs tutorial.

I hope this helps you with your signature image hunting! :)

User avatar
UKCS Vice President
UKCS iSeries Attendee
Player: Xerxes
Posts: 10573
Joined: Wed Jul 09, 2008 10:30 pm

Re: Cropping *.Gif Images.

Postby kan on Fri Feb 05, 2010 12:12 am

Big help this with my sigs.... I know it looks complicated at first glance but well worth it.

Cheers Xerxes.

Huge thanks to Xerxes for the sig :)
User avatar
Executive Admin
Senior Moderator
UKCS iSeries Attendee
Player: Cake =^o.o^=
Posts: 4127
Joined: Sat Mar 22, 2008 12:35 pm
Location: Living room, near fire but not close enough to burn


Re: Cropping *.Gif Images.

Postby n0rd on Wed Feb 10, 2010 6:41 pm

soooo nice tutorials xer! I just had this problem and frying tipped me of this guide thanks! :D
Feel free to ask questions - n0rd|UKCS| Image / Image
User avatar
UKCS Sponsor
Player: n0rd
Posts: 5065
Joined: Tue Oct 28, 2008 1:46 pm
Location: Sweden, Örebro, Chewbaccastan


Return to Art Tutorials

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests