1

Full code: https://paste.pythondiscord.com/kenatayuce.py

I am encountering this error when trying to use LSB Steganography on a GIF:

pix = [value for value in imdata.next()[:3] + # 3 pixels extracted at one time

TypeError: 'int' object is not subscriptable

def modPix(pix, data): # Pixels are modified from 8-bit binary

Link to full code: https://paste.pythondiscord.com/kenatayuce.py

    datalist = genData(data)
    lendata = len(datalist)
    imdata = iter(pix)

    for i in range(lendata):

        pix = [value for value in imdata.__next__()[:3] + # 3 pixels extracted at one time
                                imdata.__next__()[:3] +
                                imdata.__next__()[:3]]

        for j in range(0, 8):
            if (datalist[i][j] == '0' and pix[j]% 2 != 0): # Pixel value = 1 for odd, 0 for even
                pix[j] -= 1

            elif (datalist[i][j] == '1' and pix[j] % 2 == 0):
                if(pix[j] != 0):
                    pix[j] -= 1
                else:
                    pix[j] += 1

        if (i == lendata - 1):  # 8th pixel will state whether to stop or to carry on reading
            if (pix[-1] % 2 == 0):  # 0 = Keep reading.
                if(pix[-1] != 0):   # 1 = Stop. Message is over.
                    pix[-1] -= 1
                else:
                    pix[-1] += 1

        else:
            if (pix[-1] % 2 != 0):
                pix[-1] -= 1

        pix = tuple(pix)
        yield pix[0:3]
        yield pix[3:6]
        yield pix[6:9]
RSS424
  • 11
  • 2
  • How can anyone help? We can't see your images, nor what your data looks like, nor know what modules you are using (as you have removed the `import` statements) and we don't know how you load your image. – Mark Setchell Jun 30 '21 at 18:35
  • https://paste.pythondiscord.com/kenatayuce.py Sorry it would not let me paste all my code, above is the link to show all the code I have. – RSS424 Jun 30 '21 at 19:17
  • Have a read here... https://stackoverflow.com/a/52307690/2836621 – Mark Setchell Jun 30 '21 at 19:22
  • Oh my god you beautiful man, you don't know how long I have spent trying to fix this and to see it was something so simple is frustrating but hilarious at the same time. Thank you so much! :) – RSS424 Jun 30 '21 at 19:35

0 Answers0