Skip to content

Commit

Permalink
bugfix: story height resize
Browse files Browse the repository at this point in the history
  • Loading branch information
vltclz committed Feb 23, 2024
1 parent e080e28 commit efa4823
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions instagrapi/mixins/photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ class UploadPhotoMixin:
"""

def photo_rupload(
self, path: Path, upload_id: str = "", to_album: bool = False
self,
path: Path,
upload_id: str = "",
to_album: bool = False,
for_story: bool = False,
) -> tuple:
"""
Upload photo to Instagram
Expand All @@ -136,6 +140,8 @@ def photo_rupload(
upload_id: str, optional
Unique upload_id (String). When None, then generate automatically. Example from video.video_configure
to_album: bool, optional
for_story: bool, optional
Useful for resize util only
Returns
-------
Expand Down Expand Up @@ -174,7 +180,15 @@ def photo_rupload(
}
if to_album:
rupload_params["is_sidecar"] = "1"
photo_data, photo_size = prepare_image(str(path), max_side=1080)
if for_story:
photo_data, photo_size = prepare_image(
str(path),
max_side=1080,
aspect_ratios=(9 / 16, 90 / 47),
max_size=(1080, 1920),
)
else:
photo_data, photo_size = prepare_image(str(path), max_side=1080)
photo_len = str(len(photo_data))
headers = {
"Accept-Encoding": "gzip",
Expand Down Expand Up @@ -381,7 +395,7 @@ def photo_upload_to_story(
An object of Media class
"""
path = Path(path)
upload_id, width, height = self.photo_rupload(path, upload_id)
upload_id, width, height = self.photo_rupload(path, upload_id, for_story=True)
for attempt in range(10):
self.logger.debug(f"Attempt #{attempt} to configure Photo: {path}")
time.sleep(3)
Expand Down

0 comments on commit efa4823

Please sign in to comment.