I've been trying to read images in ASCII values and compare the two images for an exact ASCII values match. However, the output is very large and my hardware is very old and cannot read the output, I have tried to save the output to a file and the file was huge. Here is what I'm trying to do:

```
orig = sys.stdout
f = open('output.txt','w')
sys.stdout = f

# Load the two Images 

with open("image1.jpg", "rb") as b:
 with open("image2.jpg", "rb") as a:

  # Convert the two images from binary to ascii

    chunk1 = binascii.b2a_hex(b.read())
    chunk2 = binascii.b2a_hex(a.read())

# split the two chunks of ascii values into a list of 24 bytes 

chunkSize = 24
for i in range (0,len(chunk1),chunkSize):
 for j in range (0,len(chunk2),chunkSize):

 # Print them

  list1 = chunk1[i:i+chunkSize]
  print "List1: "+ list1
  list2 = chunk2[j:j+chunkSize]
  print "List2: " + list2

# Compare the two images for equality 

  list = list1 == list2

 # print whether its a match or false

  print list

sys.stdout = orig
f.close()

# Saved to a file

```

How it works:

img1 has the following hex : FFD8 FFE0 0010 4A46 4946 0001 0200 0064 0064 0000 FFEC 0011 
 img2 has the following hex: FFD8 FFE0 0010 4A46 4946 0001 0210 0064 0064 0000 FFEC 0012

It would take the first 24 chars of the img1 and test it against all the img2 hex in 24 chars a time and then take the next 24 chars of img1 and test against all the img2 hex. Example: 

```
List1: FFD8 FFE0 0010 4A46 4946 0001 
List2: FFD8 FFE0 0010 4A46 4946 0001 
True 

List1: FFD8 FFE0 0010 4A46 4946 0001 
List2: 0210 0064 0064 0000 FFEC 0012 
False

List1: 0200 0064 0064 0000 FFEC 0011 
List2: FFD8 FFE0 0010 4A46 4946 0001 
False 

List1: 0200 0064 0064 0000 FFEC 0011 
List2: 0210 0064 0064 0000 FFEC 0012 
False

```

However, The output is large considering huge images with like 40k hex and 20k which I can't read from the terminal either saving the output to a file. 

How do I print only the matched(True) 24 chars ASCII hex value without printing true, false and false ASCII hex values?

```
FFD8 FFE0 0010 4A46 4946 0001

```