Exemplo n.º 1
0
    def extract_png(self):

        for kra in self.kras:
            png = kra.get_merged_image()
            png_name = kra.get_basename() + '.png'

            png_dir = os.path.join(self.outdir, kra.get_basename(), 'png')
            os.makedirs(png_dir, exist_ok=True)
            with open(os.path.join(png_dir, png_name), 'w+b') as f:
                f.write(png)
                f.close()
Exemplo n.º 2
0
def export_as_jpegs(kras, outdir):
    for kra in kras:
        # Create one jpeg with the original size
        jpeg_dir = os.path.join(outdir, kra.get_basename(), 'jpg')
        os.makedirs(jpeg_dir, exist_ok=True)
        im = Image.open(kra.merged_image_path)
        jpeg_name = kra.get_basename() + '_original.jpg'
        save_as_jpeg(im, kra, jpeg_name, jpeg_dir)

        for size in args.sizes:
            im = Image.open(kra.merged_image_path)
            jpeg_name = kra.get_basename() + '{0}.jpg'.format(size)
            im.thumbnail((size, size), Image.ANTIALIAS)
            save_as_jpeg(im, kra, jpeg_name, jpeg_dir)
Exemplo n.º 3
0
def export_as_jpegs(kras, outdir):
    for kra in kras:
        """
        Create one jpeg with the original size
        """
        jpeg_dir = os.path.join(outdir, kra.get_basename(), 'jpeg')
        os.makedirs(jpeg_dir, exist_ok=True)
        im = Image.open(kra.merged_image_path)
        jpeg_name = kra.get_basename() + '_original.jpeg'
        save_as_jpeg(im, kra, jpeg_name, jpeg_dir)

        for size in args.sizes:
            im = Image.open(kra.merged_image_path)
            jpeg_name = kra.get_basename() + '{0}.jpeg'.format(size)
            im.thumbnail((size, size), Image.ANTIALIAS)
            save_as_jpeg(im, kra, jpeg_name, jpeg_dir)
Exemplo n.º 4
0
def extract_icc(kras, outdir):
    for kra in kras:
        icc = kra.get_icc()
        icc_dir = os.path.join(outdir, kra.get_basename(), 'icc')
        os.makedirs(icc_dir, exist_ok=True)
        kra.icc_path = os.path.join(icc_dir, icc['name'])

        with open(kra.icc_path, 'w+b') as f:
            f.write(icc['data'])
            f.close()
Exemplo n.º 5
0
def extract_icc(kras, outdir):
    for kra in kras:
        icc = kra.get_icc()
        icc_dir = os.path.join(outdir, kra.get_basename(), 'icc')
        os.makedirs(icc_dir, exist_ok=True)
        kra.icc_path = os.path.join(icc_dir, icc['name'])

        with open(kra.icc_path, 'wb') as f:
            f.write(icc['data'])
            f.close()
Exemplo n.º 6
0
    def extract_icc(self):

        for kra in self.kras:
            icc = kra.get_icc()
            icc_dir = os.path.join(self.outdir, kra.get_basename(), 'icc')
            os.makedirs(icc_dir, exist_ok=True)

            with open(os.path.join(icc_dir, icc['name']), 'w+b') as f:
                f.write(icc['data'])
                f.close()
Exemplo n.º 7
0
def extract_png(kras, outdir):
    for kra in kras:
        png = kra.get_merged_image()
        png_name = kra.get_basename() + '.png'
        png_name_web = kra.get_basename() + '_srgb.png'

        png_dir = os.path.join(outdir, kra.get_basename(), 'png')
        os.makedirs(png_dir, exist_ok=True)
        kra.merged_image_path = os.path.join(png_dir, png_name)

        with open(kra.merged_image_path, 'w+b') as f:
            f.write(png)
            f.close()

        if args.webready:
            im = Image.open(kra.merged_image_path)

            # BUG: I don't know why but I need to use inPlace here or else
            # my test png was just transparent
            ImageCms.profileToProfile(im, kra.icc_path, srgb, inPlace=True)
            im.save(os.path.join(png_dir, png_name_web), optimize=True)
Exemplo n.º 8
0
def extract_png(kras, outdir):
    for kra in kras:
        png = kra.get_merged_image()
        png_name = kra.get_basename() + '.png'
        png_name_web = kra.get_basename() + '-srgb.png'

        png_dir = os.path.join(outdir, kra.get_basename(), 'png')
        os.makedirs(png_dir, exist_ok=True)
        kra.merged_image_path = os.path.join(png_dir, png_name)

        with open(kra.merged_image_path, 'wb') as f:
            f.write(png)
            f.close()

        if args.webready:
            im = Image.open(kra.merged_image_path)

            # BUG: I don't know why but I need to use inPlace here or else
            # my test png was just transparent
            ImageCms.profileToProfile(im, kra.icc_path, srgb, inPlace=True)
            im.save(os.path.join(png_dir, png_name_web), optimize=True)