  
          try:
              with open(self.location, self.serializer.roptions) as align:
                  data = self.serializer.unmarshal(align.read())
  
          except Exception as err:
              print("{} not read!".format(self.location))
              print(str(err))
              data = dict()
  
          if skip_faces:
              # Remove items from algnments that have no faces so they will
              # be re-detected
              del_keys = [key for key, val in data.items() if not val]
 
</s> remove             with open(self.location, self.serializer.roptions) as align:
 </s> add             with open(self.file, self.serializer.roptions) as align: </s> remove         skip_faces = None
        if self.is_extract:
            skip_existing = bool(hasattr(self.args, 'skip_existing')
                                 and self.args.skip_existing)
            skip_faces = bool(hasattr(self.args, 'skip_faces')
                              and self.args.skip_faces)

            if not self.have_alignments_file:
                if skip_existing or skip_faces:
                    print("Skip Existing/Skip Faces selected, but no "
                          "alignments file found!")
                return data
            if not skip_existing and not skip_faces:
                return data
 </s> add         if not self.is_extract:
            data = super().load()
            return data

        skip_existing = bool(hasattr(self.args, 'skip_existing')
                             and self.args.skip_existing)
        skip_faces = bool(hasattr(self.args, 'skip_faces')
                          and self.args.skip_faces)

        if not skip_existing and not skip_faces:
            return data

        if not self.have_alignments_file and (skip_existing or skip_faces):
            print("Skip Existing/Skip Faces selected, but no alignments file "
                  "found!")
            return data </s> remove     def reload(self):
        """ Read the alignments data from the correct format """
        print("Reloading alignments from {}".format(self.file))
        with open(self.file, self.serializer.roptions) as align:
            self.alignments = self.serializer.unmarshal(align.read())

    def save_alignments(self):
 </s> add     def save(self): </s> remove         return dst_fmt

    def set_destination_serializer(self):
        """ set the destination serializer """
        self.serializer = Serializer.get_serializer(self.dst_format)

    def load(self):
        """ Read the alignments data from the correct format """
        print("Loading alignments from {}".format(self.file))
        with open(self.file, self.serializer.roptions) as align:
            alignments = self.serializer.unmarshal(align.read())
        return alignments
 </s> add         self.serializer = self.get_serializer("", dst_fmt)
        filename = os.path.splitext(self.file)[0]
        self.file = "{}.{}".format(filename, self.serializer.ext) </s> remove     def save(self):
        """ Write the serialized alignments file """
        try:
            print("Writing alignments to: {}".format(self.location))
            with open(self.location, self.serializer.woptions) as align:
                align.write(self.serializer.marshal(self.data))
        except Exception as err:
            print("{} not written!".format(self.location))
            print(str(err))

    def frame_exists(self, frame):
        """ return path of images that have faces """
        return frame in self.data.keys()

    def get_alignments_for_frame(self, frame):
        """ Return the alignments for the selected frame """
        return self.data.get(frame, list())

    def get_legacy_frames(self):
        """ Return a list of frames with legacy rotations """
        keys = list()
        for key, val in self.data.items():
            if any(alignment.get("r", None) for alignment in val):
                keys.append(key)
        return keys

    def rotate_existing_landmarks(self, frame, dimensions):
        """ Backwards compatability fix. Rotates the landmarks to
            their correct position and deletes r """
        for face in self.get_alignments_for_frame(frame):
            angle = face.get("r", 0)
            if not angle:
                return
            rotation_matrix = self.get_original_rotation_matrix(dimensions,
                                                                angle)
            rotate_landmarks(face, rotation_matrix)
            del face["r"]

    @staticmethod
    def get_original_rotation_matrix(dimensions, angle):
        """ Calculate original rotation matrix and invert """
        height, width = dimensions
        center = (width/2, height/2)
        rotation_matrix = cv2.getRotationMatrix2D(center, -1.0*angle, 1.)

        abs_cos = abs(rotation_matrix[0, 0])
        abs_sin = abs(rotation_matrix[0, 1])
        rotated_width = int(height*abs_sin + width*abs_cos)
        rotated_height = int(height*abs_cos + width*abs_sin)
        rotation_matrix[0, 2] += rotated_width/2 - center[0]
        rotation_matrix[1, 2] += rotated_height/2 - center[1]

        return rotation_matrix

 </s> add 
        except IOError as err:
            print("Error: {} not read: {}".format(self.file, err.strerror))
            exit(1)
  
          try:
              with open(self.location, self.serializer.roptions) as align:
                  data = self.serializer.unmarshal(align.read())
        except IOError as err:
            print("Error: {} not read: {}".format(self.file, err.strerror))
            exit(1)
        except IOError as err:
            print("Error: {} not read: {}".format(self.file, err.strerror))
            exit(1)
        except IOError as err:
            print("Error: {} not read: {}".format(self.file, err.strerror))
            exit(1)
        except IOError as err:
            print("Error: {} not read: {}".format(self.file, err.strerror))
            exit(1)
        except IOError as err:
            print("Error: {} not read: {}".format(self.file, err.strerror))
            exit(1)
  
          if skip_faces:
              # Remove items from algnments that have no faces so they will
              # be re-detected
              del_keys = [key for key, val in data.items() if not val]
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
 Fix convert-adjust (#531)

* Add dimensions to alignments + refactor

* Add frame_dims + funcs to DetectFaces. Add alignments lib

* Convert Adjust working

* Refactor and tidy up 
scripts/fsmedia.py