├── .gitignore ├── ImportPhotos.py ├── LICENSE ├── README.md ├── __init__.py ├── code ├── MouseClick.py └── PhotosViewer.py ├── i18n ├── ImportPhotos_fr.qm └── ImportPhotos_fr.ts ├── icons ├── ImportImage.svg ├── SelectImage.svg ├── arrowLeft.png ├── arrowRight.png ├── edges.PNG ├── example.png ├── export.svg ├── icon.png ├── mActionPan.svg ├── mActionZoomFullExtent.svg ├── mActionZoomToSelected.svg ├── method-draw-image.svg ├── photos.qml ├── redband.PNG ├── rotate.png ├── sync_views.svg └── tonorth.png ├── install_packages ├── install_pip_packages.bat ├── py3-env.bat └── requirements.txt ├── metadata.txt ├── resources.py ├── resources.qrc ├── runuifiles.bat └── ui ├── impphotos.py └── impphotos.ui /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | deploy.bat 3 | .idea/ -------------------------------------------------------------------------------- /ImportPhotos.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | ImportPhotos 5 | A QGIS plugin 6 | Import photos 7 | last update : 04/01/2023 8 | begin : February 2018 9 | copyright : (C) 2019 by KIOS Research Center 10 | email : mariosmsk@gmail.com 11 | ***************************************************************************/ 12 | /*************************************************************************** 13 | * * 14 | * This program is free software; you can redistribute it and/or modify * 15 | * it under the terms of the GNU General Public License as published by * 16 | * the Free Software Foundation; either version 2 of the License, or * 17 | * (at your option) any later version. * 18 | * * 19 | ***************************************************************************/ 20 | """ 21 | 22 | import json 23 | import os 24 | import uuid 25 | 26 | from qgis.PyQt import uic 27 | from qgis.PyQt.QtCore import QFileInfo 28 | from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication, Qt, QTextCodec 29 | from qgis.PyQt.QtGui import QIcon, QGuiApplication 30 | from qgis.PyQt.QtWidgets import QAction, QFileDialog, QMessageBox, QInputDialog, QLabel 31 | from qgis.PyQt.QtWidgets import QDialog 32 | from qgis.core import * 33 | from qgis.gui import QgsRuleBasedRendererWidget 34 | 35 | # Initialize Qt resources from file resources.py 36 | from . import resources 37 | # Import the code for the dialog 38 | from .code.MouseClick import MouseClick 39 | from pathlib import Path 40 | 41 | # Import python module 42 | CHECK_MODULE = '' 43 | try: 44 | import exifread 45 | 46 | CHECK_MODULE = 'exifread' 47 | except: 48 | CHECK_MODULE = '' 49 | 50 | try: 51 | if CHECK_MODULE == '': 52 | from PIL import Image 53 | from PIL.ExifTags import TAGS 54 | 55 | CHECK_MODULE = 'PIL' 56 | except: 57 | CHECK_MODULE = '' 58 | 59 | FORM_CLASS, _ = uic.loadUiType(os.path.join( 60 | os.path.dirname(__file__), 'ui/impphotos.ui')) 61 | 62 | FIELDS = ['fid', 'ID', 'Name', 'Date', 'Time', 'Lon', 'Lat', 'Altitude', 'North', 'Azimuth', 'Cam. Maker', 63 | 'Cam. Model', 'Title', 'Comment', 'Path', 'RelPath', 'Timestamp', 'Images', 'Link', 'Description'] 64 | 65 | SUPPORTED_PHOTOS_EXTENSIONS = ['jpg', 'jpeg', 'JPG', 'JPEG'] 66 | 67 | SUPPORTED_OUTPUT_FILE_EXTENSIONS = { 68 | "GeoPackage (*.gpkg *.GPKG)": ".gpkg", 69 | "ESRI Shapefile (*.shp *.SHP)": ".shp", 70 | "GeoJSON (*.geojson *.GEOJSON)": ".geojson", 71 | "Comma Separated Value (*.csv *.CSV)": ".csv", 72 | "Keyhole Markup Language (*.kml *.KML)": ".kml", 73 | "Mapinfo TAB (*.tab *.TAB)": ".tab" 74 | } 75 | 76 | EXTENSION_DRIVERS = { 77 | ".gpkg": "GPKG", 78 | ".shp": "ESRI Shapefile", 79 | ".geojson": "GeoJSON", 80 | ".csv": "CSV", 81 | ".kml": "KML", 82 | ".tab": "MapInfo File" 83 | } 84 | 85 | CODEC = QTextCodec.codecForName("UTF-8") 86 | 87 | 88 | # Import ui file 89 | class ImportPhotosDialog(QDialog, FORM_CLASS): 90 | def __init__(self, parent=None): 91 | # """Constructor.""" 92 | QDialog.__init__(self, None, Qt.WindowStaysOnTopHint) 93 | super(ImportPhotosDialog, self).__init__(parent) 94 | self.setupUi(self) 95 | 96 | 97 | class ImportPhotos: 98 | """QGIS Plugin Implementation.""" 99 | 100 | def __init__(self, iface): 101 | """Constructor. 102 | 103 | :param iface: An interface instance that will be passed to this class 104 | which provides the hook by which you can manipulate the QGIS 105 | application at run time. 106 | :type iface: QgsInterface 107 | """ 108 | # Save reference to the QGIS interface 109 | self.iface = iface 110 | self.canvas = self.iface.mapCanvas() 111 | self.project_instance = QgsProject.instance() 112 | # initialize plugin directory 113 | self.plugin_dir = os.path.dirname(__file__) 114 | # initialize locale 115 | locale = QSettings().value('locale/userLocale')[0:2] 116 | locale_path = os.path.join( 117 | self.plugin_dir, 118 | 'i18n', 119 | 'ImportPhotos_{}.qm'.format(locale)) 120 | 121 | if os.path.exists(locale_path): 122 | self.translator = QTranslator() 123 | self.translator.load(locale_path) 124 | 125 | # Declare instance attributes 126 | self.actions = [] 127 | self.menu = self.tr('&ImportPhotos') 128 | # TODO: We are going to let the user set this up in a future iteration 129 | self.toolbar = self.iface.addToolBar('ImportPhotos') 130 | self.toolbar.setObjectName('ImportPhotos') 131 | # Renderer that will be set after the import process 132 | self.layer_renderer = None 133 | 134 | # noinspection PyMethodMayBeStatic 135 | def tr(self, message): 136 | """Get the translation for a string using Qt translation API. 137 | 138 | We implement this ourselves since we do not inherit QObject. 139 | 140 | :param message: String for translation. 141 | :type message: str, QString 142 | 143 | :returns: Translated version of message. 144 | :rtype: QString 145 | """ 146 | # noinspection PyTypeChecker,PyArgumentList,PyCallByClass 147 | return QCoreApplication.translate('ImportPhotos', message) 148 | 149 | def add_action( 150 | self, 151 | icon_path, 152 | text, 153 | callback, 154 | checkable=False, 155 | enabled_flag=True, 156 | add_to_menu=True, 157 | add_to_toolbar=True, 158 | status_tip=None, 159 | whats_this=None, 160 | parent=None): 161 | """Add a toolbar icon to the toolbar. 162 | 163 | :param icon_path: Path to the icon for this action. Can be a resource 164 | path (e.g. ':/plugins/foo/bar.png') or a normal file system path. 165 | :type icon_path: str 166 | 167 | :param text: Text that should be shown in menu items for this action. 168 | :type text: str 169 | 170 | :param callback: Function to be called when the action is triggered. 171 | :type callback: function 172 | 173 | :param enabled_flag: A flag indicating if the action should be enabled 174 | by default. Defaults to True. 175 | :type enabled_flag: bool 176 | 177 | :param add_to_menu: Flag indicating whether the action should also 178 | be added to the menu. Defaults to True. 179 | :type add_to_menu: bool 180 | 181 | :param add_to_toolbar: Flag indicating whether the action should also 182 | be added to the toolbar. Defaults to True. 183 | :type add_to_toolbar: bool 184 | 185 | :param status_tip: Optional text to show in a popup when mouse pointer 186 | hovers over the action. 187 | :type status_tip: str 188 | 189 | :param parent: Parent widget for the new action. Defaults None. 190 | :type parent: QWidget 191 | 192 | :param whats_this: Optional text to show in the status bar when the 193 | mouse pointer hovers over the action. 194 | 195 | :returns: The action that was created. Note that the action is also 196 | added to self.actions list. 197 | :rtype: QAction 198 | """ 199 | 200 | # Create the dialog (after translation) and keep reference 201 | 202 | icon = QIcon(icon_path) 203 | action = QAction(icon, text, parent) 204 | action.triggered.connect(callback) 205 | action.setEnabled(enabled_flag) 206 | 207 | if status_tip is not None: 208 | action.setStatusTip(status_tip) 209 | 210 | if whats_this is not None: 211 | action.setWhatsThis(whats_this) 212 | 213 | if add_to_toolbar: 214 | self.toolbar.addAction(action) 215 | 216 | if add_to_menu: 217 | self.iface.addPluginToMenu( 218 | self.menu, 219 | action) 220 | if checkable: 221 | action.setCheckable(checkable) 222 | 223 | self.actions.append(action) 224 | 225 | return action 226 | 227 | def initGui(self): 228 | """Create the menu entries and toolbar icons inside the QGIS GUI.""" 229 | icon_path = ':/plugins/ImportPhotos/icons/ImportImage.svg' 230 | self.add_action( 231 | icon_path, 232 | text=self.tr('Import Photos'), 233 | callback=self.run, 234 | parent=self.iface.mainWindow()) 235 | icon_path = ':/plugins/ImportPhotos/icons/SelectImage.svg' 236 | self.clickPhotos = self.add_action( 237 | icon_path, 238 | checkable=True, 239 | text=self.tr('Click Photos'), 240 | callback=self.setMouseClickMapTool, 241 | parent=self.iface.mainWindow()) 242 | icon_path = ':/plugins/ImportPhotos/icons/sync_views.svg' 243 | self.add_action( 244 | icon_path, 245 | text=self.tr('Update Photos'), 246 | callback=self.update_photos, 247 | parent=self.iface.mainWindow()) 248 | icon_path = ':/plugins/ImportPhotos/icons/export.svg' 249 | self.add_action( 250 | icon_path, 251 | text=self.tr('Bulk Export'), 252 | callback=self.bulk_export, 253 | parent=self.iface.mainWindow()) 254 | 255 | self.dlg = ImportPhotosDialog() 256 | self.dlg.ok.clicked.connect(self.import_photos) 257 | self.dlg.closebutton.clicked.connect(self.dlg.close) 258 | self.dlg.toolButtonImport.clicked.connect(self.toolButtonImport) 259 | self.dlg.toolButtonOut.clicked.connect(self.toolButtonOut) 260 | self.dlg.toolButtonRelative.clicked.connect(self.toolButtonRelative) 261 | 262 | # Add QgsRuleBasedRendererWidget 263 | # temp_layer is a class variable because we need to keep its reference 264 | # so the RendererWidget does not crash QGIS 265 | # If it's not a class variable, then it goes out of scope after this method 266 | # and as mentioned, QGIS crashes because it tries to access it. 267 | self.temp_layer = QgsVectorLayer( 268 | 'Point?crs=epsg:4326&field=ID:string&field=Name:string&' 269 | 'field=Date:date&field=Time:text&field=Lon:double&field=Lat:double' 270 | '&field=Altitude:double&field=Cam.Mak:string&field=Cam.Mod:string' 271 | '&field=Title:string&field=Comment:string&field=Path:string' 272 | '&field=RelPath:string&field=Timestamp:string&field=Images:string' 273 | '&field=Link:string&field=Description:string', 274 | 'temp_layer', 275 | 'memory') 276 | self.temp_layer.setRenderer(QgsFeatureRenderer.defaultRenderer(QgsWkbTypes.PointGeometry)) 277 | self.temp_layer.loadNamedStyle(os.path.join(self.plugin_dir, 'icons', "photos.qml")) 278 | renderer_widget = QgsRuleBasedRendererWidget( 279 | self.temp_layer, QgsStyle.defaultStyle(), 280 | self.temp_layer.renderer()) 281 | renderer_widget.setObjectName("renderer_widget") 282 | self.dlg.gridLayout.addWidget(QLabel("Output layer style"), 4, 0) 283 | self.dlg.gridLayout.addWidget(renderer_widget, 4, 2) 284 | 285 | self.toolMouseClick = MouseClick(self.canvas, self) 286 | 287 | def setMouseClickMapTool(self): 288 | 289 | # Set photos layer as active layer 290 | for layer in self.project_instance.mapLayers().values(): 291 | if layer.type() == QgsMapLayerType.VectorLayer and layer.fields().names() == FIELDS: 292 | self.iface.setActiveLayer(layer) 293 | break 294 | 295 | self.canvas.setMapTool(self.toolMouseClick) 296 | 297 | def unload(self): 298 | """Removes the plugin menu item and icon from QGIS GUI.""" 299 | for action in self.actions: 300 | self.iface.removePluginMenu( 301 | self.tr('&ImportPhotos'), 302 | action) 303 | self.iface.removeToolBarIcon(action) 304 | # remove the toolbar 305 | del self.toolbar 306 | 307 | def run(self): 308 | if CHECK_MODULE == '': 309 | self.showMessage( 310 | self.tr('Python Modules'), 311 | self.tr('Please install python module "exifread" or "PIL".'), 312 | 'Warning') 313 | return 314 | 315 | self.dlg.out.setText('') 316 | self.dlg.imp.setText('') 317 | self.dlg.canvas_extent.setChecked(False) 318 | self.dlg.show() 319 | 320 | def toolButtonOut(self): 321 | 322 | outputPath, selected_extension_filter = QFileDialog.getSaveFileName( 323 | self.dlg, 324 | self.tr("Save output layer"), os.path.expanduser('~'), 325 | ";;".join(list(SUPPORTED_OUTPUT_FILE_EXTENSIONS.keys()))) 326 | 327 | if outputPath: 328 | extension = SUPPORTED_OUTPUT_FILE_EXTENSIONS[selected_extension_filter] 329 | if os.path.splitext(outputPath)[1] == '': 330 | # Add extension to filepath if user did not specify it 331 | self.dlg.out.setText(outputPath + extension) 332 | else: 333 | # Set extension with the specified filter 334 | self.dlg.out.setText(os.path.splitext(outputPath)[0] + extension) 335 | 336 | def get_path_relative_to_project_root(self, abs_path): 337 | project_folder = QFileInfo( 338 | self.project_instance.fileName()).absolutePath() 339 | try: 340 | rel_path = os.path.relpath( 341 | path=os.path.normpath(abs_path), start=project_folder) 342 | except ValueError: 343 | # On Windows, when path and start are on different drives. 344 | rel_path = os.path.normpath(abs_path) 345 | return rel_path 346 | 347 | def toolButtonRelative(self): 348 | directory_path = QFileDialog.getExistingDirectory( 349 | self.dlg, self.tr('Select a folder:'), 350 | os.path.expanduser('~'), QFileDialog.ShowDirsOnly) 351 | 352 | if directory_path: 353 | self.selected_folder = directory_path[:] 354 | self.dlg.relativeroot.setText(directory_path) 355 | 356 | def toolButtonImport(self): 357 | directory_path = QFileDialog.getExistingDirectory( 358 | self.dlg, self.tr('Select a folder'), 359 | os.path.expanduser('~'), QFileDialog.ShowDirsOnly) 360 | 361 | if directory_path: 362 | self.selected_folder = directory_path[:] 363 | self.dlg.imp.setText(directory_path) 364 | 365 | def import_photos(self): 366 | self.layer_renderer = self.dlg.findChild(QgsRuleBasedRendererWidget, "renderer_widget").renderer() 367 | 368 | file_not_found = False 369 | if self.dlg.imp.text() == '' and not os.path.isdir(self.dlg.imp.text()): # should have been or? 370 | file_not_found = True 371 | msg = self.tr('Please select a directory photos.') 372 | if self.dlg.out.text() == '' and not os.path.isabs(self.dlg.out.text()): # should have been or? 373 | file_not_found = True 374 | msg = self.tr('Please define output file location.') 375 | 376 | if file_not_found: 377 | self.showMessage('Warning', msg, 'Warning') 378 | return 379 | 380 | if self.dlg.relativeroot.text() == '': 381 | self.relativeroot = self.dlg.imp.text() 382 | else: 383 | self.relativeroot = self.dlg.relativeroot.text() 384 | 385 | self.webroot = self.dlg.webroot.text() # Will be checked later if it is '' 386 | 387 | # get paths of photos 388 | self.photos_to_import = [] 389 | for root, dirs, files in os.walk(self.dlg.imp.text()): 390 | for filename in files: 391 | if filename.lower().endswith(tuple(SUPPORTED_PHOTOS_EXTENSIONS)): 392 | self.photos_to_import.append(os.path.join(root, filename)) 393 | 394 | if len(self.photos_to_import) == 0: 395 | self.showMessage('Warning', self.tr('No photos were found!'), 'Warning') 396 | return 397 | 398 | # Set up for url: 399 | 400 | self.dlg.close() 401 | self.call_import_photos() 402 | # QGuiApplication.setOverrideCursor(Qt.WaitCursor) 403 | # photos_to_import.sort() 404 | # try: 405 | # result = self.import_photos_task(photos_to_import) 406 | # self.completed(result) 407 | # except Exception as e: 408 | # self.showMessage(self.tr('Unexpected Error'), str(e), 'Warning') 409 | # QGuiApplication.restoreOverrideCursor() 410 | 411 | def call_import_photos(self): 412 | # self.import_photos_task('', '') 413 | # self.completed('') 414 | self.taskPhotos = QgsTask.fromFunction('ImportPhotos', self.import_photos_task, 415 | on_finished=self.completed, wait_time=4) 416 | QgsApplication.taskManager().addTask(self.taskPhotos) 417 | 418 | def stopped(self, task): 419 | QgsMessageLog.logMessage( 420 | 'Task "{name}" was canceled'.format( 421 | name=task.description()), 422 | 'ImportPhotos', Qgis.Info) 423 | 424 | def import_photos_task(self, task, wait_time): 425 | self.temp_photos_layer = self.project_instance.addMapLayer( 426 | QgsVectorLayer("Point?crs=epsg:4326", None, "memory"), False) 427 | 428 | imported_photos_counter = 0 429 | out_of_bounds_photos_counter = 0 430 | no_location_photos_counter = 0 431 | editing_started = self.temp_photos_layer.startEditing() 432 | 433 | self.photos = [] 434 | self.photos_names = [] 435 | for root, dirs, files in os.walk(self.selected_folder): 436 | for name in files: 437 | if name.lower().endswith(tuple(SUPPORTED_PHOTOS_EXTENSIONS)): 438 | self.photos.append(os.path.join(root, name)) 439 | 440 | self.initphotos = len(self.photos) 441 | if editing_started: 442 | # Import new pictures 443 | attribute_fields_set = False 444 | 445 | for count, photo_path in enumerate(self.photos_to_import): 446 | try: 447 | if not os.path.isdir(photo_path) and photo_path.lower().endswith( 448 | tuple(SUPPORTED_PHOTOS_EXTENSIONS)): 449 | geo_info = self.get_geo_infos_from_photo(photo_path) 450 | if geo_info and geo_info["properties"]["Lat"] and geo_info["properties"]["Lon"]: 451 | geo_info = json.dumps(geo_info) 452 | fields = QgsJsonUtils.stringToFields(geo_info, CODEC) 453 | 454 | if not attribute_fields_set: 455 | attribute_fields_set = True 456 | for field in fields.toList(): 457 | self.temp_photos_layer.addAttribute(field) 458 | 459 | feature = QgsJsonUtils.stringToFeatureList( 460 | geo_info, fields, CODEC)[0] 461 | 462 | self.temp_photos_layer.addFeature(feature) 463 | imported_photos_counter += 1 464 | elif geo_info == 'out': 465 | out_of_bounds_photos_counter += 1 466 | elif geo_info is False: 467 | no_location_photos_counter += 1 468 | except: 469 | pass 470 | 471 | if not editing_started or not self.temp_photos_layer.commitChanges(): 472 | self.project_instance.removeMapLayer(self.temp_photos_layer) 473 | title = self.tr('Import Photos') 474 | msg = "{}\n\n{} {}".format( 475 | self.tr("Import Failed."), 476 | self.tr("Details:"), 477 | "\n".join(self.temp_photos_layer.commitErrors())) 478 | self.showMessage(title, msg, 'Warning') 479 | self.result = False, len( 480 | self.photos_to_import), imported_photos_counter, out_of_bounds_photos_counter, no_location_photos_counter 481 | 482 | # Save vector layer as a Shapefile 483 | driver = EXTENSION_DRIVERS[os.path.splitext(self.dlg.out.text())[1]] 484 | error_code, error_message = QgsVectorFileWriter.writeAsVectorFormat( 485 | self.temp_photos_layer, self.dlg.out.text(), "utf-8", 486 | QgsCoordinateReferenceSystem(self.temp_photos_layer.crs().authid()), 487 | driver) 488 | 489 | if error_code != 0: 490 | self.project_instance.removeMapLayer(self.temp_photos_layer) 491 | self.showMessage(self.tr('Writing output file error'), error_message, 'Warning') 492 | return False, len( 493 | self.photos_to_import), imported_photos_counter, out_of_bounds_photos_counter, no_location_photos_counter 494 | 495 | self.project_instance.removeMapLayer(self.temp_photos_layer) 496 | self.setMouseClickMapTool() 497 | 498 | self.result = True, len( 499 | self.photos_to_import), imported_photos_counter, out_of_bounds_photos_counter, no_location_photos_counter 500 | 501 | def completed(self, result): 502 | 503 | import_ok, photos_to_import_number, imported_photos_counter, out_of_bounds_photos_counter, no_location_photos_counter = self.result 504 | no_location_photos_counter = no_location_photos_counter + photos_to_import_number - imported_photos_counter - out_of_bounds_photos_counter 505 | 506 | if import_ok: 507 | if imported_photos_counter == 0: 508 | title = self.tr('ImportPhotos') 509 | msg = '{}\n\n{}\n {}'.format( 510 | self.tr('Import Completed.'), 511 | self.tr('Details:'), 512 | self.tr('No new photos were added.')) 513 | else: 514 | title = self.tr('ImportPhotos') 515 | msg = '{}\n\n{}\n {} {}\n {} {}\n {} {}\n'.format( 516 | self.tr('Import Completed.'), 517 | self.tr('Details:'), 518 | str(int(imported_photos_counter)), 519 | self.tr('photo(s) added without error.'), 520 | str(int(no_location_photos_counter)), 521 | self.tr('photo(s) skipped (because of missing location).'), 522 | str(int(out_of_bounds_photos_counter)), 523 | self.tr('photo(s) skipped (because not in canvas extent).')) 524 | self.showMessage(title, msg, self.tr('Information')) 525 | 526 | self.layerPhotos_final = QgsVectorLayer( 527 | self.dlg.out.text(), 528 | os.path.basename(self.dlg.out.text()).split(".")[0], 529 | "ogr") 530 | 531 | self.layerPhotos_final.setReadOnly(False) 532 | self.layerPhotos_final.setRenderer(self.layer_renderer.clone()) 533 | self.layerPhotos_final.reload() 534 | self.layerPhotos_final.triggerRepaint() 535 | self.project_instance.addMapLayer(self.layerPhotos_final) 536 | 537 | expression = """ 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 |
[% Name %]
546 | """ 547 | self.layerPhotos_final.setMapTipTemplate(expression) 548 | 549 | def layer_selector(self, title: str = 'Select layer to update'): 550 | layers = {} 551 | 552 | for layer in self.project_instance.mapLayers().values(): 553 | if layer.type() == QgsMapLayerType.VectorLayer and all( 554 | field in layer.fields().names() for field in FIELDS): 555 | layers[layer.name()] = layer 556 | 557 | if layers.keys(): 558 | selected_layer_name, ok = QInputDialog.getItem( 559 | self.iface.mainWindow(), 560 | self.tr(title), 561 | "Layer List:", layers.keys(), 0, False) 562 | else: 563 | self.showMessage('Error', self.tr('No photos layer(s) found'), 'Warning') 564 | return 565 | 566 | if not ok: 567 | return 568 | 569 | return layers[selected_layer_name] 570 | 571 | def update_photos(self): 572 | self.selected_layer = self.layer_selector() 573 | if not self.selected_layer: 574 | return 575 | 576 | # All picture paths that are currently saved in the shapefile layer 577 | picture_paths = [] 578 | # Path of the parent directory where the pictures are saved in 579 | base_picture_directory = "" 580 | # Feature fields 581 | basic_feature_fields = None 582 | 583 | for feature in self.selected_layer.getFeatures(): 584 | if not base_picture_directory: 585 | base_picture_directory = os.path.dirname(feature.attribute("Path")) 586 | basic_feature_fields = feature.fields() 587 | picture_paths.append(os.path.basename(feature.attribute("Path"))) 588 | 589 | # Pictures that should be removed from the layer 590 | self.selected_folder = base_picture_directory 591 | list_pictures = [] 592 | try: 593 | for root, dirs, files in os.walk(base_picture_directory): 594 | for name in files: 595 | if name.lower().endswith(tuple(SUPPORTED_PHOTOS_EXTENSIONS)): 596 | list_pictures.append(name) 597 | except: 598 | pass 599 | 600 | pictures_to_remove = list(set(picture_paths) - set(list_pictures)) 601 | pictures_to_add = sorted(list(set(list_pictures) - set(picture_paths))) 602 | 603 | editing_started = self.selected_layer.startEditing() 604 | if editing_started: 605 | 606 | try: 607 | # Remove pictures that do not exist anymore in base_picture_directory 608 | for feature in self.selected_layer.getFeatures(): 609 | if os.path.basename(feature.attribute("Path")) in pictures_to_remove: 610 | self.selected_layer.deleteFeature(feature.id()) 611 | 612 | # Import new pictures 613 | imported_pictures_counter = 0 614 | out_of_bounds_photos_counter = 0 615 | photos_to_import_counter = 0 616 | no_location_photos_counter = 0 617 | if self.selected_layer.source().lower().endswith("gpkg"): 618 | idx = self.selected_layer.dataProvider().fieldNameIndex('fid') 619 | counter = self.selected_layer.maximumValue(idx) 620 | for picture_path in pictures_to_add: 621 | if picture_path.lower().endswith(tuple(SUPPORTED_PHOTOS_EXTENSIONS)): 622 | photos_to_import_counter += 1 623 | geo_info = self.get_geo_infos_from_photo(os.path.join(base_picture_directory, picture_path)) 624 | if geo_info and geo_info["properties"]["Lat"] and geo_info["properties"]["Lon"]: 625 | # QGIS automatically adds the fid attribute when saving the photos layer 626 | if self.selected_layer.source().lower().endswith("gpkg"): 627 | geo_info["properties"]["fid"] = counter + 1 628 | counter += 1 629 | self.selected_layer.addFeatures( 630 | QgsJsonUtils.stringToFeatureList( 631 | json.dumps(geo_info), basic_feature_fields, CODEC)) 632 | imported_pictures_counter += 1 633 | elif geo_info == 'out': 634 | out_of_bounds_photos_counter += 1 635 | elif geo_info is False: 636 | no_location_photos_counter += 1 637 | except: 638 | pass 639 | 640 | if not editing_started or not self.selected_layer.commitChanges(): 641 | title = self.tr('Update Photos') 642 | msg = self.tr( 643 | "Update Failed.\n\nDetails:\n Could not update the photos layer.\n " 644 | "Layer is either read-only or you don't have permissions to edit it.") 645 | self.showMessage(title, msg, 'Warning') 646 | return 647 | 648 | no_location_photos_counter = no_location_photos_counter + photos_to_import_counter - imported_pictures_counter - out_of_bounds_photos_counter 649 | title = self.tr('Update Photos') 650 | msg = '{}\n\n{}\n {} {}\n {} {}\n {} {}\n {} {}'.format( 651 | self.tr('Update Completed.'), 652 | self.tr('Details:'), 653 | str(int(imported_pictures_counter)), 654 | self.tr('photo(s) added without error.'), 655 | str(int(no_location_photos_counter)), 656 | self.tr('photo(s) skipped (because of missing location).'), 657 | str(int(out_of_bounds_photos_counter)), 658 | self.tr('photo(s) skipped (because not in canvas extent).'), 659 | str(int(len(pictures_to_remove))), 660 | self.tr('photo(s) removed.')) 661 | 662 | self.showMessage(title, msg, 'Information') 663 | 664 | def bulk_export(self): 665 | self.selected_layer = self.layer_selector('Select layer to export') 666 | if not self.selected_layer: 667 | return 668 | 669 | path_column_index = self.selected_layer.fields().indexFromName('Path') 670 | 671 | directory_path = QFileDialog.getExistingDirectory( 672 | self.dlg, self.tr('Select an output folder'), 673 | os.path.expanduser('~'), QFileDialog.ShowDirsOnly) 674 | if not directory_path: 675 | return 676 | 677 | images = self.selected_layer.getFeatures() 678 | for image in images: 679 | src_path = Path(image.attributes()[path_column_index]) 680 | dest_dir = Path(directory_path) 681 | dest_filename = dest_dir / Path(f"{src_path.parent.name}_{src_path.name}") 682 | dest_filename.write_bytes(src_path.read_bytes()) 683 | 684 | self.showMessage('Success', self.tr('Export complete.'), self.tr('Information')) 685 | return 686 | 687 | def get_geo_infos_from_photo(self, photo_path): 688 | try: 689 | rel_path = self.get_path_relative_to_project_root(photo_path) 690 | if self.webroot != '': 691 | webrelpath = os.path.relpath(photo_path, self.relativeroot) 692 | url = self.webroot + webrelpath 693 | ImagesSrc = '' 694 | else: 695 | url = 'file:///'+photo_path 696 | ImagesSrc = '' 697 | # This will make a clickable link in kml 698 | description = f'{os.path.basename(photo_path)}' 699 | if CHECK_MODULE == 'exifread': 700 | with open(photo_path, 'rb') as imgpathF: 701 | tags = exifread.process_file(imgpathF, details=False) 702 | 703 | if not set(tags.keys()).union({"GPS GPSLongitude", "GPS GPSLatitude"}): 704 | return False 705 | 706 | lat, lon = self.get_exif_location(tags, "lonlat") 707 | 708 | if 'GPS GPSAltitude' in tags and abs(float(tags.get("GPS GPSAltitude").values[0].den)) > 0: 709 | altitude = float(tags.get("GPS GPSAltitude").values[0].num) / float( 710 | tags.get("GPS GPSAltitude").values[0].den) 711 | else: 712 | altitude = None 713 | 714 | uuid_ = str(uuid.uuid4()) 715 | 716 | try: 717 | dt1, dt2 = tags["EXIF DateTimeOriginal"].values.split(' ') 718 | date = dt1.replace(':', '/') 719 | time_ = dt2 720 | timestamp = dt1.replace(':', '-') + 'T' + time_ 721 | except: 722 | try: 723 | date = tags["GPS GPSDate"].values.replace(':', '/') 724 | tt = [str(i) for i in tags["GPS GPSTimeStamp"].values] 725 | time_ = "{:0>2}:{:0>2}:{:0>2}".format(tt[0], tt[1], tt[2]) 726 | timestamp = tags["GPS GPSDate"].values.replace(':', '-') + 'T' + time_ 727 | except: 728 | date = None 729 | time_ = None 730 | timestamp = None 731 | 732 | try: 733 | if 'GPS GPSImgDirection' in tags: 734 | azimuth = float(tags["GPS GPSImgDirection"].values[0].num) / float( 735 | tags["GPS GPSImgDirection"].values[0].den) 736 | else: 737 | azimuth = None 738 | except: 739 | azimuth = None 740 | 741 | try: 742 | if 'GPS GPSImgDirectionRef' in tags: 743 | north = str(tags["GPS GPSImgDirectionRef"].values) 744 | else: 745 | north = '' 746 | except: 747 | north = '' 748 | 749 | try: 750 | if 'Image Make' in tags: 751 | maker = tags['Image Make'] 752 | else: 753 | maker = '' 754 | except: 755 | maker = '' 756 | 757 | try: 758 | if 'Image Model' in tags: 759 | model = tags['Image Model'] 760 | else: 761 | model = '' 762 | except: 763 | model = '' 764 | 765 | try: 766 | if 'Image ImageDescription' in tags: 767 | title = tags['Image ImageDescription'] 768 | else: 769 | title = '' 770 | except: 771 | title = '' 772 | 773 | try: 774 | if 'EXIF UserComment' in tags: 775 | user_comm = tags['EXIF UserComment'].printable 776 | else: 777 | user_comm = '' 778 | except: 779 | user_comm = '' 780 | 781 | elif CHECK_MODULE == 'PIL': 782 | a = {} 783 | with Image.open(photo_path) as img: 784 | info = img._getexif() 785 | 786 | if info is None: 787 | return False 788 | 789 | for tag, value in info.items(): 790 | if ( 791 | TAGS.get(tag, tag) == 'GPSInfo' or 792 | TAGS.get(tag, tag) == 'DateTime' or 793 | TAGS.get(tag, tag) == 'DateTimeOriginal' 794 | ): 795 | a[TAGS.get(tag, tag)] = value 796 | 797 | if a == {}: 798 | return False 799 | 800 | if a['GPSInfo'] != {}: 801 | if 1 and 2 and 3 and 4 in a['GPSInfo']: 802 | lat = a['GPSInfo'][2] 803 | latref = a['GPSInfo'][1] 804 | lon = a['GPSInfo'][4] 805 | lonref = a['GPSInfo'][3] 806 | 807 | lat = float(lat[0] + lat[1] / 60 + lat[2] / 3600) 808 | lon = float(lon[0] + lon[1] / 60 + lon[2] / 3600) 809 | 810 | if latref == 'S': 811 | lat = -lat 812 | if lonref == 'W': 813 | lon = -lon 814 | else: 815 | return False 816 | 817 | uuid_ = str(uuid.uuid4()) 818 | if 'DateTime' or 'DateTimeOriginal' in a: 819 | if 'DateTime' in a: 820 | dt1, dt2 = a['DateTime'].split() 821 | if 'DateTimeOriginal' in a: 822 | dt1, dt2 = a['DateTimeOriginal'].split() 823 | date = dt1.replace(':', '/') 824 | time_ = dt2 825 | timestamp = dt1.replace(':', '-') + 'T' + time_ 826 | 827 | try: 828 | if 6 in a['GPSInfo']: 829 | altitude = float(a['GPSInfo'][6]) 830 | else: 831 | altitude = None 832 | except: 833 | altitude = None 834 | 835 | try: 836 | if 16 and 17 in a['GPSInfo']: 837 | north = a['GPSInfo'][16] 838 | azimuth = float(a['GPSInfo'][17]) 839 | else: 840 | north = '' 841 | azimuth = None 842 | except: 843 | north = '' 844 | azimuth = None 845 | 846 | maker = '' 847 | model = '' 848 | user_comm = '' 849 | title = '' 850 | 851 | if self.dlg.canvas_extent.isChecked(): 852 | if not (self.canvas.extent().xMaximum() > lon > self.canvas.extent().xMinimum() \ 853 | and self.canvas.extent().yMaximum() > lat > self.canvas.extent().yMinimum()): 854 | return 'out' 855 | 856 | geo_info = { 857 | "type": "Feature", 858 | "properties": { 859 | 'ID': uuid_, 'Name': os.path.basename(photo_path), 860 | 'Date': date, 'Time': time_, 861 | 'Lon': lon, 'Lat': lat, 'Altitude': altitude, 862 | 'North': north, 'Azimuth': azimuth, 863 | 'Cam. Maker': str(maker), 'Cam. Model': str(model), 864 | 'Title': str(title), 'Comment': user_comm, 865 | 'Path': photo_path, 'RelPath': rel_path, 866 | 'Timestamp': timestamp, 'Images': ImagesSrc, 'Link': url, 867 | 'Description': description 868 | }, 869 | "geometry": { 870 | "coordinates": [lon, lat], 871 | "type": "Point" 872 | } 873 | } 874 | 875 | try: 876 | if self.selected_layer.source().lower().endswith("gpkg"): 877 | geo_info = { 878 | "type": "Feature", 879 | "properties": { 880 | 'fid': 0, 'ID': uuid_, 'Name': os.path.basename(photo_path), 881 | 'Date': date, 'Time': time_, 882 | 'Lon': lon, 'Lat': lat, 'Altitude': altitude, 883 | 'North': north, 'Azimuth': azimuth, 884 | 'Cam. Maker': str(maker), 'Cam. Model': str(model), 885 | 'Title': str(title), 'Comment': user_comm, 886 | 'Path': photo_path, 'RelPath': rel_path, 887 | 'Timestamp': timestamp, 'Images': ImagesSrc, 'Link': url, 888 | 'Description': description 889 | }, 890 | "geometry": { 891 | "coordinates": [lon, lat], 892 | "type": "Point" 893 | } 894 | } 895 | except: 896 | pass 897 | # geo_info should exist from default 898 | return geo_info 899 | 900 | except Exception as e: 901 | # print(e) # Can be uncommented for debugging 902 | return '' 903 | 904 | def showMessage(self, title, msg, icon): 905 | if icon == 'Warning': 906 | icon = QMessageBox.Warning 907 | elif icon == 'Information': 908 | icon = QMessageBox.Information 909 | 910 | msgBox = QMessageBox() 911 | msgBox.setIcon(icon) 912 | msgBox.setWindowTitle(title) 913 | msgBox.setText(msg) 914 | msgBox.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint) 915 | QGuiApplication.restoreOverrideCursor() 916 | msgBox.exec_() 917 | 918 | def refresh(self): 919 | self.iface.mainWindow().findChild( 920 | QAction, 'mActionDeselectAll').trigger() 921 | self.canvas.refresh() 922 | 923 | ###################################################### 924 | # based on http://www.codegists.com/snippet/python/exif_gpspy_snakeye_python 925 | 926 | def get_exif_location(self, exif_data, lonlat): 927 | """ 928 | Returns the latitude and longitude, if available, from the provided exif_data (obtained through get_exif_data above) 929 | """ 930 | 931 | if lonlat == 'lonlat': 932 | lat = '' 933 | lon = '' 934 | gps_latitude = self._get_if_exist(exif_data, 'GPS GPSLatitude') 935 | gps_latitude_ref = self._get_if_exist(exif_data, 'GPS GPSLatitudeRef') 936 | gps_longitude = self._get_if_exist(exif_data, 'GPS GPSLongitude') 937 | gps_longitude_ref = self._get_if_exist(exif_data, 'GPS GPSLongitudeRef') 938 | 939 | if gps_latitude and gps_latitude_ref and gps_longitude and gps_longitude_ref: 940 | lat = self._convert_to_degress(gps_latitude) 941 | if gps_latitude_ref.values[0] != 'N': 942 | lat = 0 - lat 943 | 944 | lon = self._convert_to_degress(gps_longitude) 945 | if gps_longitude_ref.values[0] != 'E': 946 | lon = 0 - lon 947 | 948 | return lat, lon 949 | 950 | def _get_if_exist(self, data, key): 951 | if key in data: 952 | return data[key] 953 | 954 | return None 955 | 956 | def _convert_to_degress(self, value): 957 | """ 958 | Helper function to convert the GPS coordinates stored in the EXIF to degress in float format 959 | 960 | :param value: 961 | :type value: exifread.utils.Ratio 962 | :rtype: float 963 | """ 964 | d = float(value.values[0].num) / float(value.values[0].den) 965 | m = float(value.values[1].num) / float(value.values[1].den) 966 | s = float(value.values[2].num) / float(value.values[2].den) 967 | 968 | return d + (m / 60.0) + (s / 3600.0) 969 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | ImportPhotos is a QGIS plugin that written in Python. 635 | This tool can be used to import Geo-Tagged photos (jpg or jpeg) as points to QGIS. The user is able to select a folder with photos and only the geo-tagged photos will be taken. Then a geoJSON point file will be created which will contain the name of the picture, its directory, the date and time taken, altitude, longitude, latitude, azimuth, north and camera maker and model. The plug-in doesn’t need any third party applications to work. It has two buttons; the one is to import geotagged photos, and the other one is to be able to click on a point and display the photo along with information regarding the date time and altitude. 636 | Copyright (C) 2018 Marios S. Kyriakou, George A. Christou, KIOS Research and Innovation Center of Excellence (KIOS CoE) 637 | 638 | This program is free software: you can redistribute it and/or modify 639 | it under the terms of the GNU General Public License as published by 640 | the Free Software Foundation, either version 3 of the License, or 641 | (at your option) any later version. 642 | 643 | This program is distributed in the hope that it will be useful, 644 | but WITHOUT ANY WARRANTY; without even the implied warranty of 645 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 646 | GNU General Public License for more details. 647 | 648 | You should have received a copy of the GNU General Public License 649 | along with this program. If not, see . 650 | 651 | Also add information on how to contact you by electronic and paper mail. 652 | 653 | If the program does terminal interaction, make it output a short 654 | notice like this when it starts in an interactive mode: 655 | 656 | ImportPhotos Copyright (C) 2018 Marios S. Kyriakou, George A. Christou, KIOS Research and Innovation Center of Excellence (KIOS CoE) 657 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 658 | This is free software, and you are welcome to redistribute it 659 | under certain conditions; type `show c' for details. 660 | 661 | The hypothetical commands `show w' and `show c' should show the appropriate 662 | parts of the General Public License. Of course, your program's commands 663 | might be different; for a GUI interface, you would use an "about box". 664 | 665 | You should also get your employer (if you work as a programmer) or school, 666 | if any, to sign a "copyright disclaimer" for the program, if necessary. 667 | For more information on this, and how to apply and follow the GNU GPL, see 668 | . 669 | 670 | The GNU General Public License does not permit incorporating your program 671 | into proprietary programs. If your program is a subroutine library, you 672 | may consider it more useful to permit linking proprietary applications with 673 | the library. If this is what you want to do, use the GNU Lesser General 674 | Public License instead of this License. But first, please read 675 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |  2 | 3 | ![ImportPhotos Downloads](https://img.shields.io/badge/dynamic/json?formatter=metric&color=green&label=ImportPhotos-downloads&query=%24.ImportPhotos.downloads&url=https://raw.githubusercontent.com/Mariosmsk/qgis-plugins-downloads/main/data/plugins.json) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3384824.svg)](https://doi.org/10.5281/zenodo.3384824) 4 | 5 | ## How to cite 6 | 7 | If you find the **"ImportPhotos" QGIS plugin** useful in your research or work, we kindly request that you cite our paper. This helps support our work and ensures that we can continue developing and maintaining the plugin. Here's the citation for your convenience: 8 | 9 | Kyriakou, M., Christou, G., & Kolios, P. (2019). *ImportPhotos: a QGIS plugin to visualise geotagged photos*. Zenodo. [DOI:10.5281/zenodo.3384824](https://doi.org/10.5281/zenodo.3384824) 10 | 11 | Thank you for your support! 12 | 13 | ``` 14 | @INPROCEEDINGS{kyriakou2019, 15 | author={Kyriakou, Marios and Christou, Georgios and Kolios, Panayiotis}, 16 | title={ImportPhotos: a QGIS plugin to visualise geotagged photos}, 17 | month= {jul}, 18 | year= {2019}, 19 | DOI= {10.5281/zenodo.3384824}} 20 | ``` 21 | 22 | # ImportPhotos 23 | 24 | QGIS plugin 25 | 26 | This tool can be used to import Geo-Tagged photos (jpg or jpeg) as points to QGIS. The user is able to select a folder with photos and only the geo-tagged photos will be taken. Then a layer will be created which it will contain the name of the picture, its directory, the date and time taken, altitude, longitude, latitude, azimuth, north, camera maker and model, title, user comment and relative path. The plug-in doesn’t need any third party applications to work. It has two buttons; the one is to import geotagged photos, and the other one is to be able to click on a point and display the photo along with information regarding the date time and altitude. The user can create one of the following file types: GeoJSON, SHP, GPKG, CSV, KML, TAB. When the user saves a project and wants to reopen it, the folder with the pictures should stay at the original file location or moved at the same location of the project (e.g. *.qgz) in order to be able to view the pictures.* The new version of Import photos gives the ability to the user to use several basic filters on the image and save the picture. To use additional filters, the user needs to use the python package *opencv-python*. 27 | 28 | Latest version 3.0.7:

29 | ![image](https://github.com/user-attachments/assets/ecfa56f8-615f-43fe-87c7-5fb57fe78896) 30 | 31 | ![image](https://github.com/user-attachments/assets/02719e75-f319-4f94-a075-5a6e373801a7) 32 | 33 | Tutorial on youtube:

34 | [![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/Y3R8gHJUrrk/0.jpg)](https://www.youtube.com/watch?v=Y3R8gHJUrrk) 35 | 36 | QGIS 3 37 | Mac Users. Requires the following Python Modules to be installed: UnixImageIO, FreeType, PIL Please visit: http://www.kyngchaos.com/software/python 38 | 39 | ## Updated version 40 | 41 | 42 | 43 | 44 | # Contributors # 45 | * Marios S. Kyriakou, [KIOS Research and Innovation Center of Excellence (KIOS CoE)](https://www.kios.ucy.ac.cy/) 46 | * George A. Christou, [KIOS Research and Innovation Center of Excellence (KIOS CoE)](https://www.kios.ucy.ac.cy/) 47 | * Panayiotis S. Kolios, [KIOS Research and Innovation Center of Excellence (KIOS CoE)](https://www.kios.ucy.ac.cy/) 48 | * Demetris G. Eliades, [KIOS Research and Innovation Center of Excellence (KIOS CoE)](https://www.kios.ucy.ac.cy/) 49 | 50 | * [QGIS Cyprus](https://www.facebook.com/qgiscyprus/) 51 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | ImportPhotos 5 | A QGIS plugin 6 | Import photos jpegs 7 | ------------------- 8 | begin : 2018-08-25 9 | git sha : $Format:%H$ 10 | copyright : (C) 2018 by KIOS Research Center 11 | email : mariosmsk@gmail.com 12 | ***************************************************************************/ 13 | 14 | /*************************************************************************** 15 | * * 16 | * This program is free software; you can redistribute it and/or modify * 17 | * it under the terms of the GNU General Public License as published by * 18 | * the Free Software Foundation; either version 2 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | ***************************************************************************/ 22 | """ 23 | 24 | # noinspection PyPep8Naming 25 | def classFactory(iface): # pylint: disable=invalid-name 26 | """Load ImportPhotos class from file ImportPhotos. 27 | 28 | :param iface: A QGIS interface instance. 29 | :type iface: QgsInterface 30 | """ 31 | # 32 | from .ImportPhotos import ImportPhotos 33 | return ImportPhotos(iface) 34 | -------------------------------------------------------------------------------- /code/MouseClick.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | ImportPhotos 5 | A QGIS plugin 6 | Import photos 7 | last update : 04/01/2023 8 | begin : February 2018 9 | copyright : (C) 2019 by KIOS Research Center 10 | email : mariosmsk@gmail.com 11 | ***************************************************************************/ 12 | /*************************************************************************** 13 | * * 14 | * This program is free software; you can redistribute it and/or modify * 15 | * it under the terms of the GNU General Public License as published by * 16 | * the Free Software Foundation; either version 2 of the License, or * 17 | * (at your option) any later version. * 18 | * * 19 | ***************************************************************************/ 20 | """ 21 | 22 | import os.path 23 | 24 | from qgis.PyQt.QtCore import (Qt, pyqtSignal, QCoreApplication, QFileInfo, QRectF) 25 | from qgis.PyQt.QtGui import (QPixmap, QImage) 26 | from qgis.core import (QgsRectangle, QgsProject) 27 | from qgis.gui import (QgsMapTool) 28 | 29 | from .PhotosViewer import PhotoWindow 30 | 31 | 32 | # Mouseclik import file 33 | class MouseClick(QgsMapTool): 34 | afterLeftClick = pyqtSignal() 35 | afterRightClick = pyqtSignal() 36 | afterDoubleClick = pyqtSignal() 37 | 38 | def __init__(self, canvas, drawSelf): 39 | QgsMapTool.__init__(self, canvas) 40 | self.canvas = canvas 41 | self.drawSelf = drawSelf 42 | self.drawSelf.rb = None 43 | self.photosDLG = None 44 | 45 | def canvasPressEvent(self, event): 46 | if event.button() == 1: 47 | # sigeal : keep photo viewer on top of other windows 48 | if self.photosDLG is not None: 49 | self.photosDLG.setWindowFlags(Qt.WindowStaysOnTopHint) 50 | self.drawSelf.refresh() 51 | 52 | def canvasMoveEvent(self, event): 53 | pass 54 | 55 | # sigeal : display photo on click instead of double-click 56 | # def canvasReleaseEvent(self, event): 57 | def canvasDoubleClickEvent(self, event): 58 | pass 59 | 60 | # sigeal : display photo on click instead of double-click 61 | # def canvasDoubleClickEvent(self, event): 62 | def canvasReleaseEvent(self, event): 63 | layers = self.canvas.layers() 64 | p = self.toMapCoordinates(event.pos()) 65 | w = self.canvas.mapUnitsPerPixel() * 10 66 | try: 67 | rect = QgsRectangle(p.x() - w, p.y() - w, p.x() + w, p.y() + w) 68 | except: 69 | return 70 | layersSelected = [] 71 | for layer in layers: 72 | if layer.type(): 73 | continue 74 | fields = [field.name().upper() for field in layer.fields()] 75 | if 'PATH' or 'PHOTO' in fields: 76 | lRect = self.canvas.mapSettings().mapToLayerCoordinates(layer, rect) 77 | layer.selectByRect(lRect) 78 | selected_features = layer.selectedFeatures() 79 | if selected_features != []: 80 | layersSelected.append(layer) 81 | ########## SHOW PHOTOS ############ 82 | feature = selected_features[0] 83 | self.drawSelf.featureIndex = feature.id() 84 | activeLayerChanged = not hasattr(self.drawSelf, 'layerActive') or ( 85 | self.drawSelf.layerActive != layer) 86 | self.drawSelf.layerActive = layer 87 | self.drawSelf.fields = fields 88 | self.drawSelf.maxlen = len(self.drawSelf.layerActive.name()) 89 | self.drawSelf.layerActiveName = layer.name() 90 | self.drawSelf.iface.setActiveLayer(layer) 91 | 92 | if self.drawSelf.maxlen > 13: 93 | self.drawSelf.maxlen = 14 94 | self.drawSelf.layerActiveName = self.drawSelf.layerActive.name() + '...' 95 | 96 | if 'PATH' in fields: 97 | imPath = feature.attributes()[feature.fieldNameIndex('Path')] 98 | elif 'PHOTO' in fields: 99 | imPath = feature.attributes()[feature.fieldNameIndex('photo')] 100 | else: 101 | return 102 | 103 | self.drawSelf.prj = QgsProject.instance() 104 | try: 105 | if not os.path.exists(imPath): 106 | if self.drawSelf.prj.fileName() and 'RELPATH' in fields: 107 | imPath = os.path.join(QFileInfo(self.drawSelf.prj.fileName()).absolutePath(), 108 | feature.attributes()[feature.fieldNameIndex('RelPath')]) 109 | else: 110 | c = self.drawSelf.noImageFound() 111 | if c: 112 | return 113 | except: 114 | c = self.drawSelf.noImageFound() 115 | if c: 116 | return 117 | 118 | self.drawSelf.getImage = QImage(imPath) 119 | 120 | if self.photosDLG is None or activeLayerChanged: 121 | self.photosDLG = PhotoWindow(self.drawSelf) 122 | self.photosDLG.viewer.scene.clear() 123 | pixmap = QPixmap.fromImage(self.drawSelf.getImage) 124 | self.photosDLG.viewer.scene.addPixmap(pixmap) 125 | self.photosDLG.viewer.setSceneRect(QRectF(pixmap.rect())) 126 | self.photosDLG.viewer.resizeEvent([]) 127 | 128 | try: 129 | dateTrue = str(feature.attributes()[feature.fieldNameIndex('Date')].toString('yyyy-MM-dd')) 130 | except: 131 | dateTrue = str(feature.attributes()[feature.fieldNameIndex('Date')]) 132 | try: 133 | timeTrue = str(feature.attributes()[feature.fieldNameIndex('Time')].toString('hh:mm:ss')) 134 | except: 135 | timeTrue = str(feature.attributes()[feature.fieldNameIndex('Time')]) 136 | 137 | try: 138 | name_ = feature.attributes()[feature.fieldNameIndex('Name')] 139 | name_ = name_[:-4] 140 | except: 141 | try: 142 | name_ = feature.attributes()[feature.fieldNameIndex('filename')] 143 | except: 144 | name_ = '' 145 | 146 | try: 147 | self.photosDLG.infoPhoto1.setText(self.tr('Date: ') + dateTrue) 148 | self.photosDLG.infoPhoto2.setText(self.tr('Time: ') + timeTrue[0:8]) 149 | except: 150 | pass 151 | self.photosDLG.infoPhoto3.setText(self.tr('Layer: ') + self.drawSelf.layerActiveName) 152 | try: 153 | name_ = feature.attributes()[feature.fieldNameIndex('Description')] 154 | except: 155 | pass 156 | 157 | self.photosDLG.add_window_place.setText(name_) 158 | 159 | azimuth = feature.attributes()[feature.fieldNameIndex('Azimuth')] 160 | 161 | if type(azimuth) is str: 162 | try: 163 | azimuth = float(azimuth) 164 | except: 165 | pass 166 | if type(azimuth) is float: 167 | if azimuth > 0: 168 | self.photosDLG.rotate_azimuth.setEnabled(True) 169 | self.photosDLG.showNormal() 170 | return 171 | self.photosDLG.rotate_azimuth.setEnabled(False) 172 | self.photosDLG.showNormal() 173 | return 174 | 175 | def deactivate(self): 176 | self.drawSelf.clickPhotos.setChecked(False) 177 | 178 | def isZoomTool(self): 179 | return False 180 | 181 | def isTransient(self): 182 | return False 183 | 184 | def isEditTool(self): 185 | return True 186 | 187 | # noinspection PyMethodMayBeStatic 188 | def tr(self, message): 189 | """Get the translation for a string using Qt translation API. 190 | 191 | We implement this ourselves since we do not inherit QObject. 192 | 193 | :param message: String for translation. 194 | :type message: str, QString 195 | 196 | :returns: Translated version of message. 197 | :rtype: QString 198 | """ 199 | # noinspection PyTypeChecker,PyArgumentList,PyCallByClass 200 | return QCoreApplication.translate('PhotoWindow', message) 201 | -------------------------------------------------------------------------------- /code/PhotosViewer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | ImportPhotos 5 | A QGIS plugin 6 | Import photos 7 | last update : 04/01/2023 8 | begin : February 2018 9 | copyright : (C) 2019 by KIOS Research Center 10 | email : mariosmsk@gmail.com 11 | ***************************************************************************/ 12 | /*************************************************************************** 13 | * * 14 | * This program is free software; you can redistribute it and/or modify * 15 | * it under the terms of the GNU General Public License as published by * 16 | * the Free Software Foundation; either version 2 of the License, or * 17 | * (at your option) any later version. * 18 | * * 19 | ***************************************************************************/ 20 | """ 21 | 22 | from qgis.PyQt.QtWidgets import (QGraphicsView, QGraphicsScene, QVBoxLayout, QHBoxLayout, QWidget, 23 | QLineEdit, QLabel, QSizePolicy, QPushButton, QFrame, QMenuBar, QAction, qApp, 24 | QFileDialog, QMessageBox) 25 | from qgis.PyQt.QtCore import (QFileInfo, Qt, pyqtSignal, QRectF, QRect, QSize, QCoreApplication) 26 | from qgis.PyQt.QtGui import (QPainterPath, QIcon, QPixmap, QImage, QFont) 27 | import os.path 28 | 29 | # Filtering opencv 30 | opencv = False 31 | try: 32 | import cv2 33 | import numpy as np 34 | from matplotlib import pyplot as plt 35 | 36 | opencv = True 37 | except: 38 | opencv = False 39 | 40 | 41 | class PhotosViewer(QGraphicsView): 42 | afterLeftClick = pyqtSignal(float, float) 43 | afterLeftClickReleased = pyqtSignal(float, float) 44 | afterDoubleClick = pyqtSignal(float, float) 45 | keyPressed = pyqtSignal(int) 46 | 47 | def __init__(self, selfwindow): 48 | QGraphicsView.__init__(self) 49 | 50 | self.selfwindow = selfwindow 51 | self.panSelect = False 52 | self.zoomSelect = False 53 | self.rotate_value = 0 54 | self.rotate_azimuth_value = 0 55 | 56 | self.zoom_data = [] 57 | size = 36 58 | self.scene = QGraphicsScene() 59 | if len(self.selfwindow.allpictures) > 1: 60 | self.leftClick = QPushButton(self) 61 | self.leftClick.setIcon(QIcon(':/plugins/ImportPhotos/icons/arrowLeft.png')) 62 | self.leftClick.clicked.connect(self.selfwindow.leftClickButton) 63 | self.leftClick.setToolTip(self.tr('Show previous photo')) 64 | self.leftClick.setStyleSheet("QPushButton{border: 0px; background: transparent;}") 65 | self.leftClick.setIconSize(QSize(size, size)) 66 | self.leftClick.setFocusPolicy(Qt.NoFocus) 67 | 68 | self.rightClick = QPushButton(self) 69 | self.rightClick.setIcon(QIcon(':/plugins/ImportPhotos/icons/arrowRight.png')) 70 | self.rightClick.clicked.connect(self.selfwindow.rightClickButton) 71 | self.rightClick.setToolTip(self.tr('Show next photo')) 72 | self.rightClick.setStyleSheet("QPushButton{border: 0px; background: transparent;}") 73 | self.rightClick.setIconSize(QSize(size, size)) 74 | self.rightClick.setFocusPolicy(Qt.NoFocus) 75 | 76 | self.setScene(self.scene) 77 | self.setMouseTracking(False) 78 | self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) 79 | self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) 80 | self.setDragMode(QGraphicsView.NoDrag) 81 | 82 | def mousePressEvent(self, event): 83 | sc_pos = self.mapToScene(event.pos()) 84 | if self.panSelect: 85 | self.setDragMode(QGraphicsView.ScrollHandDrag) 86 | if self.zoomSelect: 87 | self.setDragMode(QGraphicsView.RubberBandDrag) 88 | self.afterLeftClick.emit(sc_pos.x(), sc_pos.y()) 89 | QGraphicsView.mousePressEvent(self, event) 90 | 91 | def mouseDoubleClickEvent(self, event): 92 | sc_pos = self.mapToScene(event.pos()) 93 | if self.zoomSelect or self.panSelect: 94 | self.zoom_data = [] 95 | self.fitInView(self.sceneRect(), Qt.KeepAspectRatio) 96 | self.afterDoubleClick.emit(sc_pos.x(), sc_pos.y()) 97 | QGraphicsView.mouseDoubleClickEvent(self, event) 98 | 99 | def mouseReleaseEvent(self, event): 100 | QGraphicsView.mouseReleaseEvent(self, event) 101 | sc_pos = self.mapToScene(event.pos()) 102 | if self.zoomSelect: 103 | view_bb = self.sceneRect() 104 | if self.zoom_data: 105 | view_bb = self.zoom_data 106 | selection_bb = self.scene.selectionArea().boundingRect().intersected(view_bb) 107 | self.scene.setSelectionArea(QPainterPath()) 108 | if selection_bb.isValid() and (selection_bb != view_bb): 109 | self.zoom_data = selection_bb 110 | self.fitInView(self.zoom_data, Qt.KeepAspectRatio) 111 | self.setDragMode(QGraphicsView.NoDrag) 112 | self.afterLeftClickReleased.emit(sc_pos.x(), sc_pos.y()) 113 | 114 | def resizeEvent(self, event): 115 | self.fitInView(self.scene.sceneRect(), Qt.KeepAspectRatio) 116 | 117 | if len(self.selfwindow.allpictures) > 1: 118 | loc = self.viewport().geometry() 119 | newloc = list(loc.getRect()) 120 | self.left_newloc = newloc[:] 121 | self.left_newloc[0] = self.left_newloc[0] # x 122 | self.left_newloc[1] = self.left_newloc[3] / 2.4 # y 123 | self.left_newloc[2] = self.left_newloc[2] / 5 # width 124 | self.left_newloc[3] = self.left_newloc[3] / 5 # height 125 | self.leftClick.setGeometry(QRect(*(map(round, self.left_newloc)))) 126 | newloc[0] = newloc[2] - newloc[2] / 5 # x 127 | newloc[1] = newloc[3] / 2.4 # y 128 | newloc[2] = newloc[2] / 5 # width 129 | newloc[3] = newloc[3] / 5 # height 130 | self.rightClick.setGeometry(QRect(*(map(round, newloc)))) 131 | 132 | # Fix rotate for the next photo 133 | self.rotate(-self.rotate_value) 134 | self.rotate_value = 0 135 | 136 | # Fix azimuth rotate for the next photo 137 | if self.rotate_azimuth_value > 0: 138 | self.rotate(-self.rotate_azimuth_value) 139 | self.rotate_azimuth_value = 0 140 | 141 | def keyPressEvent(self, e): 142 | if e.key() == Qt.Key_Right: 143 | self.selfwindow.rightClickButton() 144 | 145 | if e.key() == Qt.Key_Left: 146 | self.selfwindow.leftClickButton() 147 | 148 | if e.key() == Qt.Key_Escape: 149 | if self.selfwindow.isFullScreen(): 150 | self.selfwindow.showMaximized() 151 | return 152 | 153 | if e.key() == Qt.Key_F11: 154 | if self.selfwindow.isFullScreen(): 155 | self.selfwindow.showMaximized() 156 | else: 157 | self.selfwindow.showFullScreen() 158 | 159 | if e.key() == Qt.Key_Escape: 160 | self.selfwindow.close() 161 | 162 | # noinspection PyMethodMayBeStatic 163 | def tr(self, message): 164 | """Get the translation for a string using Qt translation API. 165 | 166 | We implement this ourselves since we do not inherit QObject. 167 | 168 | :param message: String for translation. 169 | :type message: str, QString 170 | 171 | :returns: Translated version of message. 172 | :rtype: QString 173 | """ 174 | # noinspection PyTypeChecker,PyArgumentList,PyCallByClass 175 | return QCoreApplication.translate('PhotosViewer', message) 176 | 177 | 178 | class PhotoWindow(QWidget): 179 | def __init__(self, drawSelf): 180 | super(PhotoWindow, self).__init__() 181 | self.drawSelf = drawSelf 182 | 183 | # Update for photo 184 | self.allpictures = {} 185 | self.allpicturesdates = {} 186 | self.allpicturestimes = {} 187 | self.allpicturesImpath = {} # feature id / picture path 188 | self.allpicturesAzimuth = {} 189 | self.allpicturesName = {} 190 | self.allpicturesLink = {} 191 | for i, f in enumerate(self.drawSelf.layerActive.getFeatures()): 192 | attributes = f.attributes() 193 | if 'PATH' in self.drawSelf.fields: 194 | imPath = attributes[f.fieldNameIndex('Path')] 195 | elif 'PHOTO' in self.drawSelf.fields: 196 | imPath = attributes[f.fieldNameIndex('photo')] 197 | else: 198 | imPath = '' 199 | try: 200 | dateTrue = str(attributes[f.fieldNameIndex('Date')].toString('yyyy-MM-dd')) 201 | except: 202 | dateTrue = str(attributes[f.fieldNameIndex('Date')]) 203 | try: 204 | timeTrue = str(attributes[f.fieldNameIndex('Time')].toString('hh:mm:ss')) 205 | except: 206 | timeTrue = str(attributes[f.fieldNameIndex('Time')]) 207 | try: 208 | name_ = attributes[f.fieldNameIndex('Name')] 209 | name_ = name_[:-4] 210 | except: 211 | try: 212 | name_ = attributes[f.fieldNameIndex('filename')] 213 | except: 214 | name_ = '' 215 | 216 | if not os.path.exists(imPath): 217 | try: 218 | if self.drawSelf.prj.fileName() and 'RELPATH' in self.drawSelf.fields: 219 | imPath = os.path.join( 220 | QFileInfo(self.drawSelf.prj.fileName()).absolutePath(), 221 | attributes[f.fieldNameIndex('RelPath')]) 222 | except: 223 | imPath = '' 224 | try: 225 | azimuth = attributes[f.fieldNameIndex('Azimuth')] 226 | except: 227 | azimuth = None 228 | 229 | try: 230 | link = attributes[f.fieldNameIndex('Link')] 231 | except: 232 | link = None 233 | 234 | self.allpictures[f.id()] = name_ 235 | self.allpicturesdates[f.id()] = dateTrue 236 | self.allpicturestimes[f.id()] = timeTrue 237 | self.allpicturesImpath[f.id()] = imPath 238 | self.allpicturesAzimuth[f.id()] = azimuth 239 | self.allpicturesName[f.id()] = name_ 240 | self.allpicturesLink[f.id()] = link 241 | 242 | self.viewer = PhotosViewer(self) 243 | 244 | ###################################################################################### 245 | 246 | self.setWindowTitle('Photo') 247 | self.setWindowIcon(QIcon(':/plugins/ImportPhotos/icons/icon.png')) 248 | 249 | menu_bar = QMenuBar(self) 250 | menu_bar.setGeometry(QRect(0, 0, 10000, 26)) 251 | 252 | file_menu = menu_bar.addMenu(self.tr('File')) 253 | self.saveas = file_menu.addAction(self.tr('Save As')) 254 | self.saveas.triggered.connect(self.saveas_call) 255 | 256 | filters_menu = menu_bar.addMenu(self.tr('Filters')) 257 | 258 | self.gray_filter_status = False 259 | self.gray_filter_btn = filters_menu.addAction(self.tr('Gray Filter')) 260 | self.gray_filter_btn.setCheckable(True) 261 | self.gray_filter_btn.triggered.connect(self.gray_filter_call) 262 | 263 | self.mirror_filter_status = False 264 | self.mirror_filter_btn = filters_menu.addAction(self.tr('Mirror Filter')) 265 | self.mirror_filter_btn.setCheckable(True) 266 | self.mirror_filter_btn.triggered.connect(self.mirror_filter_call) 267 | 268 | self.mono_filter_status = False 269 | self.mono_filter_btn = filters_menu.addAction(self.tr('Mono Filter')) 270 | self.mono_filter_btn.setCheckable(True) 271 | self.mono_filter_btn.triggered.connect(self.mono_filter_call) 272 | 273 | try: 274 | if opencv: 275 | opencv_menu = menu_bar.addMenu(self.tr('Opencv')) 276 | bands_menu = menu_bar.addMenu(self.tr('Bands')) 277 | 278 | self.opencv_filt_status = {'Edges': False, 'Red': False, 'Green': False, 'Blue': False, 279 | '2DConvolution': False, 'Median': False, 'Gaussian': False, 280 | 'Gaussian Highpass': False} 281 | self.edges_filter_btn = opencv_menu.addAction(self.tr('Edges Filter')) 282 | self.edges_filter_btn.setCheckable(True) 283 | self.edges_filter_btn.triggered.connect(self.edges_filter_call) 284 | 285 | self.red_filter_btn = bands_menu.addAction(self.tr('Red Band')) 286 | self.red_filter_btn.setCheckable(True) 287 | self.red_filter_btn.triggered.connect(self.red_filter_call) 288 | 289 | self.blue_filter_btn = bands_menu.addAction(self.tr('Blue Band')) 290 | self.blue_filter_btn.setCheckable(True) 291 | self.blue_filter_btn.triggered.connect(self.blue_filter_call) 292 | 293 | self.green_filter_btn = bands_menu.addAction(self.tr('Green Band')) 294 | self.green_filter_btn.setCheckable(True) 295 | self.green_filter_btn.triggered.connect(self.green_filter_call) 296 | 297 | self.averaging_filter_btn = opencv_menu.addAction(self.tr('2D Convolution Filter')) 298 | self.averaging_filter_btn.setCheckable(True) 299 | self.averaging_filter_btn.triggered.connect(self.averaging_filter_call) 300 | 301 | self.median_filter_btn = opencv_menu.addAction(self.tr('Median Filter')) 302 | self.median_filter_btn.setCheckable(True) 303 | self.median_filter_btn.triggered.connect(self.median_filter_call) 304 | 305 | self.gaussian_filter_btn = opencv_menu.addAction(self.tr('Gaussian Filter')) 306 | self.gaussian_filter_btn.setCheckable(True) 307 | self.gaussian_filter_btn.triggered.connect(self.gaussian_filter_call) 308 | 309 | self.gaussian_high_filter_btn = opencv_menu.addAction(self.tr('Gaussian Highpass')) 310 | self.gaussian_high_filter_btn.setCheckable(True) 311 | self.gaussian_high_filter_btn.triggered.connect(self.gaussian_high_filter_call) 312 | except: 313 | pass 314 | # # Add Filter buttons 315 | sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) 316 | 317 | self.add_window_place = QLabel(self) # temporary 318 | self.add_window_place.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) 319 | self.add_window_place.setFrameShape(QFrame.NoFrame) 320 | self.add_window_place.setOpenExternalLinks(True) # To make link clickable 321 | 322 | self.infoPhoto1 = QLabel(self) 323 | self.infoPhoto1.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum)) 324 | self.infoPhoto1.setStyleSheet("background-color: lightgray;") # Light gray close to white 325 | self.infoPhoto1.setFrameShape(QFrame.Box) 326 | 327 | self.infoPhoto2 = QLabel(self) 328 | self.infoPhoto2.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum)) 329 | self.infoPhoto2.setStyleSheet("background-color: lightgray;") # Light gray close to white 330 | self.infoPhoto2.setFrameShape(QFrame.Box) 331 | 332 | self.infoPhoto3 = QLabel(self) 333 | self.infoPhoto3.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum)) 334 | self.infoPhoto3.setStyleSheet("background-color: lightgray;") # Light gray close to white 335 | self.infoPhoto3.setFrameShape(QFrame.Box) 336 | 337 | self.extent = QPushButton(self) 338 | self.extent.setSizePolicy(sizePolicy) 339 | self.extent.setIcon(QIcon(':/plugins/ImportPhotos/icons/mActionZoomFullExtent.svg')) 340 | self.extent.clicked.connect(self.extentbutton) 341 | 342 | self.zoom = QPushButton(self) 343 | self.zoom.setSizePolicy(sizePolicy) 344 | self.zoom.setIcon(QIcon(':/plugins/ImportPhotos/icons/method-draw-image.svg')) 345 | self.zoom.clicked.connect(self.zoombutton) 346 | 347 | self.pan = QPushButton(self) 348 | self.pan.setSizePolicy(sizePolicy) 349 | self.pan.setIcon(QIcon(':/plugins/ImportPhotos/icons/mActionPan.svg')) 350 | self.pan.clicked.connect(self.panbutton) 351 | 352 | self.zoom_to_select = QPushButton(self) 353 | self.zoom_to_select.setSizePolicy(sizePolicy) 354 | self.zoom_to_select.setIcon(QIcon(':/plugins/ImportPhotos/icons/mActionZoomToSelected.svg')) 355 | self.zoom_to_select.clicked.connect(self.zoom_to_selectbutton) 356 | 357 | self.rotate_option = QPushButton(self) 358 | self.rotate_option.setSizePolicy(sizePolicy) 359 | self.rotate_option.setIcon(QIcon(':/plugins/ImportPhotos/icons/rotate.png')) 360 | self.rotate_option.clicked.connect(self.rotatebutton) 361 | 362 | self.rotate_azimuth = QPushButton(self) 363 | self.rotate_azimuth.setSizePolicy(sizePolicy) 364 | self.rotate_azimuth.setIcon(QIcon(':/plugins/ImportPhotos/icons/tonorth.png')) 365 | self.rotate_azimuth.clicked.connect(self.rotate_azimuthbutton) 366 | 367 | self.hide_arrow = QPushButton(self) 368 | self.hide_arrow.setSizePolicy(sizePolicy) 369 | self.hide_arrow.setIcon(QIcon(':/plugins/ImportPhotos/icons/arrowRight.png')) 370 | self.hide_arrow.clicked.connect(self.hide_arrow_button) 371 | if len(self.allpictures) > 1: 372 | self.hide_arrow.setEnabled(True) 373 | else: 374 | self.hide_arrow.setEnabled(False) 375 | 376 | # Add tips on buttons 377 | self.extent.setToolTip(self.tr('Extent photo')) 378 | self.zoom.setToolTip(self.tr('Select area to zoom')) 379 | self.pan.setToolTip(self.tr('Pan')) 380 | self.zoom_to_select.setToolTip(self.tr('Zoom to selected photo')) 381 | self.rotate_option.setToolTip(self.tr('Rotate 45°')) 382 | self.rotate_azimuth.setToolTip(self.tr('Rotate to azimuth')) 383 | self.hide_arrow.setToolTip(self.tr('Hide arrows')) 384 | 385 | # Arrange layout 386 | VBlayout = QVBoxLayout(self) 387 | HBlayout = QHBoxLayout() 388 | HBlayout2 = QHBoxLayout() 389 | HBlayoutTop = QHBoxLayout() 390 | HBlayoutTop.setAlignment(Qt.AlignCenter) 391 | HBlayoutTop.addWidget(self.add_window_place) 392 | HBlayout2.addWidget(self.viewer) 393 | HBlayout.setAlignment(Qt.AlignCenter) 394 | HBlayout.addWidget(self.infoPhoto1) 395 | HBlayout.addWidget(self.infoPhoto2) 396 | HBlayout.addWidget(self.infoPhoto3) 397 | HBlayout.addWidget(self.extent) 398 | HBlayout.addWidget(self.zoom) 399 | HBlayout.addWidget(self.pan) 400 | HBlayout.addWidget(self.rotate_option) 401 | HBlayout.addWidget(self.rotate_azimuth) 402 | HBlayout.addWidget(self.zoom_to_select) 403 | HBlayout.addWidget(self.hide_arrow) 404 | 405 | spacelabel = QHBoxLayout() 406 | spacelabel.addWidget(QLabel(self)) 407 | VBlayout.addLayout(spacelabel) 408 | 409 | VBlayout.addLayout(HBlayoutTop) 410 | VBlayout.addLayout(HBlayout2) 411 | VBlayout.addLayout(HBlayout) 412 | 413 | def gray_filter_call(self): 414 | if self.gray_filter_btn.isChecked(): 415 | self.gray_filter_status = True 416 | self.update_filters('filters_tab') 417 | else: 418 | self.gray_filter_status = False 419 | self.gray_filter_btn.setChecked(False) 420 | self.updateWindow() 421 | 422 | def mirror_filter_call(self): 423 | if self.mirror_filter_btn.isChecked(): 424 | self.mirror_filter_status = True 425 | self.update_filters('filters_tab') 426 | else: 427 | self.mirror_filter_status = False 428 | self.mirror_filter_btn.setChecked(False) 429 | self.updateWindow() 430 | 431 | def mono_filter_call(self): 432 | if self.mono_filter_btn.isChecked(): 433 | self.mono_filter_status = True 434 | self.update_filters('filters_tab') 435 | else: 436 | self.mono_filter_status = False 437 | self.mono_filter_btn.setChecked(False) 438 | self.updateWindow() 439 | 440 | def averaging_filter_call(self): 441 | if self.averaging_filter_btn.isChecked(): 442 | self.opencv_filt_status['2DConvolution'] = True 443 | self.update_filters('averaging') 444 | else: 445 | self.opencv_filt_status['2DConvolution'] = False 446 | self.averaging_filter_btn.setChecked(False) 447 | self.updateWindow() 448 | 449 | def median_filter_call(self): 450 | if self.median_filter_btn.isChecked(): 451 | self.opencv_filt_status['Median'] = True 452 | self.update_filters('median') 453 | else: 454 | self.opencv_filt_status['Median'] = False 455 | self.median_filter_btn.setChecked(False) 456 | self.updateWindow() 457 | 458 | def gaussian_filter_call(self): 459 | if self.gaussian_filter_btn.isChecked(): 460 | self.opencv_filt_status['Gaussian'] = True 461 | self.update_filters('gaussian') 462 | else: 463 | self.opencv_filt_status['Gaussian'] = False 464 | self.gaussian_filter_btn.setChecked(False) 465 | self.updateWindow() 466 | 467 | def gaussian_high_filter_call(self): 468 | if self.gaussian_high_filter_btn.isChecked(): 469 | self.opencv_filt_status['Gaussian Highpass'] = True 470 | self.update_filters('fourrier') 471 | else: 472 | self.opencv_filt_status['Gaussian Highpass'] = False 473 | self.gaussian_high_filter_btn.setChecked(False) 474 | self.updateWindow() 475 | 476 | def red_filter_call(self): 477 | if self.red_filter_btn.isChecked(): 478 | self.opencv_filt_status['Red'] = True 479 | self.update_filters('red') 480 | else: 481 | self.opencv_filt_status['Red'] = False 482 | self.red_filter_btn.setChecked(False) 483 | self.updateWindow() 484 | 485 | def blue_filter_call(self): 486 | if self.blue_filter_btn.isChecked(): 487 | self.opencv_filt_status['Blue'] = True 488 | self.update_filters('blue') 489 | else: 490 | self.opencv_filt_status['Blue'] = False 491 | self.blue_filter_btn.setChecked(False) 492 | self.updateWindow() 493 | 494 | def green_filter_call(self): 495 | if self.green_filter_btn.isChecked(): 496 | self.opencv_filt_status['Green'] = True 497 | self.update_filters('green') 498 | else: 499 | self.opencv_filt_status['Green'] = False 500 | self.green_filter_btn.setChecked(False) 501 | self.updateWindow() 502 | 503 | def edges_filter_call(self): 504 | if self.edges_filter_btn.isChecked(): 505 | self.opencv_filt_status['Edges'] = True 506 | self.update_filters('edges') 507 | else: 508 | self.opencv_filt_status['Edges'] = False 509 | self.edges_filter_btn.setChecked(False) 510 | self.updateWindow() 511 | 512 | def update_filters(self, filter): 513 | if opencv: 514 | if filter != 'fourrier': 515 | self.opencv_filt_status['Gaussian Highpass'] = False 516 | self.gaussian_high_filter_btn.setChecked(False) 517 | if filter != 'median': 518 | self.opencv_filt_status['Median'] = False 519 | self.median_filter_btn.setChecked(False) 520 | if filter != 'gaussian': 521 | self.opencv_filt_status['Gaussian'] = False 522 | self.gaussian_filter_btn.setChecked(False) 523 | if filter != 'averaging': 524 | self.opencv_filt_status['2DConvolution'] = False 525 | self.averaging_filter_btn.setChecked(False) 526 | if filter != 'blue': 527 | self.opencv_filt_status['Blue'] = False 528 | self.blue_filter_btn.setChecked(False) 529 | if filter != 'red': 530 | self.opencv_filt_status['Red'] = False 531 | self.red_filter_btn.setChecked(False) 532 | if filter != 'green': 533 | self.opencv_filt_status['Green'] = False 534 | self.green_filter_btn.setChecked(False) 535 | if filter != 'edges': 536 | self.opencv_filt_status['Edges'] = False 537 | self.edges_filter_btn.setChecked(False) 538 | 539 | if filter != 'filters_tab': 540 | self.gray_filter_status = False 541 | self.gray_filter_btn.setChecked(False) 542 | if filter != 'filters_tab': 543 | self.mirror_filter_status = False 544 | self.mirror_filter_btn.setChecked(False) 545 | if filter != 'filters_tab': 546 | self.mono_filter_status = False 547 | self.mono_filter_btn.setChecked(False) 548 | 549 | def saveas_call(self): 550 | self.outputPath = QFileDialog.getSaveFileName(None, self.tr('Save Image'), os.path.join( 551 | os.path.join(os.path.expanduser('~')), 'Desktop'), '.png') 552 | self.outputPath = self.outputPath[0] 553 | if self.outputPath == '': 554 | return 555 | self.drawSelf.getImage.save(self.outputPath + '.png') 556 | self.showMessage(title='ImportPhotos', 557 | msg=self.tr('Save image at "') + self.outputPath + '.png' + self.tr('" succesfull.'), 558 | button='OK', icon='Info') 559 | 560 | def showMessage(self, title, msg, button, icon): 561 | msgBox = QMessageBox() 562 | if icon == 'Warning': 563 | msgBox.setIcon(QMessageBox.Warning) 564 | if icon == 'Info': 565 | msgBox.setIcon(QMessageBox.Information) 566 | msgBox.setWindowTitle(title) 567 | msgBox.setText(msg) 568 | msgBox.setStandardButtons(QMessageBox.Ok) 569 | font = QFont() 570 | font.setPointSize(9) 571 | msgBox.setFont(font) 572 | msgBox.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint) 573 | buttonY = msgBox.button(QMessageBox.Ok) 574 | buttonY.setText(button) 575 | buttonY.setFont(font) 576 | msgBox.exec_() 577 | 578 | def hide_arrow_button(self): 579 | icon_right = QIcon(':/plugins/ImportPhotos/icons/arrowRight.png') 580 | if self.viewer.leftClick.icon().isNull(): 581 | self.viewer.leftClick.setIcon(QIcon(':/plugins/ImportPhotos/icons/arrowLeft.png')) 582 | self.viewer.rightClick.setIcon(icon_right) 583 | self.hide_arrow.setIcon(icon_right) 584 | self.hide_arrow.setToolTip(self.tr('Hide arrows')) 585 | else: 586 | self.viewer.leftClick.setIcon(QIcon('')) 587 | self.viewer.rightClick.setIcon(QIcon('')) 588 | self.hide_arrow.setToolTip(self.tr('Show arrows')) 589 | self.hide_arrow.setIcon(icon_right) 590 | 591 | def leftClickButton(self): 592 | lastId = list(self.allpicturesImpath.keys())[-1] 593 | it = iter(self.allpicturesImpath) 594 | 595 | prevKey = lastId 596 | for key in it: 597 | if key == self.drawSelf.featureIndex: 598 | self.drawSelf.featureIndex = prevKey 599 | break 600 | prevKey = key 601 | self.updateWindow() 602 | 603 | def rightClickButton(self): 604 | firstId = list(self.allpicturesImpath.keys())[0] 605 | it = iter(self.allpicturesImpath) 606 | for key in it: 607 | if key == self.drawSelf.featureIndex: 608 | self.drawSelf.featureIndex = next(it, firstId) 609 | break 610 | self.updateWindow() 611 | 612 | def updateWindow(self): 613 | imPath = self.allpicturesImpath[self.drawSelf.featureIndex] 614 | try: 615 | if not os.path.exists(imPath): 616 | c = self.drawSelf.noImageFound() 617 | imPath = '' 618 | except: 619 | c = self.drawSelf.noImageFound() 620 | imPath = '' 621 | 622 | self.viewer.scene.clear() 623 | self.drawSelf.getImage = QImage(imPath) 624 | 625 | if self.gray_filter_status: 626 | self.drawSelf.getImage = self.drawSelf.getImage.convertToFormat(QImage.Format_Grayscale8) 627 | if self.mirror_filter_status: 628 | self.drawSelf.getImage = self.drawSelf.getImage.mirrored(True, False) 629 | if self.mono_filter_status: 630 | self.drawSelf.getImage = self.drawSelf.getImage.convertToFormat(QImage.Format_Mono) 631 | 632 | if opencv: 633 | if self.opencv_filt_status['2DConvolution']: 634 | ## Average filter 635 | img = cv2.imread(imPath) 636 | kernel = np.ones((5, 5), np.float32) / 25 637 | filt = cv2.filter2D(img, -1, kernel) 638 | 639 | if self.opencv_filt_status['Red']: 640 | ## RED 641 | img = np.array(cv2.imread(imPath)) 642 | filt = np.zeros(img.shape, dtype='uint8') 643 | filt[:, :, 2] = img[:, :, 2] 644 | if self.opencv_filt_status['Blue']: 645 | ## BLUE 646 | img = np.array(cv2.imread(imPath)) 647 | filt = np.zeros(img.shape, dtype='uint8') 648 | filt[:, :, 0] = img[:, :, 0] 649 | if self.opencv_filt_status['Green']: 650 | ## GREEN 651 | img = np.array(cv2.imread(imPath)) 652 | filt = np.zeros(img.shape, dtype='uint8') 653 | filt[:, :, 1] = img[:, :, 1] 654 | 655 | if self.opencv_filt_status['Edges']: 656 | ## Edges filter 657 | img = cv2.imread(imPath, 0) 658 | filt = cv2.Canny(img, 100, 200) 659 | 660 | if self.opencv_filt_status['Median']: 661 | img = cv2.imread(imPath) 662 | filt = cv2.medianBlur(img, 5) 663 | 664 | if self.opencv_filt_status['Gaussian']: 665 | img = cv2.imread(imPath) 666 | filt = cv2.GaussianBlur(img, (5, 5), 0) 667 | 668 | if self.opencv_filt_status['Gaussian Highpass']: 669 | from scipy import ndimage 670 | data = np.array(cv2.imread(imPath)) 671 | lowpass = ndimage.gaussian_filter(data, 3) 672 | filt = data - lowpass 673 | 674 | for value in self.opencv_filt_status: 675 | if self.opencv_filt_status[value] == True: 676 | # Fix for all opencv filters 677 | height, width = filt.shape[:2] 678 | try: 679 | rgb = cv2.cvtColor(filt, cv2.COLOR_GRAY2RGB) 680 | except: 681 | rgb = cv2.cvtColor(filt, cv2.COLOR_BGR2RGB) 682 | 683 | self.drawSelf.getImage = QImage(rgb, width, height, QImage.Format_RGB888) 684 | break 685 | 686 | pixmap = QPixmap.fromImage(self.drawSelf.getImage) 687 | self.viewer.scene.addPixmap(pixmap) 688 | self.viewer.setSceneRect(QRectF(pixmap.rect())) 689 | self.drawSelf.layerActive.selectByIds([self.drawSelf.featureIndex]) 690 | 691 | self.viewer.resizeEvent([]) 692 | self.extentbutton() 693 | self.infoPhoto1.setText( 694 | self.tr('Date: ') + self.allpicturesdates[self.drawSelf.featureIndex]) 695 | self.infoPhoto2.setText( 696 | self.tr('Time: ') + self.allpicturestimes[self.drawSelf.featureIndex][0:8]) 697 | self.infoPhoto3.setText(self.tr('Layer: ') + self.drawSelf.layerActiveName) 698 | link = self.allpicturesLink[self.drawSelf.featureIndex] 699 | header = self.allpicturesName[self.drawSelf.featureIndex] 700 | if link is not None: 701 | header = f'{header}' 702 | self.add_window_place.setText(header) 703 | azimuth = self.allpicturesAzimuth[self.drawSelf.featureIndex] 704 | if type(azimuth) is str: 705 | try: 706 | azimuth = float(azimuth) 707 | except: 708 | pass 709 | if type(azimuth) is float: 710 | if azimuth > 0: 711 | self.rotate_azimuth.setEnabled(True) 712 | return 713 | self.rotate_azimuth.setEnabled(False) 714 | 715 | def rotatebutton(self): 716 | self.viewer.rotate(90) 717 | self.viewer.rotate_value = self.viewer.rotate_value + 90 718 | if self.viewer.rotate_value == 360: 719 | self.viewer.rotate_value = 0 720 | 721 | def rotate_azimuthbutton(self): 722 | if self.viewer.rotate_azimuth_value == 0: 723 | azimuth = self.allpicturesAzimuth[self.drawSelf.featureIndex] 724 | if type(azimuth) is str: 725 | azimuth = float(azimuth) 726 | self.viewer.rotate(azimuth) 727 | self.viewer.rotate_azimuth_value = azimuth 728 | return 729 | if self.viewer.rotate_azimuth_value > 0: 730 | self.viewer.rotate(-self.viewer.rotate_azimuth_value) 731 | self.viewer.rotate_azimuth_value = 0 732 | 733 | def zoom_to_selectbutton(self): 734 | self.drawSelf.iface.actionZoomToSelected().trigger() 735 | 736 | def panbutton(self): 737 | self.viewer.panSelect = True 738 | self.viewer.zoomSelect = False 739 | self.viewer.setCursor(Qt.OpenHandCursor) 740 | self.viewer.setDragMode(QGraphicsView.ScrollHandDrag) 741 | 742 | def zoombutton(self): 743 | self.viewer.panSelect = False 744 | self.viewer.zoomSelect = True 745 | self.viewer.setCursor(Qt.CrossCursor) 746 | self.viewer.setDragMode(QGraphicsView.RubberBandDrag) 747 | 748 | def extentbutton(self): 749 | self.viewer.zoom_data = [] 750 | self.viewer.fitInView(self.viewer.sceneRect(), Qt.KeepAspectRatio) 751 | self.viewer.panSelect = False 752 | self.viewer.zoomSelect = False 753 | self.viewer.setCursor(Qt.ArrowCursor) 754 | self.viewer.setDragMode(QGraphicsView.NoDrag) 755 | 756 | # noinspection PyMethodMayBeStatic 757 | def tr(self, message): 758 | """Get the translation for a string using Qt translation API. 759 | 760 | We implement this ourselves since we do not inherit QObject. 761 | 762 | :param message: String for translation. 763 | :type message: str, QString 764 | 765 | :returns: Translated version of message. 766 | :rtype: QString 767 | """ 768 | # noinspection PyTypeChecker,PyArgumentList,PyCallByClass 769 | return QCoreApplication.translate('PhotoWindow', message) 770 | -------------------------------------------------------------------------------- /i18n/ImportPhotos_fr.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/ImportPhotos/3196e97fe15f5f740a6f037fd507aca185fc50e9/i18n/ImportPhotos_fr.qm -------------------------------------------------------------------------------- /i18n/ImportPhotos_fr.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | photosImp 6 | 7 | 8 | ImportPhotos 9 | Added 10 | ImportPhotos 11 | 12 | 13 | 14 | OK 15 | Added 16 | OK 17 | 18 | 19 | 20 | Load style (optional) 21 | Added 22 | Charger le style (optionnel) 23 | 24 | 25 | 26 | Output file location 27 | Added 28 | Fichier en sortie 29 | 30 | 31 | 32 | Input folder location 33 | Added 34 | Dossier en entrée 35 | 36 | 37 | 38 | e.g. 39 | Added 40 | ex. 41 | 42 | 43 | 44 | Browse... 45 | Added 46 | Parcourir... 47 | 48 | 49 | 50 | Only import photos in canvas extent 51 | Added 52 | Importer seulement photos de l'emprise 53 | 54 | 55 | 56 | Close 57 | Added 58 | Fermer 59 | 60 | 61 | 62 | ImportPhotos 63 | 64 | 65 | Import Photos 66 | Added 67 | Importer des photos 68 | 69 | 70 | 71 | Click Photos 72 | Added 73 | Afficher une photo 74 | 75 | 76 | 77 | Save File 78 | Added 79 | Enregistrer le fichier 80 | 81 | 82 | 83 | Select a folder: 84 | Added 85 | Sélectionner un dossier : 86 | 87 | 88 | 89 | Load style 90 | Added 91 | Charger le style 92 | 93 | 94 | 95 | Please select a directory photos. 96 | Added 97 | Sélectionner un dossier pour les photos. 98 | 99 | 100 | 101 | Warning 102 | Added 103 | Avertissement 104 | 105 | 106 | 107 | Please define output file location. 108 | Added 109 | Définir l'emplacement du fichier de sortie. 110 | 111 | 112 | 113 | No image path found. 114 | Added 115 | Pas d'emplacement d'images. 116 | 117 | 118 | 119 | No style path found. 120 | Added 121 | Pas d'emplacement de style. 122 | 123 | 124 | 125 | No photos 126 | Added 127 | Aucune photo 128 | 129 | 130 | 131 | No geo-tagged images were detected. 132 | Added 133 | Aucune image géoréférencée détectée. 134 | 135 | 136 | 137 | Import Completed. 138 | Added 139 | Importation terminée. 140 | 141 | 142 | 143 | Details: 144 | Added 145 | Détails : 146 | 147 | 148 | 149 | No new photos were added. 150 | Added 151 | Aucune nouvelle photo ajoutée. 152 | 153 | 154 | 155 | Information 156 | Added 157 | Information 158 | 159 | 160 | 161 | photo(s) added without error. 162 | Added 163 | photo(s) ajoutées sans erreur. 164 | 165 | 166 | 167 | photo(s) skipped (because of missing location). 168 | Added 169 | photo(s) non traitées (emplacement absent). 170 | 171 | 172 | 173 | photo(s) skipped (because not in canvas extent). 174 | Added 175 | photo(s) non traitées (hors emprise). 176 | 177 | 178 | 179 | PhotosViewer 180 | 181 | 182 | Show previous photo 183 | Added 184 | Afficher photo précédente 185 | 186 | 187 | 188 | Show next photo 189 | Added 190 | Afficher photo suivante 191 | 192 | 193 | 194 | PhotoWindow 195 | 196 | 197 | File 198 | Added 199 | Fichier 200 | 201 | 202 | 203 | Save As 204 | Added 205 | Enregistrer sous 206 | 207 | 208 | 209 | Filters 210 | Added 211 | Filtres 212 | 213 | 214 | 215 | Gray Filter 216 | Added 217 | Filtre Gris 218 | 219 | 220 | 221 | Mirror Filter 222 | Added 223 | Filtre Mirroir 224 | 225 | 226 | 227 | Mono Filter 228 | Added 229 | Filtre Mono 230 | 231 | 232 | 233 | Opencv 234 | Added 235 | Opencv 236 | 237 | 238 | 239 | Bands 240 | Added 241 | Bandes 242 | 243 | 244 | 245 | Edges Filter 246 | Added 247 | Filtre arrêtes 248 | 249 | 250 | 251 | Red Band 252 | Added 253 | Bande rouge 254 | 255 | 256 | 257 | Blue Band 258 | Added 259 | Bande bleue 260 | 261 | 262 | 263 | Green Band 264 | Added 265 | Bande verte 266 | 267 | 268 | 269 | 2D Convolution Filter 270 | Added 271 | Filtre convolution 2D 272 | 273 | 274 | 275 | Median Filter 276 | Added 277 | Filtre médian 278 | 279 | 280 | 281 | Gaussian Filter 282 | Added 283 | Filtre Gaussien 284 | 285 | 286 | 287 | Gaussian Highpass 288 | Added 289 | Passe-haut Gaussien 290 | 291 | 292 | 293 | Extent photo 294 | Added 295 | Étendue photo 296 | 297 | 298 | 299 | Select area to zoom 300 | Added 301 | Zoom sur l'emprise 302 | 303 | 304 | 305 | Pan 306 | Added 307 | Déplacer 308 | 309 | 310 | 311 | Zoom to selected photo 312 | Added 313 | Zoom sur la photo courante 314 | 315 | 316 | 317 | Rotate 45° 318 | Added 319 | Rotation 45° 320 | 321 | 322 | 323 | Rotate to azimuth 324 | Added 325 | Rotation azimuth 326 | 327 | 328 | 329 | Hide arrows 330 | Added 331 | Cacher les flèches 332 | 333 | 334 | 335 | Save Image 336 | Added 337 | Enregistrer l'image 338 | 339 | 340 | 341 | Save image at " 342 | Added 343 | Image " 344 | 345 | 346 | 347 | " succesfull. 348 | Added 349 | " enregistrée avec succès. 350 | 351 | 352 | 353 | Show arrows 354 | Added 355 | Montrer les flèches 356 | 357 | 358 | 359 | Date: 360 | Added 361 | Date : 362 | 363 | 364 | 365 | Time: 366 | Added 367 | Heure : 368 | 369 | 370 | 371 | Layer: 372 | Added 373 | Couche : 374 | 375 | 376 | 377 | -------------------------------------------------------------------------------- /icons/ImportImage.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 23 | 25 | image/svg+xml 26 | 28 | 29 | 30 | 31 | 32 | 34 | 54 | 358 | 359 | -------------------------------------------------------------------------------- /icons/arrowLeft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/ImportPhotos/3196e97fe15f5f740a6f037fd507aca185fc50e9/icons/arrowLeft.png -------------------------------------------------------------------------------- /icons/arrowRight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/ImportPhotos/3196e97fe15f5f740a6f037fd507aca185fc50e9/icons/arrowRight.png -------------------------------------------------------------------------------- /icons/edges.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/ImportPhotos/3196e97fe15f5f740a6f037fd507aca185fc50e9/icons/edges.PNG -------------------------------------------------------------------------------- /icons/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/ImportPhotos/3196e97fe15f5f740a6f037fd507aca185fc50e9/icons/example.png -------------------------------------------------------------------------------- /icons/export.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/ImportPhotos/3196e97fe15f5f740a6f037fd507aca185fc50e9/icons/icon.png -------------------------------------------------------------------------------- /icons/mActionPan.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /icons/mActionZoomFullExtent.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /icons/mActionZoomToSelected.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /icons/method-draw-image.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | background 5 | 6 | 7 | 8 | Layer 1 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /icons/redband.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/ImportPhotos/3196e97fe15f5f740a6f037fd507aca185fc50e9/icons/redband.PNG -------------------------------------------------------------------------------- /icons/rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/ImportPhotos/3196e97fe15f5f740a6f037fd507aca185fc50e9/icons/rotate.png -------------------------------------------------------------------------------- /icons/sync_views.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/tonorth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/ImportPhotos/3196e97fe15f5f740a6f037fd507aca185fc50e9/icons/tonorth.png -------------------------------------------------------------------------------- /install_packages/install_pip_packages.bat: -------------------------------------------------------------------------------- 1 | @echo ON 2 | 3 | cd /d %~dp0 4 | 5 | call "py3-env.bat" 6 | 7 | python3 -m pip install -r requirements.txt 8 | 9 | pause -------------------------------------------------------------------------------- /install_packages/py3-env.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | set OSGEO4W_ROOT=C:\Program Files\QGIS 3.20 4 | 5 | set PATH=%OSGEO4W_ROOT%\bin;%PATH% 6 | set PATH=%PATH%;%OSGEO4W_ROOT%\apps\qgis\bin 7 | 8 | @echo off 9 | call "%OSGEO4W_ROOT%\bin\o4w_env.bat" 10 | call "%OSGEO4W_ROOT%\bin\qt5_env.bat" 11 | call "%OSGEO4W_ROOT%\bin\py3_env.bat" 12 | @echo off 13 | path %OSGEO4W_ROOT%\apps\qgis\bin;%PATH% 14 | 15 | cd /d %~dp0 -------------------------------------------------------------------------------- /install_packages/requirements.txt: -------------------------------------------------------------------------------- 1 | exifread 2 | pillow 3 | opencv-python -------------------------------------------------------------------------------- /metadata.txt: -------------------------------------------------------------------------------- 1 | # This file contains metadata for your plugin. Since 2 | # version 2.0 of QGIS this is the proper way to supply 3 | # information about a plugin. The old method of 4 | # embedding metadata in __init__.py will 5 | # is no longer supported since version 2.0. 6 | 7 | # This file should be included when you package your plugin.# Mandatory items: 8 | 9 | [general] 10 | name=ImportPhotos 11 | qgisMinimumVersion=2.99 12 | qgisMaximumVersion=3.99 13 | description=Import Photos 14 | version=3.0.7 15 | author=Marios S. Kyriakou, George A. Christou, Panayiotis S. Kolios, Demetris G. Eliades, KIOS Research and Innovation Center of Excellence (KIOS CoE) 16 | email=mariosmsk@gmail.com 17 | 18 | about= This tool can be used to import Geo-Tagged photos (jpg or jpeg) as points to QGIS. The user is able to select a folder with photos and only the geo-tagged photos will be taken. Then a layer will be created which it will contain the name of the picture, its directory, the date and time taken, altitude, longitude, latitude, azimuth, north, camera maker and model, title, user comment and relative path. The plug-in doesn’t need any third party applications to work. It has two buttons; the one is to import geotagged photos, and the other one is to be able to click on a point and display the photo along with information regarding the date time and altitude. The user can create one of the following file types: GeoJSON, SHP, GPKG, CSV, KML, TAB. When the user saves a project and wants to reopen it, the folder with the pictures should stay at the original file location or moved at the same location of the project (e.g. *.qgz) in order to be able to view the pictures. Mac users please refer to the Read Me file for further guidance. The new version of Import photos gives the ability to the user to use several basic filters on the image and save the picture. To use additional filters, the user needs to use the python package opencv-python. 19 | 20 | tracker=https://github.com/KIOS-Research/ImportPhotos/issues/ 21 | repository=https://github.com/KIOS-Research/ImportPhotos/ 22 | # End of mandatory metadata 23 | 24 | # Recommended items: 25 | # Uncomment the following line and add your changelog: 26 | changelog=2025-01-10 ImportPhotos 3.0.7: 27 | Add bulk image export button (Thanks @spwoodcock, @hotosm) 28 | Add relative and web root paths/URLs to hyperlink the image names, enabling them to open external links. (Thanks @sickel) 29 | 2024-04-19 ImportPhotos 3.0.6: 30 | Fixed relative path handling(Thanks @holesond) 31 | 2023-01-04 ImportPhotos 3.0.5: 32 | Show the photo in the tooltip window 33 | Add label space in the window of the photo (show the title/name of the file more clearly) 34 | Fix some issues with empty fields (Thanks @gaspermeister) 35 | Fix python type error on photos viewer setGeometry (Thanks @faebebin) 36 | Fix the error if the file in the Path field doesn't exist (Thanks @KrisRadowski, @turzik-x) 37 | 2022-07-29 ImportPhotos 3.0.4: 38 | Fix some issues (Thanks @jfbourdon) 39 | 2021-11-05 ImportPhotos 3.0.3: 40 | Fix bug when import photos with dots in the filename 41 | Thank you @mhugent and sourcepole for the following changes 42 | -Better handling of feature ids 43 | -Re-create the photo dialog if the active layer has been changed (bug) 44 | 2021-09-29 ImportPhotos 3.0.2: 45 | Fix bug 46 | 2021-09-19 ImportPhotos 3.0.1: 47 | Fix rel path / show photo with map tip and attribute table 48 | 2021-09-19 ImportPhotos 3.0.0: 49 | Adds a new button to synchronize changes in the photo directory with an already existing layer 50 | User can set the layer symbology (rules, symbols) before import (Thank you very much @mhugent and @HusseinKabbout - http://sourcepole.ch) 51 | Fix filename and extension handling and some other improvements (Thank you @jekhor) 52 | 2021-09-06 ImportPhotos 2.3.0: 53 | Display photo dialog only once - Click instead of double-click by 54 | French translation (Thank you very much @sigeal) 55 | Remove group when added layer 56 | Update photos qml file 57 | Default save as geopackage 58 | 2019-08-07 ImportPhotos 2.2.3: 59 | Add field column Images. 60 | 2019-07-18 ImportPhotos 2.2.2: 61 | Fix transparent left,right buttons for all themes 62 | Fix bug with null parameters 63 | Add option to import photos in canvas extent 64 | 2019-07-16 ImportPhotos 2.2.1: 65 | Fix tab Filters works without Opencv 66 | 2019-07-15 ImportPhotos 2.2: 67 | Add tabs options File, Filters, Opencv, Bands 68 | Add filters gray and mirror, mono, edges, averaging, gaussian, gaussian highpass (req. opencv-python) 69 | Add bands red, blue, green 70 | Add name title and save as option 71 | Clean code 72 | 2019-03-07 ImportPhotos 2.1: 73 | Fix tabs & update buttons 74 | Fix zoom to selected photo 75 | 2019-02-25 ImportPhotos 2.0: 76 | Call from python 77 | Add fields title, user comment, relative path 78 | Add option to load specific qml style 79 | Change main ui window 80 | 2019-01-25 ImportPhotos 1.9: 81 | Add group with layer 82 | Fix issue in right/left transparent 83 | 2018-11-28 ImportPhotos 1.8: 84 | Drop update for qgis 2 85 | Add QgsTask for the ImportPhotos 86 | Change main ui file 87 | Set default save file, shapefile 88 | Add buttons zoom to selected, rotation, rotation azimuth 89 | Update right, left buttons 90 | Add warning when not imported the PIL or the exifread python module 91 | Sort attribute table 92 | Add button for show/hide arrows 93 | 2018-11-15 ImportPhotos 1.7: 94 | Update view window, add next/previous-buttons and key shortcut 95 | Press F11 to enter fullscreen, Escape to exit 96 | Remove the modal window 97 | 2018-11-05 ImportPhotos 1.6: 98 | Fix issue with empty attribute for qgis 3.4 99 | 2018-10-22 ImportPhotos 1.5: 100 | Fix issue with exifread 101 | 2018-09-25 ImportPhotos 1.4: 102 | Another fix of the issue with images without gps info 103 | 2018-09-23 ImportPhotos 1.3: 104 | Fix an issue with images without gps info 105 | Fix issue for linux platform 106 | 2018-05-22 ImportPhotos 1.2: 107 | Remove Altitude from photo window 108 | Replace Zoom In icon with Zoom To Selected 109 | Fix azimuth ratio in field 110 | Add save as GeoJSON, SHP, GPKG, CSV, GML, KML, TAB, ODS type of files 111 | Merge QGIS 2 with QGIS 3 ImportPhotos plugin 112 | 2018-05-08 ImportPhotos 1.1: 113 | Update window file of photo, fix reopen project, add zoom, pan and extend buttons 114 | 2018-03-21 ImportPhotos 1.0: 115 | Issue fixes and migration code to QGIS3 116 | Fix error with replace file and clear code 117 | Add attributes field Camera Maker and Model 118 | 2018-03-09 ImportPhotos 0.4: 119 | Fix error for mac pc, and add some warning messages 120 | 2018-02-20 ImportPhotos 0.3: 121 | Update version 122 | 2018-02-20 ImportPhotos 0.2: 123 | Fixed error with activation 124 | 125 | # Tags are comma separated with spaces allowed 126 | tags=photos, jpeg, jpg, geotag 127 | 128 | homepage=https://mariosmsk.com/2019/02/02/qgis-plugin-importphotos/ 129 | category=Plugins 130 | icon=icon.png 131 | # experimental flag 132 | experimental=False 133 | 134 | # deprecated flag (applies to the whole plugin, not just a single version) 135 | deprecated=False 136 | -------------------------------------------------------------------------------- /resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/ImportImage.svg 4 | icons/SelectImage.svg 5 | icons/arrowLeft.png 6 | icons/arrowRight.png 7 | icons/icon.png 8 | icons/mActionPan.svg 9 | icons/mActionZoomFullExtent.svg 10 | icons/mActionZoomToSelected.svg 11 | icons/method-draw-image.svg 12 | icons/rotate.png 13 | icons/tonorth.png 14 | icons/sync_views.svg 15 | icons/export.svg 16 | 17 | 18 | -------------------------------------------------------------------------------- /runuifiles.bat: -------------------------------------------------------------------------------- 1 | C:\Users\mkiria01\AppData\Local\Programs\Python\Python37\Scripts\pyrcc5 resources.qrc -o resources.py -------------------------------------------------------------------------------- /ui/impphotos.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'impphotos.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.15.10 6 | # 7 | # WARNING: Any manual changes made to this file will be lost when pyuic5 is 8 | # run again. Do not edit this file unless you know what you are doing. 9 | 10 | 11 | from PyQt5 import QtCore, QtGui, QtWidgets 12 | 13 | 14 | class Ui_photosImp(object): 15 | def setupUi(self, photosImp): 16 | photosImp.setObjectName("photosImp") 17 | photosImp.setWindowModality(QtCore.Qt.NonModal) 18 | photosImp.resize(815, 470) 19 | photosImp.setMinimumSize(QtCore.QSize(382, 223)) 20 | photosImp.setWhatsThis("") 21 | photosImp.setSizeGripEnabled(False) 22 | self.gridLayout_2 = QtWidgets.QGridLayout(photosImp) 23 | self.gridLayout_2.setObjectName("gridLayout_2") 24 | self.gridLayout = QtWidgets.QGridLayout() 25 | self.gridLayout.setObjectName("gridLayout") 26 | self.imp = QtWidgets.QLineEdit(photosImp) 27 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) 28 | sizePolicy.setHorizontalStretch(0) 29 | sizePolicy.setVerticalStretch(0) 30 | sizePolicy.setHeightForWidth(self.imp.sizePolicy().hasHeightForWidth()) 31 | self.imp.setSizePolicy(sizePolicy) 32 | self.imp.setObjectName("imp") 33 | self.gridLayout.addWidget(self.imp, 0, 2, 1, 1) 34 | spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) 35 | self.gridLayout.addItem(spacerItem, 12, 2, 1, 1) 36 | spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) 37 | self.gridLayout.addItem(spacerItem1, 1, 0, 1, 1) 38 | self.label_3 = QtWidgets.QLabel(photosImp) 39 | self.label_3.setObjectName("label_3") 40 | self.gridLayout.addWidget(self.label_3, 8, 0, 1, 1) 41 | self.relativeroot = QtWidgets.QLineEdit(photosImp) 42 | self.relativeroot.setObjectName("relativeroot") 43 | self.gridLayout.addWidget(self.relativeroot, 8, 2, 1, 1) 44 | spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) 45 | self.gridLayout.addItem(spacerItem2, 1, 2, 1, 1) 46 | self.closebutton = QtWidgets.QPushButton(photosImp) 47 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding) 48 | sizePolicy.setHorizontalStretch(0) 49 | sizePolicy.setVerticalStretch(0) 50 | sizePolicy.setHeightForWidth(self.closebutton.sizePolicy().hasHeightForWidth()) 51 | self.closebutton.setSizePolicy(sizePolicy) 52 | self.closebutton.setObjectName("closebutton") 53 | self.gridLayout.addWidget(self.closebutton, 13, 4, 1, 1) 54 | self.out = QtWidgets.QLineEdit(photosImp) 55 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) 56 | sizePolicy.setHorizontalStretch(0) 57 | sizePolicy.setVerticalStretch(0) 58 | sizePolicy.setHeightForWidth(self.out.sizePolicy().hasHeightForWidth()) 59 | self.out.setSizePolicy(sizePolicy) 60 | self.out.setObjectName("out") 61 | self.gridLayout.addWidget(self.out, 2, 2, 1, 1) 62 | spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) 63 | self.gridLayout.addItem(spacerItem3, 5, 0, 1, 1) 64 | self.label_2 = QtWidgets.QLabel(photosImp) 65 | self.label_2.setObjectName("label_2") 66 | self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1) 67 | self.toolButtonImport = QtWidgets.QPushButton(photosImp) 68 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding) 69 | sizePolicy.setHorizontalStretch(0) 70 | sizePolicy.setVerticalStretch(0) 71 | sizePolicy.setHeightForWidth(self.toolButtonImport.sizePolicy().hasHeightForWidth()) 72 | self.toolButtonImport.setSizePolicy(sizePolicy) 73 | self.toolButtonImport.setObjectName("toolButtonImport") 74 | self.gridLayout.addWidget(self.toolButtonImport, 0, 4, 1, 1) 75 | spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) 76 | self.gridLayout.addItem(spacerItem4, 1, 4, 1, 1) 77 | self.horizontalLayout_2 = QtWidgets.QHBoxLayout() 78 | self.horizontalLayout_2.setObjectName("horizontalLayout_2") 79 | spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) 80 | self.horizontalLayout_2.addItem(spacerItem5) 81 | self.ok = QtWidgets.QPushButton(photosImp) 82 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding) 83 | sizePolicy.setHorizontalStretch(0) 84 | sizePolicy.setVerticalStretch(0) 85 | sizePolicy.setHeightForWidth(self.ok.sizePolicy().hasHeightForWidth()) 86 | self.ok.setSizePolicy(sizePolicy) 87 | self.ok.setObjectName("ok") 88 | self.horizontalLayout_2.addWidget(self.ok) 89 | self.gridLayout.addLayout(self.horizontalLayout_2, 13, 2, 1, 1) 90 | spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) 91 | self.gridLayout.addItem(spacerItem6, 5, 4, 1, 1) 92 | spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) 93 | self.gridLayout.addItem(spacerItem7, 5, 2, 1, 1) 94 | self.label = QtWidgets.QLabel(photosImp) 95 | self.label.setObjectName("label") 96 | self.gridLayout.addWidget(self.label, 0, 0, 1, 1) 97 | self.canvas_extent = QtWidgets.QCheckBox(photosImp) 98 | self.canvas_extent.setLayoutDirection(QtCore.Qt.LeftToRight) 99 | self.canvas_extent.setObjectName("canvas_extent") 100 | self.gridLayout.addWidget(self.canvas_extent, 11, 2, 1, 1) 101 | self.toolButtonOut = QtWidgets.QPushButton(photosImp) 102 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding) 103 | sizePolicy.setHorizontalStretch(0) 104 | sizePolicy.setVerticalStretch(0) 105 | sizePolicy.setHeightForWidth(self.toolButtonOut.sizePolicy().hasHeightForWidth()) 106 | self.toolButtonOut.setSizePolicy(sizePolicy) 107 | self.toolButtonOut.setObjectName("toolButtonOut") 108 | self.gridLayout.addWidget(self.toolButtonOut, 2, 4, 1, 1) 109 | self.label_4 = QtWidgets.QLabel(photosImp) 110 | self.label_4.setObjectName("label_4") 111 | self.gridLayout.addWidget(self.label_4, 9, 0, 1, 1) 112 | self.webroot = QtWidgets.QLineEdit(photosImp) 113 | self.webroot.setObjectName("webroot") 114 | self.gridLayout.addWidget(self.webroot, 9, 2, 1, 1) 115 | self.toolButtonRelative = QtWidgets.QPushButton(photosImp) 116 | self.toolButtonRelative.setObjectName("toolButtonRelative") 117 | self.gridLayout.addWidget(self.toolButtonRelative, 8, 4, 1, 1) 118 | spacerItem8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) 119 | self.gridLayout.addItem(spacerItem8, 6, 0, 1, 1) 120 | spacerItem9 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) 121 | self.gridLayout.addItem(spacerItem9, 6, 2, 1, 1) 122 | spacerItem10 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) 123 | self.gridLayout.addItem(spacerItem10, 6, 4, 1, 1) 124 | self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1) 125 | 126 | self.retranslateUi(photosImp) 127 | QtCore.QMetaObject.connectSlotsByName(photosImp) 128 | 129 | def retranslateUi(self, photosImp): 130 | _translate = QtCore.QCoreApplication.translate 131 | photosImp.setWindowTitle(_translate("photosImp", "ImportPhotos")) 132 | self.label_3.setText(_translate("photosImp", "Relative root")) 133 | self.closebutton.setText(_translate("photosImp", "Close")) 134 | self.label_2.setText(_translate("photosImp", "Output file location")) 135 | self.toolButtonImport.setText(_translate("photosImp", "Browse...")) 136 | self.ok.setText(_translate("photosImp", "OK")) 137 | self.label.setText(_translate("photosImp", "Input folder location")) 138 | self.canvas_extent.setText(_translate("photosImp", "Only import photos in canvas extent")) 139 | self.toolButtonOut.setText(_translate("photosImp", "Browse...")) 140 | self.label_4.setText(_translate("photosImp", "Web root")) 141 | self.toolButtonRelative.setText(_translate("photosImp", "Browse...")) 142 | -------------------------------------------------------------------------------- /ui/impphotos.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | photosImp 4 | 5 | 6 | Qt::NonModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 815 13 | 470 14 | 15 | 16 | 17 | 18 | 382 19 | 223 20 | 21 | 22 | 23 | ImportPhotos 24 | 25 | 26 | 27 | 28 | 29 | false 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 0 39 | 0 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Qt::Horizontal 48 | 49 | 50 | 51 | 40 52 | 20 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Qt::Horizontal 61 | 62 | 63 | QSizePolicy::Preferred 64 | 65 | 66 | 67 | 40 68 | 20 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Relative root 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | Qt::Horizontal 87 | 88 | 89 | QSizePolicy::Preferred 90 | 91 | 92 | 93 | 40 94 | 20 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 0 104 | 0 105 | 106 | 107 | 108 | Close 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 0 117 | 0 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | Qt::Horizontal 126 | 127 | 128 | QSizePolicy::Preferred 129 | 130 | 131 | 132 | 40 133 | 20 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | Output file location 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 0 150 | 0 151 | 152 | 153 | 154 | Browse... 155 | 156 | 157 | 158 | 159 | 160 | 161 | Qt::Horizontal 162 | 163 | 164 | QSizePolicy::Preferred 165 | 166 | 167 | 168 | 40 169 | 20 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | Qt::Horizontal 180 | 181 | 182 | 183 | 40 184 | 20 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 0 194 | 0 195 | 196 | 197 | 198 | OK 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | Qt::Horizontal 208 | 209 | 210 | QSizePolicy::Preferred 211 | 212 | 213 | 214 | 40 215 | 20 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | Qt::Horizontal 224 | 225 | 226 | QSizePolicy::Preferred 227 | 228 | 229 | 230 | 40 231 | 20 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | Input folder location 240 | 241 | 242 | 243 | 244 | 245 | 246 | Qt::LeftToRight 247 | 248 | 249 | Only import photos in canvas extent 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 0 258 | 0 259 | 260 | 261 | 262 | Browse... 263 | 264 | 265 | 266 | 267 | 268 | 269 | Web root 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | Browse... 280 | 281 | 282 | 283 | 284 | 285 | 286 | Qt::Horizontal 287 | 288 | 289 | QSizePolicy::Preferred 290 | 291 | 292 | 293 | 40 294 | 20 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | Qt::Horizontal 303 | 304 | 305 | QSizePolicy::Preferred 306 | 307 | 308 | 309 | 40 310 | 20 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | Qt::Horizontal 319 | 320 | 321 | QSizePolicy::Preferred 322 | 323 | 324 | 325 | 40 326 | 20 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | --------------------------------------------------------------------------------