84648488
Chunk
reverted.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import jpeg
import sys
import struct
a = jpeg.Jpeg(sys.argv[1])
def flipblock(block):
tmp = str(block)
for i in range(0, len(block), 4):
short, = struct.unpack_from("h", tmp, i+2)
struct.pack_into("h", block, i+2, -short)
for comp in range(a.component_count):
xmax, ymax = a.getcomponentdimensions(comp)
for y in range(ymax):
for x in range((xmax+1)/2):
block = a.getblock(x,y,comp)
block2 = a.getblock(xmax-1 - x, y, comp)
flipblock(block)
flipblock(block2)
a.setblock(xmax-1-x, y, comp, block)
a.setblock(x,y,comp,block2)
a.write(sys.argv[2])
|