Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add caption to downloaded images #110

aseques opened this issue May 2, 2018 · 3 comments


Copy link

commented May 2, 2018

I want to stream my feed pictures in a bigger screen, so I would like to add the caption to the downloaded pictures. Is there such feature build in instaloader (couldn't find it in the docs), what would you recommend otherwise?

@aandergr aandergr added the question label May 8, 2018

This comment has been minimized.

Copy link

commented May 9, 2018

Instaloader does not modify the downloaded JPEG file. However, you could combine it with an imaging library such as Pillow or PIL to render the Post.caption on pictures. An approach could be

from io import BytesIO

from requests import get
from PIL import Image, ImageDraw
from instaloader import *

L = Instaloader()

# Load Post instance
post = load_structure_from_file(L.context, '2017-10-01_18-53-03_UTC.json.xz')
# or post = Post.from_shortcode(L.context, SHORTCODE)

# Render caption
image =
draw = ImageDraw.Draw(image)
draw.text((300,100), post.caption.encode('latin1', errors='ignore'))

# Save image'test.jpg')

However, this is just an approach. See e.g. for how to modify images with Python (there are plenty more libraries tough). Instaloader exports a picture's URL as Post.url and its caption as Post.caption.


This comment has been minimized.

Copy link

commented May 9, 2018

Thanks a lot, I'll try it and drop a comment.

@aseques aseques closed this May 9, 2018

This comment has been minimized.

Copy link

commented May 12, 2018

It helped me to get on track, only issue is that the deault color wasn't visible in my test picture.

color = 'rgb(0, 0, 0)'  # black color
draw.text((300,100), post.caption.encode('latin1', errors='ignore'), fill=color)
aandergr added a commit that referenced this issue Jun 4, 2018
Presents code examples that use the instaloader module for more advanced tasks
than what is possible with the Instaloader command line interface.

Presents #46, #56, #110, #113, #120, #121.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.