Beispiel #1
0
    def _rotate_by_jpegtran(cls, image_phys_path, rotated_image):
        image_phys_path_rotated = image_phys_path + "_rotated"
        rotation_angle = str(cls.ROTATIONS_MAP[rotated_image.orientation])

        logger.info("rotating image ({} degrees): {}".format(rotation_angle, image_phys_path))

        # call lossless rotation
        subprocess.call(
            ['jpegtran', '-rotate', rotation_angle, '-outfile', image_phys_path_rotated, image_phys_path])

        os.rename(image_phys_path_rotated, image_phys_path)

        # invoke thumbnail recreation
        Thumbnailer.create_miniatures(image_phys_path, force_recreate=True)

        # reset image orientation
        rotated_image.orientation = 'up'
        # recalculate aspect radio, modification_time
        rotated_image.aspect_ratio = Indexer.get_image_aspect_ratio(image_phys_path)
        rotated_image.modification_time = get_mtime_datetime(image_phys_path)

        rotated_image.save()
Beispiel #2
0
    def go(cls):
        django.setup()
        # configure logging
        cls._configure_logging()

        # create pidfile, exit if creation fails
        handle_pidfile(os.path.join(COLLECTION_PHYS_ROOT, '.meta', 'gallery_runner.pid'))

        Rotator.perform_requested_rotations()
        TrashCleaner.remove_old_trash_files()
        Linker.create_links()

        indexer = Indexer()
        for (root, dirs, files) in collection_walk():
            renamed = Renamer(root, files).rename_jpgs_in_collection()
            Thumbnailer.synchronize_miniatures_with_collection(root, dirs, renamed)
            indexer.synchronize_db_with_collection(root, dirs, renamed)

        Thumbnailer.remove_obsolete()
        indexer.post_indexing_fixes()
        indexer.process_pending_removals()