예제 #1
0
def test_write_png_produces_file_of_expected_size():
    expected_size = 77  # Precomputed size of resulting PNG
    white = [255, 255, 255]
    black = [0, 0, 0]
    pixel_rows = [black + white + black,
                  white + black + white,
                  black + white + black]

    pixel_array = PixelArray(pixel_rows)
    file = io.BytesIO()
    write_pixels_to_png(pixel_array, file)

    assert len(file.getvalue()) == expected_size
예제 #2
0
 def execute(self):
     with open(self._input_file, 'rb') as data_file:
         with open(self._output_file, 'wb') as png_file:
             data = read_data_from_file(data_file)
             write_pixels_to_png(convert_bytes_to_pixels(data, self._width),
                                 png_file)
예제 #3
0
 def execute(self):
     with open(self._input_file, 'rb') as data_file:
         with open(self._output_file, 'wb') as png_file:
             data = read_data_from_file(data_file)
             write_pixels_to_png(convert_bytes_to_pixels(data, self._width),
                                 png_file)