<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def images_create(self, filename):
 """Create and image file or image group object from the given file. The type of the created database object is determined by the suffix of the given file. An ValueError exception is thrown if the file has an unknown suffix. Raises ValueError if invalid file is given. Parameters filename : File-type object File on local disk. Expected to be either an image file or an archive containing image. Returns ------- DataObjectHandle Handle for create dtabase object. Either an ImageHandle or an ImageGroupHandle """

        # Check if file is a single image
        suffix = get_filename_suffix(filename, image.VALID_IMGFILE_SUFFIXES)
        if not suffix is None:
            # Create image object from given file
            return self.images.create_object(filename)
        # The file has not been recognized as a valid image. Check if the file
        # is a valid tar archive (based on suffix).
        suffix = get_filename_suffix(filename, ARCHIVE_SUFFIXES)
        if not suffix is None:
            # Unpack the file to a temporary folder .
            temp_dir = tempfile.mkdtemp()
            try:
                tf = tarfile.open(name=filename, mode='r')
                tf.extractall(path=temp_dir)
            except (tarfile.ReadError, IOError) as err:
                # Clean up in case there is an error during extraction
                shutil.rmtree(temp_dir)
                raise ValueError(str(err))
            # Get names of all files with valid image suffixes and create an
            # object for each image object
            group = []
            for img_file in image.get_image_files(temp_dir, []):
                img_obj = self.images.create_object(img_file)
                folder = img_file[len(temp_dir):-len(img_obj.name)]
                group.append(image.GroupImage(
                    img_obj.identifier,
                    folder,
                    img_obj.name,
                    img_obj.image_file
                ))
            # Create image group
            name = os.path.basename(os.path.normpath(filename))[:-len(suffix)]
            img_grp = self.image_groups.create_object(name, group, filename)
            # Delete the temporary folder
            shutil.rmtree(temp_dir)
            return img_grp
        else:
            # Not a valid file suffix
            raise ValueError('invalid file suffix: ' + os.path.basename(os.path.normpath(filename)))