Jump to content

Converting a txt file into GIF file


zak100

Recommended Posts

Hi,

I want to create a GIF file from a text file of 500 x 500 dimensions.

I got some help to create the following program which works fine but I have not tried it for text file. Also how I can add the 500 x 500 dimension. My code is:

 

import imageio

images = []
filenames = ["one.jpeg", "two.png", "three.png"]
for filename in filenames:
    images.append(imageio.imread(f'./images/{filename}'))
    #imageio.
imageio.mimsave('./images/movie.gif', images)

Somebody please guide me.

 

Zulfi.

Link to comment
Share on other sites

1 minute ago, zak100 said:

I want to create a GIF file from a text file of 500 x 500 dimensions.

It is not clear what this means. (Clearly specifying what you want to do is 90% of the work in programming; the rest is just syntax.)

What is the text file? In other words, what does it contain?

How does it relate to the image file you want to create?

Is 500x500 measured in pixels or some other units?

4 minutes ago, zak100 said:

I got some help to create the following program which works fine but I have not tried it for text file.

That program appears to read several gif files and combine them in one. I can't see how this is related to your initial description of what you want to do.

Quote

Also how I can add the 500 x 500 dimension.

it depends. Are you using mages that are already this size? Are you scaling an existing image to this size? Are you creating a new image of this size?

Link to comment
Share on other sites

10 minutes ago, zak100 said:

I want to create a GIF file from a text file of 500 x 500 dimensions.

Are you required to use some specific programming language? Does any restrictions regarding libraries, packages etc apply? 

(I guess python may be used)

Link to comment
Share on other sites

Hi,

I have a text file created on notepad. I want to convert it into GIF. I found the following link:

Converting text to gif

 

But the problem is that I can't specify the image resolution in the above link. It works great. I tried paint but it does not accept text file. My visio is very old and I am not satisfied with the quality of gif created by this 2003 version. 

So I am thinking to write my own converter. Is it possible?

Quote

Are you required to use some specific programming language? Does any restrictions regarding libraries, packages etc apply?

Not really, its my personal task. But I want to prefer Python at this point as I am studying this right now.

Zulfi.

Edited by zak100
Link to comment
Share on other sites

18 minutes ago, zak100 said:

So I am thinking to write my own converter. Is it possible?

Yes.

But personally I would not bother. 

18 minutes ago, zak100 said:

I tried paint but it does not accept text file

Why not create a 500x500 pixels picture in Paint and then paste the text using paint's Text tool?

image.png.30285838f2c35bd4d74ce3da11c5757b.png

 

If you absolutely have to create a program, can you use something like pillow* and ImageDraw?. Pseudo code, untested:

from PIL import Image, ImageDraw
image = Image.new('RGB', (500, 500), color = (255, 255, 255))
drawer = ImageDraw.Draw(img)
drawer.text((10,10), "Content From TextFile", fill=(255,255,0))

 

https://pillow.readthedocs.io/en/stable/

Edited by Ghideon
format
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.