<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_object(self, filename, img_properties=None):
 """Create an image object on local disk from the given file. The file is copied to a new local directory that is created for the image object. The optional list of image properties will be associated with the new object together with the set of default properties for images. Parameters filename : string Path to file on disk img_properties : Dictionary, optional Set of image properties. Returns ------- ImageHandle Handle for created image object """

        # Get the file name, i.e., last component of the given absolute path
        prop_name = os.path.basename(os.path.normpath(filename))
        # Ensure that the image file has a valid suffix. Currently we do not
        # check whether the file actually is an image. If the suffix is valid
        # get the associated Mime type from the dictionary.
        prop_mime = None
        pos = prop_name.rfind('.')
        if pos >= 0:
            suffix = prop_name[pos:].lower()
            if suffix in VALID_IMGFILE_SUFFIXES:
                prop_mime = VALID_IMGFILE_SUFFIXES[suffix]
        if not prop_mime:
            raise ValueError('unsupported image type: ' + prop_name)
        # Create a new object identifier.
        identifier = str(uuid.uuid4()).replace('-','')
        # The sub-folder to store the image is given by the first two
        # characters of the identifier.
        image_dir = self.get_directory(identifier)
        # Create the directory if it doesn't exists
        if not os.access(image_dir, os.F_OK):
            os.makedirs(image_dir)
        # Create the initial set of properties for the new image object.
        properties = {
            datastore.PROPERTY_NAME: prop_name,
            datastore.PROPERTY_FILENAME : prop_name,
            datastore.PROPERTY_FILESIZE : os.path.getsize(filename),
            datastore.PROPERTY_MIMETYPE : prop_mime
        }
        # Add additional image properties (if given). Note that this will not
        # override the default image properties.
        if not img_properties is None:
            for prop in img_properties:
                if not prop in properties:
                    properties[prop] = img_properties[prop]
        # Copy original file to new object's directory
        shutil.copyfile(filename, os.path.join(image_dir, prop_name))
        # Create object handle and store it in database before returning it
        obj = ImageHandle(identifier, properties, image_dir)
        self.insert_object(obj)
        return obj