Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2024
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import requests
  2. from PIL import Image
  3. from io import BytesIO
  4.  
  5. # Updated base URL and suffix for the new set of images
  6. base_url = "https://vexgateway.fastly.carvana.io/executions/105356595/FLOOR_CLEANER/cleaned/clean_"
  7. url_suffix = ".jpg?v=1705586461.054&crop=60.79p,51.29p,x18.27p,y29.79p&quality=75&optimize=medium&width=2000"
  8.  
  9. images = []
  10.  
  11. # Download images and provide console output
  12. for i in range(1, 64): # There are 63 images
  13. url = f"{base_url}{str(i).zfill(3)}{url_suffix}"
  14. print(f"Downloading image {i}...")
  15. response = requests.get(url)
  16.  
  17. if response.status_code == 200:
  18. images.append(Image.open(BytesIO(response.content)))
  19. print(f"Image {i} downloaded successfully.")
  20. else:
  21. print(f"Failed to download image {i}")
  22.  
  23. # Create GIF and provide console output
  24. if images:
  25. gif_filename = "output.gif"
  26. print("Creating GIF...")
  27. images[0].save(
  28. gif_filename,
  29. save_all=True,
  30. append_images=images[1:],
  31. duration=100, # duration between frames in milliseconds
  32. loop=0 # loop forever
  33. )
  34. print(f"GIF created successfully: {gif_filename}")
  35. else:
  36. print("No images to create GIF.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement