code: def apply(self, resource):
          
          if isinstance(resource, Image.Image):
              return getattr(self, '_' + self.method)(resource)
          else:
              raise ValueError('Unsupported resource format: %s' % str(type(resource)))
docs: :param resource: Image
          :return: Image