Stack Overflow Asked by Chloe Wong on January 5, 2022
Just wondering if someone might be able to point me in the right direction as I’m at complete loss of what’s happening (I’m a beginner so sorry if this is blaringly obvious!).
I’m writing some code to create a photomosaic. It requires resizing photos from a database and then concating images together to create a bigger picture.
The relevant code is as follows:
def resize(self):
path = "C:/Users/chloe/Desktop/Python_Stuffs/Robert_Heaton/landscape_images"
dirs = os.listdir(path)
new_path = Path(path, 'resized_pics')
new_path.mkdir(parents=True, exist_ok=True)
#etc.
def concat_rows(self):
path = "C:/Users/chloe/Desktop/Python_Stuffs/Robert_Heaton"
new_path_concat = Path(path, 'photomosaic_images_' + im_name)
new_path_concat.mkdir(parents=True, exist_ok=True)
counter = 0
for row in self.match_pixel_img:
im1_path = os.path.join(self.new_path,row.pop(0))
os.chdir(self.new_path)
im1 = Image.open(im1_path)
#etc.
In the function resize
I create a new directory with the new resized pictures in, and then in concat_rows
I take the resized images from the new directory and concat them. However, I’m getting this error:
File "C:UserschloeDesktopPython_StuffsRobert_Heatonphotomosaic.py", line 95, in concat_rows
im1 = Image.open(im1_path)
File "C:Userschloeanaconda3libsite-packagesPILImage.py", line 2878, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory:
'C:\Users\chloe\Desktop\Python_Stuffs\Robert_Heaton\landscape_images\resized_pics\'
even though this is the directory I created in resize
and I can SEE the directory in my files at that exact location. I’m using the fullpath so I’m really not sure what is wrong. Furthermore, when I run the code a second time it works fine so maybe it’s something to do with the way Python reads lines?
If anyone could shed some light I’d be really grateful!
5 Asked on February 11, 2021 by indian_trash
0 Asked on February 11, 2021 by barry-griffey
0 Asked on February 10, 2021 by swati
2 Asked on February 10, 2021 by obsidian
3 Asked on February 10, 2021 by aniket-ujgare
2 Asked on February 10, 2021 by user14955679
2 Asked on February 10, 2021 by peter-flanagan
4 Asked on February 10, 2021 by diego
2 Asked on February 10, 2021 by data_mind
2 Asked on February 10, 2021 by gremlinshx
0 Asked on February 10, 2021 by zachary-kennedy
0 Asked on February 10, 2021 by matheus-nascimento
1 Asked on February 10, 2021 by aamer-salame
2 Asked on February 10, 2021 by morimn
3 Asked on February 9, 2021 by doliphin
4 Asked on February 9, 2021 by osk6r
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP