Exemple #1
0
    def createCardLayoutPreview(self):
        logging.debug("createCardLayoutPreview")

        logging.debug(self.layout[0])
        logging.debug(self.layout[0].piccount)

        # Load Preview Pics
        for i in range(0, self.layout[0].piccount):
            logging.debug(self.layout[0].picture[i])
            self.layout[0].picture[i].img = image(
                filename = os.path.join(REAL_PATH, 'Media/demo' + str(i + 1) + '.jpg'))
            self.layout[0].picture[i].ProcessImage()


        # Load Preview Pics
        for i in range(0, self.layout[1].piccount):
            logging.debug(self.layout[1].picture[i])
            self.layout[1].picture[i].img = image(
                filename = os.path.join(REAL_PATH, 'Media/demo' + str(i + 1) + '.jpg'))
            self.layout[1].picture[i].ProcessImage()

        self.layout[0].processCard()
        self.layout[1].processCard()

        self.layout[0].cardImage.resize(int(1868 / 8), int(1261 / 8))
        self.layout[1].cardImage.resize(int(1868 / 8), int(1261 / 8))

        screen = image(width=self.screen_w, height=self.screen_h)

        # create screen
        screen.composite(self.layout[0].cardImage, 131, self.screen_h - 184)
        screen.composite(self.layout[1].cardImage, 643, self.screen_h - 184)

        # save screen to file for displaying
        screen.save(filename=self.screen_choose_layout)
Exemple #2
0
    def processCard(self):
        #if layout in foreground, the template is overlaied at last
        if self.layoutInForeground:
            self.createEmptyCard()

        else:
            self.loadImageTemplate()

        # composite all photos to card
        for i in range(0, self.piccount):
            self.__cardImage.composite(self.picture[i].img, self.picture[i].posX,
                                       self.picture[i].posY)

        # if Layout is in foreground, overlay it last
        if self.layoutInForeground:
            self.__cardImage.composite(image(filename=self.templateFileName).clone(), 0, 0)

        self.__cardImage.resize(int(1868), int(1261))
Exemple #3
0
async def mega_meeme(upper_text, lower_text, picture_name, endname):
    main_image = image(filename=picture_name)
    main_image.resize(
        1024,
        int(((main_image.height * 1.0) / (main_image.width * 1.0)) * 1024.0))
    upper_text = "\n".join(wrap(upper_text,
                                get_warp_length(main_image.width))).upper()
    lower_text = "\n".join(wrap(lower_text,
                                get_warp_length(main_image.width))).upper()
    lower_margin = MARGINS[lower_text.count("\n")]
    text_draw = Drawing()
    text_draw.font = join(getcwd(), "userbot/helpers/styles/impact.ttf")
    text_draw.font_size = 100
    text_draw.text_alignment = "center"
    text_draw.stroke_color = Color("black")
    text_draw.stroke_width = 3
    text_draw.fill_color = Color("white")
    if upper_text:
        text_draw.text((main_image.width) // 2, 80, upper_text)
    if lower_text:
        text_draw.text((main_image.width) // 2,
                       main_image.height - lower_margin, lower_text)
    text_draw(main_image)
    main_image.save(filename=endname)
Exemple #4
0
    def readCardConfiguration(self, path):
        logging.debug("Read card Config File")
        self.cardconfig = configparser.ConfigParser()
        self.cardconfig.sections()

        if path is not None:
            logging.debug("start reading")
            self.cardconfig.read(path)

            # layout 1 configuration
            self.layout[0].piccount = int(self.cardconfig.get("Layout1", "piccount", fallback="0"))
            self.layout[0].templateFileName = os.path.join(os.path.split(path)[0],
                                                           self.cardconfig.get("Layout1", "cardtemplate", fallback="0"))

            self.layout[0].layoutInForeground = self.cardconfig.getboolean("Layout1", "layout_in_foreground", fallback=False)

            # manipulation of photos for Layout 1
            for i in range(0, self.layout[0].piccount):
                self.layout[0].picture[i].resizeX = int(
                    self.cardconfig.get("Layout1", "resize_image_x_" + str(i + 1), fallback="0"))
                self.layout[0].picture[i].resizeY = int(
                    self.cardconfig.get("Layout1", "resize_image_y_" + str(i + 1), fallback="0"))
                self.layout[0].picture[i].rotate = int(
                    self.cardconfig.get("Layout1", "rotate_image_" + str(i + 1), fallback="0"))
                self.layout[0].picture[i].posX = int(
                    self.cardconfig.get("Layout1", "position_image_x_" + str(i + 1), fallback="0"))
                self.layout[0].picture[i].posY = int(
                    self.cardconfig.get("Layout1", "position_image_y_" + str(i + 1), fallback="0"))
                self.layout[0].picture[i].color = self.cardconfig.get("Layout1", "color_image_" + str(i + 1), fallback="color")

                logging.debug(self.layout[0].picture[i])

            logging.debug(self.layout[0])

            # layout 2 configuration
            self.layout[1].piccount = int(self.cardconfig.get("Layout2", "piccount", fallback="0"))
            self.layout[1].templateFileName = os.path.join(os.path.split(path)[0],
                                                           self.cardconfig.get("Layout2", "cardtemplate", fallback="0"))

            self.layout[1].layoutInForeground = self.cardconfig.getboolean("Layout2", "layout_in_foreground", fallback=False)

            # manipulation of photos for Layout 2
            for i in range(0, self.layout[1].piccount):
                self.layout[1].picture[i].resizeX = int(
                    self.cardconfig.get("Layout2", "resize_image_x_" + str(i + 1), fallback="0"))
                self.layout[1].picture[i].resizeY = int(
                    self.cardconfig.get("Layout2", "resize_image_y_" + str(i + 1), fallback="0"))
                self.layout[1].picture[i].rotate = int(
                    self.cardconfig.get("Layout2", "rotate_image_" + str(i + 1), fallback="0"))
                self.layout[1].picture[i].posX = int(
                    self.cardconfig.get("Layout2", "position_image_x_" + str(i + 1), fallback="0"))
                self.layout[1].picture[i].posY = int(
                    self.cardconfig.get("Layout2", "position_image_y_" + str(i + 1), fallback="0"))
                self.layout[1].picture[i].color = self.cardconfig.get("Layout2", "color_image_" + str(i + 1),
                                                                      fallback="color")

                logging.debug(self.layout[1].picture[i])

            logging.debug(self.layout[1])

            self.imagetemplate1 = image(filename=self.layout[0].templateFileName)
            self.imagetemplate2 = image(filename=self.layout[1].templateFileName)
Exemple #5
0
 def createEmptyCard(self):
     self.__cardImage = image(width=self.sizeX, height=self.sizeY)
Exemple #6
0
 def loadImageTemplate(self):
     self.__cardImage = image(filename=self.templateFileName).clone()
Exemple #7
0
 def LoadImage(self):
     self.img = image(filename=self.fileName)