def testTagging(self): self.assertFalse(QgsExifTools.geoTagImage('', QgsPointXY(1, 2))) self.assertFalse( QgsExifTools.geoTagImage('not a path', QgsPointXY(1, 2))) src_photo = os.path.join(TEST_DATA_DIR, 'photos', 'notags.JPG') tmpFile = QTemporaryFile() tmpFile.open() tmpName = tmpFile.fileName() tmpFile.close() shutil.copy(src_photo, tmpName) self.assertTrue(QgsExifTools.geoTagImage(tmpName, QgsPointXY(1.1, 3.3))) tag, ok = QgsExifTools.getGeoTag(tmpName) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'Point (1.1 3.3)') os.remove(tmpName) shutil.copy(src_photo, tmpName) self.assertTrue( QgsExifTools.geoTagImage(tmpName, QgsPointXY(-1.1, -3.3))) tag, ok = QgsExifTools.getGeoTag(tmpName) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'Point (-1.1 -3.3)') os.remove(tmpName) shutil.copy(src_photo, tmpName) deets = QgsExifTools.GeoTagDetails() deets.elevation = 110.1 self.assertTrue( QgsExifTools.geoTagImage(tmpName, QgsPointXY(1.1, 3.3), deets)) tag, ok = QgsExifTools.getGeoTag(tmpName) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'PointZ (1.1 3.3 110.1)') os.remove(tmpName) shutil.copy(src_photo, tmpName) deets = QgsExifTools.GeoTagDetails() deets.elevation = -110.1 self.assertTrue( QgsExifTools.geoTagImage(tmpName, QgsPointXY(1.1, 3.3), deets)) tag, ok = QgsExifTools.getGeoTag(tmpName) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'PointZ (1.1 3.3 -110.1)') os.remove(tmpName)
def testGeoTags(self): photos_folder = os.path.join(TEST_DATA_DIR, 'photos') tag, ok = QgsExifTools.getGeoTag('') self.assertFalse(ok) tag, ok = QgsExifTools.getGeoTag(os.path.join(photos_folder, '0997.JPG')) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'PointZ (149.275167 -37.2305 422.191011)') tag, ok = QgsExifTools.getGeoTag(os.path.join(photos_folder, 'geotagged.jpg')) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'PointZ (149.131878 -36.220892 867)') tag, ok = QgsExifTools.getGeoTag(os.path.join(photos_folder, 'notags.JPG')) self.assertFalse(ok) tag, ok = QgsExifTools.getGeoTag(os.path.join(photos_folder, 'not_photo.jpg')) self.assertFalse(ok)
def testGeoTags(self): photos_folder = os.path.join(TEST_DATA_DIR, 'photos') tag, ok = QgsExifTools.getGeoTag('') self.assertFalse(ok) tag, ok = QgsExifTools.getGeoTag(os.path.join(photos_folder, '0997.JPG')) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'PointZ (149.275167 -37.2305 422.191011)') tag, ok = QgsExifTools.getGeoTag(os.path.join(photos_folder, 'geotagged.jpg')) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'PointZ (149.131878 -36.220892 867)') tag, ok = QgsExifTools.getGeoTag(os.path.join(photos_folder, 'notags.JPG')) self.assertFalse(ok) tag, ok = QgsExifTools.getGeoTag(os.path.join(photos_folder, 'not_photo.jpg')) self.assertFalse(ok)
def testTagging(self): self.assertFalse(QgsExifTools.geoTagImage('', QgsPointXY(1, 2))) self.assertFalse(QgsExifTools.geoTagImage('not a path', QgsPointXY(1, 2))) src_photo = os.path.join(TEST_DATA_DIR, 'photos', 'notags.JPG') tmpFile = QTemporaryFile() tmpFile.open() tmpName = tmpFile.fileName() tmpFile.close() shutil.copy(src_photo, tmpName) self.assertTrue(QgsExifTools.geoTagImage(tmpName, QgsPointXY(1.1, 3.3))) tag, ok = QgsExifTools.getGeoTag(tmpName) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'Point (1.1 3.3)') os.remove(tmpName) shutil.copy(src_photo, tmpName) self.assertTrue(QgsExifTools.geoTagImage(tmpName, QgsPointXY(-1.1, -3.3))) tag, ok = QgsExifTools.getGeoTag(tmpName) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'Point (-1.1 -3.3)') os.remove(tmpName) shutil.copy(src_photo, tmpName) deets = QgsExifTools.GeoTagDetails() deets.elevation = 110.1 self.assertTrue(QgsExifTools.geoTagImage(tmpName, QgsPointXY(1.1, 3.3), deets)) tag, ok = QgsExifTools.getGeoTag(tmpName) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'PointZ (1.1 3.3 110.1)') os.remove(tmpName) shutil.copy(src_photo, tmpName) deets = QgsExifTools.GeoTagDetails() deets.elevation = -110.1 self.assertTrue(QgsExifTools.geoTagImage(tmpName, QgsPointXY(1.1, 3.3), deets)) tag, ok = QgsExifTools.getGeoTag(tmpName) self.assertTrue(ok) self.assertEqual(tag.asWkt(6), 'PointZ (1.1 3.3 -110.1)') os.remove(tmpName)