0

I'm facing a feature that I'm not able to do after looking at some tutorials, with several way of doing it. So it's a project in Python. As you can see below I have some images that are located in some folders.

What I would like to do is to combine/merge the images that are located in a folder in only one image, for each folder. So 001.jpg, 002.jpg, 003.jpg, 004.jpg inside folder 0 needs to be merged as 0-merged.png. I'm putting the output image as a .png because my images are really long vertically, and jpg have a maximum size. For info, the width of my images are always the same, only the height is not.

Then do the same for all others folders.

.
├── 0
├─────001.jpg
├─────002.jpg
├─────003.jpg
├─────004.jpg
├── 1
├─────001.jpg
├─────002.jpg
├─────003.jpg
├── 2
├─────001.jpg
├─────002.jpg
├─────003.jpg
├─────004.jpg
└─────005.jpg

I have tried a lot of stuff found on internet, for example Numpy, imageio, imagemagick (output png is way too big), etc. But I couldn't make it work properly...

If someone can help that would be great :)

Thanks ! Btv-

Chris
  • 15,819
  • 3
  • 24
  • 37
bientavu
  • 23
  • 3
  • 1
    Does this answer your question? [Combine several images horizontally with Python](https://stackoverflow.com/questions/30227466/combine-several-images-horizontally-with-python) – Chris Sep 21 '22 at 13:52
  • How do you want to combine them -- horizontally, vertically, layered? Please show your attempt in Imagemagick. For Imagemagick you would loop over each directory and get every JPG image in the directory and then use, say, -append or montage. – fmw42 Sep 21 '22 at 16:50
  • @Chris, I found your link right after posting my message... sorry about that. I changed the code a little bit to make it work for vertical alignment and it's working great ! Only issue is that I still have an heavy png image of around 120MB for an height of 180,000 px. If you guys have an easy solution to reduce the size, it would be amazing ! For fmw42 : I tried this way but wasn't able to make it work with the loop. Anyway thanks ! – bientavu Sep 21 '22 at 17:32

0 Answers0