Return pixmap for item, which is a list of 2 xref numbers. Second xref
    is that of an smask if > 0.
    Return None for any error.

def recoverpix(doc, item):
    """Return pixmap for item, which is a list of 2 xref numbers. Second xref
    is that of an smask if > 0.
    Return None for any error.
    """
    x = item[0]  # xref of PDF image
    s = item[1]  # xref of its /SMask
    
    try:
        pix1 = fitz.Pixmap(doc, x)     # make pixmap from image
    except:
        print("xref %i " % x + doc._getGCTXerrmsg())
        return None                    # skip if error

    if s == 0:                    # has no /SMask
        return pix1               # no special handling
    
    try:
        pix2 = fitz.Pixmap(doc, s)    # create pixmap of /SMask entry
    except:
        print("cannot create mask %i for image xref %i" % (s,x))
        return pix1               # return w/ failed transparency
        
    # check that we are safe
    if not (pix1.irect == pix2.irect and \
            pix1.alpha == pix2.alpha == 0 and \
            pix2.n == 1):
        print("unexpected /SMask situation: pix1", pix1, "pix2", pix2)
        return pix1
    pix = fitz.Pixmap(pix1)       # copy of pix1, alpha channel added
    pix.setAlpha(pix2.samples)    # treat pix2.samples as alpha values
    pix1 = pix2 = None            # free temp pixmaps
    return pix