to git
|
Before Width: | Height: | Size: 217 KiB |
|
Before Width: | Height: | Size: 218 KiB |
|
Before Width: | Height: | Size: 219 KiB After Width: | Height: | Size: 227 KiB |
|
Before Width: | Height: | Size: 220 KiB After Width: | Height: | Size: 231 KiB |
@@ -2,6 +2,43 @@ from PIL import Image, ImageEnhance
|
||||
import os
|
||||
|
||||
|
||||
def split_string(string, max_chars_per_line):
|
||||
words = string.split()
|
||||
lines = []
|
||||
current_line = ""
|
||||
for word in words:
|
||||
if len(current_line + " " + word) > max_chars_per_line:
|
||||
lines.append(current_line.strip())
|
||||
current_line = ""
|
||||
current_line += " " + word
|
||||
if current_line:
|
||||
lines.append(current_line.strip())
|
||||
|
||||
# Re-combine lines to achieve even distribution of words
|
||||
num_lines = len(lines)
|
||||
if num_lines > 1:
|
||||
total_words = len(words)
|
||||
ideal_words_per_line = (total_words + num_lines - 1) // num_lines
|
||||
excess_words = total_words - ideal_words_per_line * (num_lines - 1)
|
||||
|
||||
even_lines = []
|
||||
i = 0
|
||||
while i < num_lines - 1:
|
||||
line_words = words[:ideal_words_per_line]
|
||||
if excess_words > 0:
|
||||
line_words.append(words[ideal_words_per_line])
|
||||
excess_words -= 1
|
||||
words.pop(ideal_words_per_line)
|
||||
even_lines.append(" ".join(line_words))
|
||||
words = words[ideal_words_per_line:]
|
||||
i += 1
|
||||
even_lines.append(" ".join(words))
|
||||
return "\n".join(even_lines)
|
||||
else:
|
||||
return lines[0]
|
||||
|
||||
|
||||
|
||||
def darken_images(images_folder, output_folder):
|
||||
# Set desired darkness
|
||||
dark = 0.5
|
||||
|
||||
22
main.py
@@ -2,18 +2,26 @@ import post_handler
|
||||
import helper_images
|
||||
|
||||
# Define the paths and values to everything
|
||||
number_of_posts = 2
|
||||
images_folder = "C:/Bots/ChristianPostMaker/sources/images/cropped/darken"
|
||||
number_of_posts = 119
|
||||
images_folder = "C:/Bots/ChristianPostMaker/sources/images"
|
||||
images_folder_cropped = f"{images_folder}/cropped"
|
||||
images_folder_cropped_darken = f"{images_folder_cropped}/darken"
|
||||
text_file = "C:/Bots/ChristianPostMaker/sources/quotes.txt"
|
||||
font_dir = "C:/Users/samla/AppData/Local/Microsoft/Windows/Fonts/MouldyCheeseRegular-WyMWG.ttf"
|
||||
output_folder = "C:/Bots/ChristianPostMaker/customers"
|
||||
logo_file = "C:/Bots/ChristianPostMaker/sources/logo.png"
|
||||
customer_name = "test1"
|
||||
customer_name = "no_logo"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# helper_images.cut_images(images_folder, f"{images_folder}/cropped")
|
||||
# helper_images.darken_images(images_folder, f"{images_folder}/darken")
|
||||
post_handler.create_posts(images_folder=images_folder, text_file=text_file,
|
||||
# helper_images.cut_images(images_folder, images_folder_cropped)
|
||||
# helper_images.darken_images(images_folder_cropped, images_folder_cropped_darken)
|
||||
# post_handler.create_posts(images_folder=images_folder_cropped_darken, text_file=text_file,
|
||||
# font_dir=font_dir, output_folder=output_folder,
|
||||
# logo_file=logo_file, customer_name=customer_name, number_of_posts=number_of_posts)
|
||||
|
||||
# No logo
|
||||
post_handler.create_posts(images_folder=images_folder_cropped_darken, text_file=text_file,
|
||||
font_dir=font_dir, output_folder=output_folder,
|
||||
logo_file=logo_file, customer_name=customer_name, number_of_posts=number_of_posts)
|
||||
customer_name=customer_name, number_of_posts=number_of_posts)
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import textwrap
|
||||
import time
|
||||
from string import ascii_letters
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageEnhance
|
||||
|
||||
import helper_images
|
||||
import json_handler
|
||||
|
||||
|
||||
@@ -29,7 +31,9 @@ def create_posts(images_folder, text_file, font_dir, output_folder, customer_nam
|
||||
# verses: str = json_data[0]
|
||||
# refs: str = json_data[1]
|
||||
|
||||
quotes = ["test1", "test2"]
|
||||
# Read the text file into a list of lines
|
||||
with open(text_file, 'r', encoding='utf-8') as file:
|
||||
quotes = file.readlines()
|
||||
|
||||
|
||||
# Get list of photos in the specified folder and shuffle it
|
||||
@@ -53,7 +57,13 @@ def create_posts(images_folder, text_file, font_dir, output_folder, customer_nam
|
||||
random_image_num = image_num[0]
|
||||
del image_num[0]
|
||||
image_file = image_files[random_image_num]
|
||||
file_name = f"/{i}-{random_image_num}.jpg"
|
||||
|
||||
image_license = image_file.split('/')
|
||||
image_license = image_license[len(image_license)-1]
|
||||
image_license = image_license.split('-')
|
||||
image_license = image_license[len(image_license)-1].rstrip(".jpg")
|
||||
|
||||
file_name = f"/{i}-{image_license}.jpg"
|
||||
create_post(image_file=image_file, text=text,
|
||||
font_dir=font_dir, output_path=output_path, file_name=file_name,
|
||||
logo_file=logo_file, customer_name=customer_name)
|
||||
@@ -86,14 +96,14 @@ def create_post(image_file, text, font_dir, output_path, file_name, logo_file, c
|
||||
# Define our text:
|
||||
# Calculate the average length of a single character of our font.
|
||||
# Note: this takes into account the specific font and font size.
|
||||
avg_char_width = sum(font.getsize(char)[0] for char in ascii_letters) / len(ascii_letters)
|
||||
# avg_char_width = sum(font.getsize(char)[0] for char in ascii_letters) / len(ascii_letters)
|
||||
|
||||
# Translate this average length into a character count
|
||||
max_char_count = int(img.size[0] * .718 / avg_char_width)
|
||||
|
||||
# max_char_count = int(img.size[0] / avg_char_width)
|
||||
max_char_count = 25
|
||||
# Create a wrapped text object using scaled character count
|
||||
new_text = textwrap.fill(text=text, width=max_char_count)
|
||||
|
||||
# new_text = helper_images.split_string(text, max_char_count)
|
||||
# Define the positions of logo and text
|
||||
x_logo = 0
|
||||
y_logo = 1100
|
||||
@@ -104,7 +114,7 @@ def create_post(image_file, text, font_dir, output_path, file_name, logo_file, c
|
||||
# Draw the shadow text
|
||||
shadow_color = (0, 0, 0, 128)
|
||||
shadow_position = (x_text+5, y_text+5)
|
||||
draw.text(shadow_position, text, font=font, fill=shadow_color, anchor='mm')
|
||||
draw.text(shadow_position, new_text, font=font, fill=shadow_color, anchor='mm', align='center')
|
||||
|
||||
# Add main text to the image
|
||||
draw.text(position, text=new_text, font=font, fill=(255, 255, 255, 255), anchor='mm',
|
||||
@@ -115,7 +125,7 @@ def create_post(image_file, text, font_dir, output_path, file_name, logo_file, c
|
||||
img_logo = Image.open(logo_file)
|
||||
|
||||
# Reduce the alpha of the overlay image by 50%
|
||||
alpha = 0.5
|
||||
alpha = 0.7
|
||||
enhancer = ImageEnhance.Brightness(img_logo)
|
||||
img_logo_darken = enhancer.enhance(alpha)
|
||||
|
||||
@@ -131,6 +141,8 @@ def create_post(image_file, text, font_dir, output_path, file_name, logo_file, c
|
||||
# Convert from RGBA to RGB
|
||||
img_with_logo_rgb = img_with_logo.convert("RGB")
|
||||
|
||||
file_name
|
||||
|
||||
# Save the image
|
||||
img_with_logo_rgb.save(f"{output_path}/{file_name}")
|
||||
# combined.show()
|
||||
|
||||
BIN
sources/fiverr/AD_Feed_Light.png
Normal file
|
After Width: | Height: | Size: 742 KiB |
BIN
sources/fiverr/AD_Feed_Light2.png
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
sources/fiverr/fiver pic1.psd
Normal file
BIN
sources/fiverr/fiverr banner1.png
Normal file
|
After Width: | Height: | Size: 735 KiB |
BIN
sources/fiverr/fiverr pic2 - Copy.psd
Normal file
BIN
sources/fiverr/fiverr pic2 copy.png
Normal file
|
After Width: | Height: | Size: 288 KiB |
BIN
sources/fiverr/fiverr pic2 with socials.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
sources/fiverr/fiverr pic2.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
sources/fiverr/fiverr pic2.psd
Normal file
BIN
sources/fiverr/fiverr_banner.psd
Normal file
BIN
sources/fiverr/promotion_video.mp4
Normal file
BIN
sources/fiverr/promotion_video/62-1Peter122_52_25_20_Moment.jpg
Normal file
|
After Width: | Height: | Size: 2.1 MiB |
|
After Width: | Height: | Size: 2.0 MiB |
BIN
sources/fiverr/promotion_video/83-Proverbs817_19_10_0_Moment.jpg
Normal file
|
After Width: | Height: | Size: 2.4 MiB |
BIN
sources/fiverr/promotion_video/AD_Instagram_Template_2021.zip
Normal file
BIN
sources/fiverr/promotion_video/AD_Instagram_Template_2021/NEW Version 2021/.DS_Store
vendored
Normal file
BIN
sources/fiverr/promotion_video/AD_Instagram_Template_2021/NEW Version 2021/Dark/.DS_Store
vendored
Normal file
BIN
sources/fiverr/promotion_video/AD_Instagram_Template_2021/NEW Version 2021/Light/.DS_Store
vendored
Normal file
BIN
sources/fiverr/promotion_video/fiverr_banner.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
sources/fiverr/promotion_video/fiverr_banner_no_phone.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
sources/fiverr/promotion_video/free-sample.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
sources/fiverr/promotion_video/phone mockp.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
sources/fiverr/promotion_video/promotion switching vids/1.mp4
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\ProgramData\TechSmith\Camtasia\Icons\ProjectFolder.ico,0
|
||||
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
BIN
sources/fiverr/promotion_video/promotion_video.tscproj/1.mp4
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\ProgramData\TechSmith\Camtasia\Icons\ProjectFolder.ico,0
|
||||
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
BIN
sources/fiverr/promotion_video/yellow_background.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 306 KiB |
|
Before Width: | Height: | Size: 215 KiB |
|
After Width: | Height: | Size: 198 KiB |
BIN
sources/images/cropped/darken/pexels-aron-visuals-1643113.jpg
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
sources/images/cropped/darken/pexels-aron-visuals-1743165.jpg
Normal file
|
After Width: | Height: | Size: 132 KiB |
BIN
sources/images/cropped/darken/pexels-artem-saranin-1496373.jpg
Normal file
|
After Width: | Height: | Size: 246 KiB |
BIN
sources/images/cropped/darken/pexels-arın-turkay-2591408.jpg
Normal file
|
After Width: | Height: | Size: 176 KiB |
BIN
sources/images/cropped/darken/pexels-disha-sheta-3584430.jpg
Normal file
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 158 KiB |
|
After Width: | Height: | Size: 237 KiB |
|
After Width: | Height: | Size: 242 KiB |
BIN
sources/images/cropped/darken/pexels-edou-hoekstra-3756718.jpg
Normal file
|
After Width: | Height: | Size: 196 KiB |
|
After Width: | Height: | Size: 341 KiB |
BIN
sources/images/cropped/darken/pexels-ian-beckley-2440021.jpg
Normal file
|
After Width: | Height: | Size: 190 KiB |
BIN
sources/images/cropped/darken/pexels-jacob-colvin-1761279.jpg
Normal file
|
After Width: | Height: | Size: 353 KiB |
BIN
sources/images/cropped/darken/pexels-jaime-reimer-2662116.jpg
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
sources/images/cropped/darken/pexels-jeremy-bishop-2524874.jpg
Normal file
|
After Width: | Height: | Size: 113 KiB |
BIN
sources/images/cropped/darken/pexels-jeremy-bishop-3464632.jpg
Normal file
|
After Width: | Height: | Size: 215 KiB |