'Setup this image object based on current tags'

def _setup(self):

    if (48129 in self.tag_v2):
        raise IOError('Windows    Media    Photo    files    not    yet    supported')
    self._compression = COMPRESSION_INFO[self.tag_v2.get(COMPRESSION, 1)]
    self._planar_configuration = self.tag_v2.get(PLANAR_CONFIGURATION, 1)
    photo = self.tag_v2.get(PHOTOMETRIC_INTERPRETATION, 0)
    fillorder = self.tag_v2.get(FILLORDER, 1)
    if DEBUG:
        print('***    Summary    ***')
        print('-    compression:', self._compression)
        print('-    photometric_interpretation:', photo)
        print('-    planar_configuration:', self._planar_configuration)
        print('-    fill_order:', fillorder)
    xsize = self.tag_v2.get(IMAGEWIDTH)
    ysize = self.tag_v2.get(IMAGELENGTH)
    self.size = (xsize, ysize)
    if DEBUG:
        print('-    size:', self.size)
    sampleFormat = self.tag_v2.get(SAMPLEFORMAT, (1,))
    if ((len(sampleFormat) > 1) and (max(sampleFormat) == min(sampleFormat) == 1)):
        sampleFormat = (1,)
    key = (self.tag_v2.prefix, photo, sampleFormat, fillorder, self.tag_v2.get(BITSPERSAMPLE, (1,)), self.tag_v2.get(EXTRASAMPLES, ()))
    if DEBUG:
        print('format    key:', key)
    try:
        (self.mode, rawmode) = OPEN_INFO[key]
    except KeyError:
        if DEBUG:
            print('-    unsupported    format')
        raise SyntaxError('unknown    pixel    mode')
    if DEBUG:
        print('-    raw    mode:', rawmode)
        print('-    pil    mode:', self.mode)
    self.info['compression'] = self._compression
    xres = self.tag_v2.get(X_RESOLUTION, 1)
    yres = self.tag_v2.get(Y_RESOLUTION, 1)
    if (xres and yres):
        resunit = self.tag_v2.get(RESOLUTION_UNIT)
        if (resunit == 2):
            self.info['dpi'] = (xres, yres)
        elif (resunit == 3):
            self.info['dpi'] = ((xres * 2.54), (yres * 2.54))
        elif (resunit is None):
            self.info['dpi'] = (xres, yres)
            self.info['resolution'] = (xres, yres)
        else:
            self.info['resolution'] = (xres, yres)
    x = y = l = 0
    self.tile = []
    self.use_load_libtiff = False
    if (STRIPOFFSETS in self.tag_v2):
        offsets = self.tag_v2[STRIPOFFSETS]
        h = self.tag_v2.get(ROWSPERSTRIP, ysize)
        w = self.size[0]
        if (READ_LIBTIFF or (self._compression in ['tiff_ccitt', 'group3', 'group4', 'tiff_jpeg', 'tiff_adobe_deflate', 'tiff_thunderscan', 'tiff_deflate', 'tiff_sgilog', 'tiff_sgilog24', 'tiff_raw_16'])):
            self.use_load_libtiff = True
            if (fillorder == 2):
                key = (self.tag_v2.prefix, photo, sampleFormat, 1, self.tag_v2.get(BITSPERSAMPLE, (1,)), self.tag_v2.get(EXTRASAMPLES, ()))
                if DEBUG:
                    print('format    key:', key)
                (self.mode, rawmode) = OPEN_INFO[key]
            if ((self.mode in ('I;16B', 'I;16')) and ('I;16' in rawmode)):
                rawmode = 'I;16N'
            a = (rawmode, self._compression, False)
            self.tile.append((self._compression, (0, 0, w, ysize), 0, a))
            a = None
        else:
            for (i, offset) in enumerate(offsets):
                a = self._decoder(rawmode, l, i)
                self.tile.append((self._compression, (0, min(y, ysize), w, min((y + h), ysize)), offset, a))
                if DEBUG:
                    print('tiles:    ', self.tile)
                y = (y + h)
                if (y >= self.size[1]):
                    x = y = 0
                    l += 1
                a = None
    elif (TILEOFFSETS in self.tag_v2):
        w = self.tag_v2.get(322)
        h = self.tag_v2.get(323)
        a = None
        for o in self.tag_v2[TILEOFFSETS]:
            if (not a):
                a = self._decoder(rawmode, l)
            self.tile.append((self._compression, (x, y, (x + w), (y + h)), o, a))
            x = (x + w)
            if (x >= self.size[0]):
                (x, y) = (0, (y + h))
                if (y >= self.size[1]):
                    x = y = 0
                    l += 1
                    a = None
    else:
        if DEBUG:
            print('-    unsupported    data    organization')
        raise SyntaxError('unknown    data    organization')
    if (ICCPROFILE in self.tag_v2):
        self.info['icc_profile'] = self.tag_v2[ICCPROFILE]
    if (self.mode == 'P'):
        palette = [o8((b // 256)) for b in self.tag_v2[COLORMAP]]
        self.palette = ImagePalette.raw('RGB;L', ''.join(palette))
