from google.appengine.api import images def get_webp_url(image_url): # قم بتحميل الصورة من URL المعطى image_data = urllib.urlopen(image_url).read() # تحويل الصورة إلى WebP webp_data = images.resize(image_data, width=800, height=800, output_encoding=images.WEBP) # رفع الصورة المحولة إلى URL webp_url = blobstore.create_gs_key('/webp/' + image_url.split('/')[-1]).replace('/gs/', '/storage/') with files.open(webp_url, 'a') as f: f.write(webp_data) return images.get_serving_url(webp_url)