Nicolás Medina
Nicolás Medina

Reputation: 59

Upload vertical images to instagram using Python

I'm taking the risk to be marked as duplicated with this question. I wanted to know if there's a way to upload vertical images using the instabot library. So far I used the following code to upload images to an IG account:

from instabot import Bot 

username = "dosisdelpasado"
password = "**************"
image_path = "path/path"
caption = "aun sigo testeando"

bot = Bot() 
bot.login(username=username, password=password) 

result = bot.upload_photo(image_path,caption= caption)

The main issue is that instabot doesn't distinguish between vertical-oriented and horizontal-oriented images, and assume that all of them are vertical images. Digging a little bit in the source code, I came to this function defined inside api_phot.py, which seems to identify the pixel size of the image, as get_image_size(fname) and compatible_aspect_ratio(size), but after a while of playing with the code, I didn't solve this annoying problem.

Will be really useful if you can help me with this issue. Thanks in advance for your time!!

Upvotes: 2

Views: 440

Answers (1)

Siddhesh Agarwal
Siddhesh Agarwal

Reputation: 189

Rather than using the "instabot" library, try using "instapy_cli". Here is what the code would look like:

from instapy_cli import client

username = "dosisdelpasado"
password = "**************"
image_path = "path/path"
caption = "aun sigo testeando"
 
with client(username, password) as bot:
    bot.upload(image_path, caption)

Upvotes: 2

Related Questions