Пример #1
0
    def process_imgs(self, f0, f1, ctr=0):
        im0 = f0
        im1 = f1
        im_ctr = ctr
        out_file = self.o_path + "img"
        # for level in range(20):
        #     out_file_curr = out_file+utils.zero_str(4,im_ctr)+self.o_type
        #     im0.save(out_file_curr)
        #     im_ctr +=1
        transition = self.warp_frames / 2
        transition_start = self.warp_frames / 4
        transition_end = self.warp_frames - self.warp_frames / 4

        for level in range(int(self.warp_frames) + 1):
            out_file_curr = out_file + utils.zero_str(4, im_ctr) + self.o_type
            # if level< 10:
            #    im0.save(out_file_curr)
            # elif level>self.warp_frames-10:
            #    im1.save(out_file_curr)
            # else:

            if level < transition_start:
                alpha = 0
            elif level > transition_end:
                alpha = 1
            else:
                alpha = float(level - transition_start) / float(self.warp_frames + 1 - transition)

            im_new = Image.blend(im0, im1, alpha)
            ###### TODO HACK FOR 2000x1333 image
            im_new = im_new.crop((40, 120, 1960, 1200))
            # im_new=im_new.resize((1920,1080),Image.BILINEAR)
            im_new.save(out_file_curr)
            im_ctr += 1
Пример #2
0
    def css_parallel(self,files,o_size,o_path,ctr):    
        i = ctr  
        in_bounds = i
               
        for curr_frame in files:


            img = Image.open(curr_frame)

            img_size = img.size
            if self.dr_x[i] < img_size[0] and self.dr_y[i] < img_size[1]:
                img = img.crop((self.ul_x[i],self.ul_y[i],self.dr_x[i],self.dr_y[i]))
                in_bounds = i
            else:
                img = img.crop((self.ul_x[in_bounds],self.ul_y[in_bounds],self.dr_x[in_bounds],self.dr_y[in_bounds]))
            img = img.resize(o_size,self.flags["filter"])
            number_str=utils.zero_str(5,i)
            o_file = o_path+"img_"+number_str+".jpg"
            img.save(o_file)
            i = i+1