Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to complete this python function to save in the same folder?
    primarykey
    data
    text
    <p>I am trying to write my first real python function that does something real. What i want to accomplish is searching a given folder, and then open all images and merging them together so they make a filmstrip image. Imagine 5 images stacked on top of eachother in one image.</p> <p>I have this code now, which should be pretty much ok, but propably needs some modification:</p> <pre><code>import os import Image def filmstripOfImages(): imgpath = '/path/here/' files = glob.glob(imgpath + '*.jpg') imgwidth = files[0].size[0] imgheight = files[0].size[1] totalheight = imgheight * len(files) filename = 'filmstrip.jpg' filmstrip_url = imgpath + filename # Create the new image. The background doesn't have to be white white = (255,255,255) filmtripimage = Image.new('RGB',(imgwidth, totalheight),white) row = 0 for file in files: img = Image.open(file) left = 0 right = left + imgwidth upper = row*imgheight lower = upper + imgheight box = (left,upper,right,lower) row += 1 filmstripimage.paste(img, box) try: filmstripimage.save(filename, 'jpg', quality=90, optimize=1) except: filmstripimage.save(miniature_filename, 'jpg', quality=90)") </code></pre> <p>How do i modify this so that it saves the new filmstrip.jpg in the same directory as I loaded the images from? And it probably has some things that are missing or wrong, anybody got a clue?</p> <p>Related question: <a href="https://stackoverflow.com/questions/334827/how-to-generate-a-filmstrip-image-in-python-from-a-folder-of-images">How to generate a filmstrip image in python from a folder of images?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload