Convert text file to image

I have this text file that contains the binary code for a photograph. I'm trying to convert it to a movie file through my Unix command line, but it's not working.

So I've tried
<IMG.txt >

but that didn't work– it only created a blank file.

I don't know a lot about doing this sort of thing through the command line, so does anyone know of a way to do it?

I'm using the Terminal application on Mac OS X High Sierra.


Is there a sort of copy command or something like that for Unix?
Last edited on
What is the format of the input file? What format do you want the output video file to be? Do you want it be the same resolution as the photograph, or cropped/extended to a particular aspect ratio/resolution? What should the duration of the output video file be?

For command-line image/video-editing tools, look into ffmpeg.

Is there a sort of copy command or something like that for Unix?
Last edited on
The input file is .txt, but it's binary code, so that doesn't mean much.

Oops! I meant to say convert it to image. It's just an image's binary code.

I figured the formatting and aspect ratio would be in the binary code...?

ffmpeg, ok, I'll look into it.

Oh, ok. Thanks!
Last edited on
The extension of the filename doesn't matter as far as the content of the file is concerned. If the content of the file is an image format (JPEG, or PNG, etc.), then it's an image, full stop.

If you want your file explorer or what have you to correctly do things like preview or open the file in your default photo viewer, then your original idea of copying to a new name or renaming the file is what you want.
Last edited on
This is how I interpret your monumentally clear request:
1. There is a file of yours called xyz.txt
2. If the file is simply renamed xyz.bmp it represents a normal picture file as a normal .bmp file. (The .txt suffix is accidental (or whatever))
3. Using the Terminal app (only) on a Mac you want to display the picture.

1. Open Terminal
2. cd to the folder containing the xyz.txt file
(Use the ls command to verify that the location is correct)
3. mv xyz.txt xyz.bmp i.e rename file
4. open -a preview xyz.bmp xyz picture will then be displayed in Preview
Ok, makes sense. That's what I thought, because I've seen it mentioned on a thread a while back, too.

Thanks! I'll try that and see if it works.

Hey, it worked! Thanks!

I tried both cp and mv, and they both worked– I had to look them up to figure out how to use them correctly, but they worked!

Thanks, guys!
Last edited on
mac should let you do this from the gui file view too.
windows, f2 solves it.
I'm actually working on an application that will take a text file (or whatever file you drop into it) and "convert it to an image" i.e. change the extension to .jpg or .png or something like that.

Mac has an application for doing this called Automator; so ironically, I'll be making an application with an application!
Topic archived. No new replies allowed.