def load_palette(file_href):
 bytes = urlopen(file_href).read()
 (count, t_index) = unpack('!HH', bytes[768:(768 + 4)])
 t_index = (((t_index <= 255) and t_index) or None)
 palette = []
 for offset in range(0, count):
  if (offset == t_index):
   rgb = (255, 153, 0)
  else:
   rgb = unpack('!BBB', bytes[(offset * 3):((offset + 1) * 3)])
  palette.append(rgb)
 bits = int(ceil((log(len(palette)) / log(2))))
 return (palette, bits, t_index)

def load_palette ( file_href ) : bytes = urlopen ( file_href ) . read ( ) ( count , t_index ) = unpack ( '!HH' , bytes [ 768 : ( 768 + 4 ) ] ) t_index = ( ( ( t_index <= 255 ) and t_index ) or None ) palette = [ ] for offset in range ( 0 , count ) : if ( offset == t_index ) : rgb = ( 255 , 153 , 0 ) else : rgb = unpack ( '!BBB' , bytes [ ( offset * 3 ) : ( ( offset + 1 ) * 3 ) ] ) palette . append ( rgb ) bits = int ( ceil ( ( log ( len ( palette ) ) / log ( 2 ) ) ) ) return ( palette , bits , t_index )
load colors from a photoshop .