Closed VickiLanger closed 3 years ago
Is there any difference between the images named "{no}" and images named "{no}+a" ? Why don't they all have the same naming syntax?
@Ares358 There is no difference. I took the easiest way I could think of when renaming them all at once. I should've named them all the same
I think this issue was resolved after PR #100 and can be closed now.
@JasirZaeem The PR definitely addressed the issue. It's throwing an error though and I haven't had a chance to check it out.
2020-10-14T00:02:38.345206+00:00 app[scheduler.4247]: ModuleNotFoundError: No module named 'PIL'```
@JasirZaeem The PR definitely addressed the issue. It's throwing an error though and I haven't had a chance to check it out.
2020-10-14T00:02:38.345206+00:00 app[scheduler.4247]: ModuleNotFoundError: No module named 'PIL'```
Installing Python Image Library via the command pip install Pillow
should solve it.
@JasirZaeem The PR definitely addressed the issue. It's throwing an error though and I haven't had a chance to check it out.
2020-10-14T00:02:38.345206+00:00 app[scheduler.4247]: ModuleNotFoundError: No module named 'PIL'```
PIL(pillow) is being used to write the tweets on images, the error says it's missing on the machine you tried running the bot on.
Using pip install Pillow
like @Ares358 suggested to install it should solve the issue.
I update pil
locally, but I don't run the bot from my computer. I run the bot using Heroku...
Nevermind, I figured out how to add it with the console in Heroku. I'll leave the issue open until I see it work
Okay, so, it still didn't work. that clearly wasn't the way to do it. I think I just need to update requirements.txt
Yes that might be the way to do it, https://devcenter.heroku.com/articles/python-pip this says so at least. I have only used Linux vpses for experimenting with things so don't have any experience with Heroku.
It was happy with my fix and now it's not happy again.
2020-10-15T00:02:01.850597+00:00 app[scheduler.4944]: File "/app/.heroku/python/lib/python3.6/site-packages/PIL/ImageFont.py", line 194, in __init__
2020-10-15T00:02:01.850748+00:00 app[scheduler.4944]: font, size, index, encoding, layout_engine=layout_engine
I think the problem might be missing fonts, at this line https://github.com/JasirZaeem/LGBTQ-of-the-day-bot/blob/60288208a79fbc2280d9f3317136731f6ae945f1/get_img_for_tweet.py#L82 and the one after, arial.ttf is used, on windows where I and the contributor who originally added the code used it, this would work, but this probably fails on heroku.
You'll have to upload arial.ttf, or some other font file, yourself, to use it. I don't have experience with heroku but this might be helpful http://stackoverflow.com/questions/57794602/using-ttf-font-file-in-pillow-within-a-django-app-hosted-on-heroku
Thank you so much @JasirZaeem. I had no clue you could link to a specific line. Neat.
Well, it still doesn't like it.
font_type = ImageFont.truetype('/assets/Nunito-Regular.ttf', 40)
font_type2 = ImageFont.truetype('/assets/Nunito-Regular.ttf', 40*2)
2020-10-16T12:00:22.737878+00:00 app[scheduler.1478]: font_type = ImageFont.truetype('/assets/Nunito-Regular.ttf', 40)
2020-10-16T12:00:22.737901+00:00 app[scheduler.1478]: File "/app/.heroku/python/lib/python3.6/site-packages/PIL/ImageFont.py", line 836, in truetype
2020-10-16T12:00:22.738235+00:00 app[scheduler.1478]: return freetype(font)
2020-10-16T12:00:22.738236+00:00 app[scheduler.1478]: File "/app/.heroku/python/lib/python3.6/site-packages/PIL/ImageFont.py", line 833, in freetype
2020-10-16T12:00:22.738581+00:00 app[scheduler.1478]: return FreeTypeFont(font, size, index, encoding, layout_engine)
2020-10-16T12:00:22.738582+00:00 app[scheduler.1478]: File "/app/.heroku/python/lib/python3.6/site-packages/PIL/ImageFont.py", line 194, in __init__
2020-10-16T12:00:22.738752+00:00 app[scheduler.1478]: font, size, index, encoding, layout_engine=layout_engine
2020-10-16T12:00:22.738756+00:00 app[scheduler.1478]: OSError: cannot open resource
Gonna try using PIL.ImageFont.load_default()
to see if that temporarily fixes it (reference) (another reference).
Okay, Images work. I'm gonna open a new issue for the font and work on that. Thank you both so much for your work and for helping me figure out the errors.
https://twitter.com/LgbtQotd/status/1317118324124299264?s=20
Issue #2 discussed generating images from text with the images in
img_bg
. Now that the images are generated withgenerateImagePost.py
, they need to be able to be tweeted withtweet.py
https://iq.opengenus.org/post-image-twitter-api/