Exemplo n.º 1
0
def insert_sample():
    zeroth_ifd = {282: (96, 1),
                  283: (96, 1),
                  296: 2,
                  305: 'paint.net 4.0.3'}
    exif_bytes = pyxif.dump(zeroth_ifd)
    pyxif.insert(exif_bytes,
                 "remove_sample.jpg",
                 "insert_sample.jpg")
Exemplo n.º 2
0
def dump_sample(input_file, output_file):
    zeroth_ifd = {pyxif.ImageGroup.Make: "foo",
                  pyxif.ImageGroup.XResolution: (96, 1),
                  pyxif.ImageGroup.YResolution: (96, 1),
                  pyxif.ImageGroup.Software: "paint.net 4.0.3",
                  }

    exif_bytes = pyxif.dump(zeroth_ifd=zeroth_ifd)
    im = Image.open(input_file)
    im.thumbnail((100, 100), Image.ANTIALIAS)
    im.save(output_file, exif=exif_bytes)
Exemplo n.º 3
0
 def test_insert(self):
     zeroth_ifd = {282: (96, 1),
                   283: (96, 1),
                   296: 2,
                   305: 'paint.net 4.0.3'}
     exif_bytes = pyxif.dump(zeroth_ifd)
     pyxif.insert(exif_bytes, INPUT_FILE1, "insert.jpg")
     try:
         i = Image.open("insert.jpg")
         i._getexif()
     except:
         self.fail("'insert' generated wrong file")
     finally:
         i.close()
Exemplo n.º 4
0
 def test_insert(self):
     zeroth_ifd = {
         282: (96, 1),
         283: (96, 1),
         296: 2,
         305: 'paint.net 4.0.3'
     }
     exif_bytes = pyxif.dump(zeroth_ifd)
     pyxif.insert(exif_bytes, INPUT_FILE1, "insert.jpg")
     try:
         i = Image.open("insert.jpg")
         i._getexif()
     except:
         self.fail("'insert' generated wrong file")
     finally:
         i.close()
Exemplo n.º 5
0
 def test_insert2(self):
     """To use on server.
     Passes binary data to input.
     """
     zeroth_ifd = {282: (96, 1),
                   283: (96, 1),
                   296: 2,
                   305: 'paint.net 4.0.3'}
     exif_bytes = pyxif.dump(zeroth_ifd)
     o = io.BytesIO()
     pyxif.insert(exif_bytes, I1, o)
     self.assertEqual(o.getvalue()[0:2], b"\xff\xd8")
     try:
         i = Image.open(o)
         i._getexif()
     except:
         self.fail("'insert' generated wrong file")
     finally:
         i.close()
Exemplo n.º 6
0
 def test_insert2(self):
     """To use on server.
     Passes binary data to input.
     """
     zeroth_ifd = {
         282: (96, 1),
         283: (96, 1),
         296: 2,
         305: 'paint.net 4.0.3'
     }
     exif_bytes = pyxif.dump(zeroth_ifd)
     o = io.BytesIO()
     pyxif.insert(exif_bytes, I1, o)
     self.assertEqual(o.getvalue()[0:2], b"\xff\xd8")
     try:
         i = Image.open(o)
         i._getexif()
     except:
         self.fail("'insert' generated wrong file")
     finally:
         i.close()
Exemplo n.º 7
0
    def test_dump(self):
        input_file = INPUT_FILE1
        output_file = "dump.jpg"
        zeroth_ifd = {271: "foo",
                      282: (96, 1),
                      283: (96, 1),
                      296: 2,
                      305: 'paint.net 4.0.3'}

        exif_bytes = pyxif.dump(zeroth_ifd)

        im = Image.open(input_file)
        im.thumbnail((100, 100), Image.ANTIALIAS)
        im.save(output_file, exif=exif_bytes)
        im.close()
        try:
            i = Image.open(output_file)
            i._getexif()
        except:
            self.fail("'dump' generated bad exif")
        finally:
            i.close()
Exemplo n.º 8
0
def dump_sample(input_file, output_file):
    zeroth_ifd = {pyxif.ImageGroup.Make: "fooooooooooooo",
                  pyxif.ImageGroup.XResolution: (96, 1),
                  pyxif.ImageGroup.YResolution: (96, 1),
                  pyxif.ImageGroup.Software: "paint.net 4.0.3",
                  }

    exif_ifd = {pyxif.PhotoGroup.ExifVersion: "0111",
                pyxif.PhotoGroup.DateTimeOriginal: "1999:09:99 99:99:99",
                pyxif.PhotoGroup.CameraOwnerName: "Mr. John Doe",
                }

    gps_ifd = {pyxif.GPSInfoGroup.GPSDateStamp: "1999:99:99",
               pyxif.GPSInfoGroup.GPSDifferential: 90,
               }
    exif_bytes = pyxif.dump(zeroth_ifd=zeroth_ifd, exif_ifd=exif_ifd, gps_ifd=gps_ifd)

    im = Image.open(input_file)
    im.thumbnail((100, 100), Image.ANTIALIAS)
    im.save(output_file, exif=exif_bytes)

    z, e, g = pyxif.load(output_file)
    print(z, e, g)
Exemplo n.º 9
0
    def test_dump(self):
        input_file = INPUT_FILE1
        output_file = "dump.jpg"
        zeroth_ifd = {
            271: "foo",
            282: (96, 1),
            283: (96, 1),
            296: 2,
            305: 'paint.net 4.0.3'
        }

        exif_bytes = pyxif.dump(zeroth_ifd)

        im = Image.open(input_file)
        im.thumbnail((100, 100), Image.ANTIALIAS)
        im.save(output_file, exif=exif_bytes)
        im.close()
        try:
            i = Image.open(output_file)
            i._getexif()
        except:
            self.fail("'dump' generated bad exif")
        finally:
            i.close()