Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6166211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:17:57+00:00 2026-05-23T22:17:57+00:00

How do I create a .gif file from the following HEX stream: 0d 0a

  • 0

How do I create a .gif file from the following HEX stream:

0d 0a 0d 0a 47 49 46 38 39 61 01 00 01 00 80 ff 00 ff ff ff 00 00 00 2c 00 00 00 00 01 00 01 00 00 02 02 44 01 00 3b

3b is the GIF file terminator

I’m trying to do it following the guide at http://en.wikipedia.org/wiki/Graphics_Interchange_Format#Example_GIF_file

I’d like to implement this in either Perl or C/C++. Any language will do though.

Many thanks in advance,


Thanks guys for all the replies. I removed the leading ‘0d 0a 0d 0a’…

Here’s what I have sofar:

#!/usr/bin/perl
use strict;
use warnings;

open(IN,"<test.txt");
open(OUT,">test.gif");

my @lines=<IN>;

foreach my $line (@lines){
        $line=~s/\n//g;
        my @bytes=split(/ /,$line);
        foreach my $byte (@bytes){
                print OUT $byte;
        }
}
close(OUT);
close(IN);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:17:58+00:00Added an answer on May 23, 2026 at 10:17 pm

    You can do it in the shell, using GNU echo:

    $ /bin/echo -n -e "\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\xff\x00\xff\xff\xff\x00\x00\x00\x2c\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3b" > foo.gif
    
    $ identify foo.gif
    foo.gif GIF 1x1 1x1+0+0 8-bit PseudoClass 2c 36B 0.000u 0:00.000
    

    You can also use the xxd command which will “make a hexdump or do the reverse”. Annoyingly, however, it seems very picky about the input format. Here’s an example using xxd:

    $ cat > mygif.hex <<END
    0000000: 4749 4638 3961 0100 0100 80ff 00ff ffff
    0000010: 0000 002c 0000 0000 0100 0100 0002 0244
    0000020: 0100 3b0a
    END
    
    $ xxd -r < mygif.hex > mygif.gif
    

    gvim has an interface to xxd. Use the “Tools → Convert To Hex” menu option (keyboard: :%!xxd) and then “Tools → Convert Back” (:%!xxd -r).

    EMACS also has a built-in hex editor, which is accessed by M-x hexl-mode (see Editing Binary Files in the manual). It’s also a little bit annoying, because you have to type C-M-x (i.e. Ctrl-Meta-X) before entering a character by its hex code:

    EMACS hexl-mode

    Of course, it is very easy to write a simple C program to do the conversion:

    #include <stdio.h>
    
    int main(int argc, char **argv) {
      unsigned int c;
      while (1 == scanf("%x", &c))
        putchar(c);
      return 0;
    }
    

    usage:

    $ gcc -Wall unhexify.c -o unhexify
    $ echo  "47 49 46 38 39 61 01 00 01 00 80 ff 
             00 ff ff ff 00 00 00 2c 00 00 00 00 
             01 00 01 00 00 02 02 44 01 00 3b" | ./unhexify > mygif.gif
    

    Also: many answers here in this code golf question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I create an animated .gif file from a movie I have? I
How do you create a .cur (for a mouse cursor), from a GIF image
I have successfully used the following command line to create a new GIF image
I have the following rake file to create a static version of my sinatra
I get the following error message when from a script I'm using to create
Create a flat text file in c++ around 50 - 100 MB with the
Create a file called Valid[File].txt and stick some text in it. Start powershell and
It has come to my attention that a user has been trying to create
I'm trying to create a simple RSS reader with Phonegap and jQuery. I am
I want to download a file from server to a local host. i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.