def instaPostStyle2MainProgram( titleText='AI DESIGN', fontTitlePath='Font-lib/Comfortaa/Comfortaa-SemiBold.ttf', subTitleText='Instant Design', fontSubTitlePath='Font-lib/Love_Ya_Like_A_Sister/LoveYaLikeASister-Regular.ttf', #'/Font-lib/Comfortaa/Comfortaa-SemiBold.ttf', logoAiDesign=None, logoMDC=None, logoYukShare=None, customLogo1=None, customLogo2=None, customHastagLogo=None, backgroundCategory=None, backgroundImage=None, ): # print('---------------') # print(fontTitlePath) # print('---------------') # print(fontSubTitlePath) if backgroundImage != '-- Pilih Kategori --': img = backgroundSelection(category=backgroundCategory).convert( 'RGB') #Select background from random image in a category elif backgroundImage: img = Image.open(backgroundImage) #there is 4 category City, Dawn, Dusk, Night # img = Image.open('/home/linkgish/Desktop/AiDesign_01/Image-lib/background-lib/City/city-wallpaper-27.jpg') #Import a single image as background #Converting PIL to OpenCV format (2 Dimension to 3 Dimensional Array) img = np.array(img) img = img[:, :, ::-1].copy() #Gamma correction using openCV gammaIs = whatsGamma(img) #Determine the number of gamma correction img = GammaCorrection(image=img, gamma=gammaIs) #Apply the gamma correction img_size = 2000 #Change the image size, so it will be better for uploading img = crop1x1_cv2( img, img_size) #Crop the image in square dimension using OpenCV # Convert OpenCV format to PIL format img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) img = Image.fromarray(img) #Done, now any further code is using PIL instead #Making the big text, and small text # maroon = '#FFA781' img = drawTitleStyle2( bigText=titleText, #"GEMPA BUMI", fontPath=os.path.abspath( fontTitlePath ), #'/home/linkgish/Desktop/AiDesign_01/Font-lib/Love_Ya_Like_A_Sister/LoveYaLikeASister-Regular.ttf', littleText=subTitleText, #'Hanya Peristiwa Alam?', subFontPath=os.path.abspath(fontSubTitlePath), imageSource=img, bigTextColor=randomMaterialColor( typeColor=LIGHTorDARK(image=img) ), #LIGHTorDARK(image=img),#, #selectColor(color='grey'), littleTextColor=randomMaterialColor(typeColor=LIGHTorDARK(image=img)), bigFontSize=1300, littleTextSize=500, ) # Draw the copyright section in the bottom right img = drawCopyright(image=img) # Draw some logo in a combination size islogoMDC = None if logoMDC == True: islogoMDC = drawMDClogo() islogoYukShare = None if logoYukShare == True: islogoYukShare = drawHashtag(hashTag='YUK SHARE') img = combineLogo( image=img, mdc=islogoMDC, logo1=islogoYukShare, # drawCustomLogo(logoPath=logo1Path), # logo2=drawCustomLogo(logoPath=logo2Path), # logo3=drawCustomLogo(logoPath=logo3Path), # instagram= drawIGaccount(instaAccount='@Rzf.Gsh'), hashTag=drawHashtag(hashTag='baik berisik'), # logo3= drawHashtag(hashTag='generasi tarbiyah'), targetHeight=int(img.size[1] / 15), isLight=True, ratioWidth=50, ratioHeight=80, ) # Drw socmed account left it None or Blank if there is no account img = drawAnotherSosmed( image=img, useOverlay=True, account_IG='Rzf.Gsh', account_FB='M Razif Rizqullah', # account_TELEGRAM='LinkGish', account_WA=None, account_LINE=None, account_WEB=None, # account_TWITTER = 'LinkGish', account_YOUTUBE=None, ratioHeight=2.5, # fontColor=(55,71,79), ) # Use time as a unique file name, so it will not be duplicated in the future nowTime = ctime() # Input variable of time into the string savePath = ( '/home/linkgish/Desktop/AiDesign_01/Result-lib/instaStyle2/Style2 {}.jpg' ).format(nowTime) img.save(savePath) print('Successfully saved at : ', savePath) # Notification while done img.thumbnail( (500, 500) ) # Just show thumbnail instead of full size image, because we should keep the quality img.show() #Show the result # instaPostStyle2MainProgram() # print(os.path.abspath('AiDesign_01/Font-lib/Comfortaa/Comfortaa-SemiBold.ttf'))
from Algorithm_BodyText import MakeBodyText from Algorithm_BackgroundManipulation import GammaCorrection, whatsGamma from Algorithm_Sosmed import drawIGaccount, drawAnotherSosmed, drawHashtag from Algorithm_backgroundSelection import backgroundSelection from Algorithm_CopyRight import drawCopyright from Algorithm_logoMaker import combineLogo, drawMDClogo, logoResizer from Algorithm_colorMaterial import LIGHTorDARK, randomMaterialColor img = backgroundSelection(category='Dusk').convert('RGB') img = np.array(img) img = img[:, :, ::-1].copy() gammaIs = whatsGamma(img) img = GammaCorrection(image=img, gamma=gammaIs) img_size = 2000 img = crop1x1_cv2(img,img_size) #Crop the image in square dimension img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) img = Image.fromarray(img) TITLE_TEXT = "Sayang-Nya," img = drawTitle(fontPath = '/home/linkgish/Desktop/WebApp2/GeneticDesignProject/Font-lib/Kaushan_Script/KaushanScript-Regular.ttf', fontSize = 400, # fontColor= randomMaterialColor(typeColor= LIGHTorDARK(image=img)), image=img, text = TITLE_TEXT, placeXratio = 50, placeYratio = 30, sizeWratio = 50, sizeHratio = 20, # blurRad=0, # shadowColor= LIGHTorDARK(image=img), # (0,0,0,200), )
import cv2 import numpy as np from Algorithm_Crop1x1 import crop1x1_cv2 from Histogram import BGRA_hist, Offset_hist, BW_hist, BGR_hist, Offset_histBGR img = cv2.imread( "/home/linkgish/Desktop/WebApp2/GeneticDesignProject/example.jpg", 1) img = crop1x1_cv2(img, 500) # BW_hist(img) img2 = cv2.imread( "/home/linkgish/Desktop/WebApp2/GeneticDesignProject/example3.jpg", 1) img2 = crop1x1_cv2(img2, 500) # BW_hist(img2) gamma = 2.5 lookUpTable = np.empty((1, 256), np.uint8) # print(lookUpTable) for i in range(256): lookUpTable[0, i] = np.clip(pow(i / 255.0, gamma) * 255.0, 0, 255) gamma2 = 2.5 lookUpTable2 = np.empty((1, 256), np.uint8) # print(lookUpTable2) for i in range(256): lookUpTable2[0, i] = np.clip(pow(i / 255.0, gamma2) * 255.0, 0, 255) res = cv2.LUT(img, lookUpTable) # BW_hist(res) res2 = cv2.LUT(img2, lookUpTable2) # BW_hist(res2) cv2.imshow('Original 1', img)