'Determine whether the candidate artwork is valid based on
its dimensions (width and ratio).
Return `CANDIDATE_BAD` if the file is unusable.
Return `CANDIDATE_EXACT` if the file is usable as-is.
Return `CANDIDATE_DOWNSCALE` if the file must be resized.'

def _validate(self, plugin):

    if (not self.path):
        return self.CANDIDATE_BAD
    if (not (plugin.enforce_ratio or plugin.minwidth or plugin.maxwidth)):
        return self.CANDIDATE_EXACT
    if (not self.size):
        self.size = ArtResizer.shared.get_size(self.path)
    self._log.debug(u'image    size:    {}', self.size)
    if (not self.size):
        self._log.warning(u'Could    not    get    size    of    image    (please    see    documentation    for    dependencies).    The    configuration    options    `minwidth`    and    `enforce_ratio`    may    be    violated.')
        return self.CANDIDATE_EXACT
    short_edge = min(self.size)
    long_edge = max(self.size)
    if (plugin.minwidth and (self.size[0] < plugin.minwidth)):
        self._log.debug(u'image    too    small    ({}    <    {})', self.size[0], plugin.minwidth)
        return self.CANDIDATE_BAD
    edge_diff = (long_edge - short_edge)
    if plugin.enforce_ratio:
        if plugin.margin_px:
            if (edge_diff > plugin.margin_px):
                self._log.debug(u'image    is    not    close    enough    to    being    square,    ({}    -    {}    >    {})', long_edge, short_edge, plugin.margin_px)
                return self.CANDIDATE_BAD
        elif plugin.margin_percent:
            margin_px = (plugin.margin_percent * long_edge)
            if (edge_diff > margin_px):
                self._log.debug(u'image    is    not    close    enough    to    being    square,    ({}    -    {}    >    {})', long_edge, short_edge, margin_px)
                return self.CANDIDATE_BAD
        elif edge_diff:
            self._log.debug(u'image    is    not    square    ({}    !=    {})', self.size[0], self.size[1])
            return self.CANDIDATE_BAD
    if (plugin.maxwidth and (self.size[0] > plugin.maxwidth)):
        self._log.debug(u'image    needs    resizing    ({}    >    {})', self.size[0], plugin.maxwidth)
        return self.CANDIDATE_DOWNSCALE
    return self.CANDIDATE_EXACT
