from Algorithm_Crop1x1 import crop1x1_cv2
# from Histogram import BGRA_hist, Offset_hist, BW_hist, BGR_hist, Offset_histBGR
from Algorithm_Text import TextDrawShade, drawTitle
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,
Esempio n. 2
0
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'))
Esempio n. 3
0
scale = 1000

bannerX, bannerY = bannerX*scale, bannerY*scale

# Making canvas for banner 
banner = Image.new('RGBA', (bannerX,bannerY), color=(222,222,222,255))
# Make gradient color for overlay color
gradOverlay = makeGradientImage(width=bannerX,
                            height=bannerY,
                            # initialR=100,
                            # initialG=100,
                            # initialB=20,
                            ) # This is PIL
gradOverlay = PILtoCV2(image=gradOverlay)
gradOverlay = GammaCorrection(image=gradOverlay,
                            gamma=0.3,
                            ) # This is cv2
gradOverlay = CV2toPIL(image=gradOverlay).convert('RGBA')
# gradOverlay.show()
# banner.paste(gradOverlay,(0,0),gradOverlay)
# Paste transparent image as mask
banner = pasteTransparentImage(image=banner,
                        overlayImage= backgroundSelection(category='City'),
                        percentTransparency=50)

# Paste Overlay image as transparency mask
banner = pasteTransparentImage(image=banner,
                        overlayImage=gradOverlay,
                        percentTransparency=50)
# Make banner main title
banner = drawBannerTitle(image=banner,
Esempio n. 4
0
from Algorithm_backgroundSelection import backgroundSelection
from Algorithm_Crop1x1 import crop1x1_cv2
from Algorithm_BackgroundManipulation import GammaCorrection, whatsGamma
from Algorithm_drawTitleStyle2 import drawTitleStyle2
from AlgorithmcolorMaterial import random2MaterialColor, selectColor
from Algorithm_Sosmed import drawHashtag, drawIGaccount, drawAnotherSosmed
from Algorithm_CopyRight import drawCopyright
from Algorithm_logoMaker import combineLogo, drawMDClogo, logoResizer


img = backgroundSelection(category='Nature').convert('RGB')
# img = Image.open('/home/linkgish/Desktop/WebApp2/GeneticDesignProject/Image-lib/background-lib/City/city-wallpaper-27.jpg')
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)

#Making the text
img = drawTitleStyle2(bigText="Lebih dari ini",
                        littleText='pernah kita lalui',
                        imageSource=img,
                        bigTextColor=(255,255,255,255), #selectColor(color='grey'),
                        littleTextColor=(255,224,130),
                        bigFontSize=1300,
                        littleTextSize=500,
                        )