How to add few pictures into one

L

Lad

Hello ,
is it possible to add( with PYTHON language) several image files into
one?
Thanks for reply
L.
 
K

K.S.Sreeram

Lad said:
Hello ,
is it possible to add( with PYTHON language) several image files into
one?

Google for 'Python Imaging Library'...

Regards
Sreeram



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEhCoTrgn0plK5qqURApwkAKCMlXC016OG4LJpQVpJOamatK+q6QCfQ9bR
MmrLXAD6JSh2aINEcrZRVds=
=W2Ow
-----END PGP SIGNATURE-----
 
L

Lad

K.S.Sreeram said:
Google for 'Python Imaging Library'...

Regards
Sreeram
Thank you for your reply.
I was thinking about this:
to open each image file in binary mode , read it and write into the
result image file?
Is that possible?
Regards,
L
 
S

Steve Holden

Lad said:
Thank you for your reply.
I was thinking about this:
to open each image file in binary mode , read it and write into the
result image file?
Is that possible?
Regards,
L
Of course, but what you haven't said yet is how you want the resulting
image file to behave. Do you want it to contain tiled copies of the
original images, or be an animation with each frame being one of the
original images, or something else I haven't thought of.

We aren't mind readers here.

though-some-regulars-get-close-ly y'rs - steve
 
L

Lad

Steve said:
Of course, but what you haven't said yet is how you want the resulting
image file to behave. Do you want it to contain tiled copies of the
original images, or be an animation with each frame being one of the
original images, or something else I haven't thought of.

We aren't mind readers here.

though-some-regulars-get-close-ly y'rs - steve
--
Steve
Thank you for your reply
All that I want is this:
I download ( via Python) some pictures from internet and I want to add
all these pictures into one =one file/
So far, I managed to download pictures but I do not know how to add i
them nto one file.
How can I do that?
Thank you for reply and help
L.
 
S

Steve Holden

Lad said:
Steve
Thank you for your reply
All that I want is this:
I download ( via Python) some pictures from internet and I want to add
all these pictures into one =one file/
So far, I managed to download pictures but I do not know how to add i
them nto one file.
How can I do that?
Thank you for reply and help
L.
Zip file? Image file? "Add all these pictures into one file" isn't (fro
me) a sufficient specification.

regards
Steve
 
L

Lad

Zip file? Image file? "Add all these pictures into one file" isn't (fro
me) a sufficient specification.

I want to to do that as easy as possible. I think the easest way could
be add( append) an image to another into an image file so that I can
use an image browser and see all pictures in one file.
Is that possible?
Thank you for reply
L.
 
B

bearophileHUGS

Lad said:
I want to to do that as easy as possible.

But not even more easy.

I think the easest way could be add( append) an image to another
into an image file so that I can use an image browser and see all
pictures in one file. Is that possible?

Well, you can do it with PIL, creating a very big white image and
putting on it all the images, as tiles.
But probably you want to do something different.
Maybe you can use PyUNO to create a PowerPoint-like (Presentation) file
with an image on each page.
If you are on Win another easy way is to create an Html page that shows
all the pics, open it with Explorer and save it as a single HMT file.
Probably there are other solutions.

Bye,
bearophile
 
L

Lad

But not even more easy.



Well, you can do it with PIL, creating a very big white image and
putting on it all the images, as tiles.
But probably you want to do something different.
Maybe you can use PyUNO to create a PowerPoint-like (Presentation) file
with an image on each page.
If you are on Win another easy way is to create an Html page that shows
all the pics, open it with Explorer and save it as a single HMT file.
Probably there are other solutions.

I was thinking about much less complicated task.
I thought about this:
Open a picture file( download it from internet) and write it in a
result file( being open in binary mode).
Then download another file and append to the result file.
And so on...
But is it possible? Will be the pictures in the result file seen
well??
regards,
L.
 
F

Fredrik Lundh

Lad said:
Open a picture file( download it from internet) and write it in a
result file( being open in binary mode).
Then download another file and append to the result file.
And so on...
But is it possible? Will be the pictures in the result file seen
well??

the internal structure of an image file is quite a bit more complicated
than the internal structure of a text file, so it's not very likely that
you would get very far with that approach.

why not just put all the files in a directory, and use an image viewer
with collage or slideshow support ?

</F>
 
L

Lad

Fredrik said:
the internal structure of an image file is quite a bit more complicated
than the internal structure of a text file, so it's not very likely that
you would get very far with that approach.

why not just put all the files in a directory, and use an image viewer
with collage or slideshow support ?
Fredrik,
Thank you for your reply.
I really would like to have ALL pictures in one file.
So, what would be the easiest/best way how to do that?
Thank you for your reply
regards,
L.
 
F

Fredrik Lundh

Lad said:
I really would like to have ALL pictures in one file.
So, what would be the easiest/best way how to do that?

do you want to look at the images as a slideshow or as a collage?

</F>
 
K

K.S.Sreeram

Lad said:
I really would like to have ALL pictures in one file.

import Image

def merge_images( input_files, output_file ) :
img_list = [Image.open(f) for f in input_files]
out_width = max( [img.size[0] for img in img_list] )
out_height = sum( [img.size[1] for img in img_list] )
out = Image.new( 'RGB', (out_width,out_height) )
y = 0
for img in img_list :
w,h = img.size
out.paste( img, (0,y,w,y+h) )
y += h
out.save( output_file )

Use like this:
merge_images( ['1.jpg','2.jpg','3.jpg'], 'output.jpg' )

Regards
Sreeram


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEhWhBrgn0plK5qqURAmPfAJ0cdYGpm5QCMWvjzNEEoC2hQDwWvgCeOdQ5
OPOPUAsQz3g7/ZKXf1opa0w=
=E9kT
-----END PGP SIGNATURE-----
 
L

Lad

K.S.Sreeram said:
Lad said:
I really would like to have ALL pictures in one file.

import Image

def merge_images( input_files, output_file ) :
img_list = [Image.open(f) for f in input_files]
out_width = max( [img.size[0] for img in img_list] )
out_height = sum( [img.size[1] for img in img_list] )
out = Image.new( 'RGB', (out_width,out_height) )
y = 0
for img in img_list :
w,h = img.size
out.paste( img, (0,y,w,y+h) )
y += h
out.save( output_file )

Use like this:
merge_images( ['1.jpg','2.jpg','3.jpg'], 'output.jpg' )

Regards
Sreeram,
Thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,301
Messages
2,571,549
Members
48,295
Latest member
JayKillian
Top