-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77eddbe
commit a50e085
Showing
187 changed files
with
38,500 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "openlab-at-city-tech/openlab-exif-tools", | ||
"type": "project", | ||
"autoload": { | ||
"psr-4": { | ||
"OpenLab\\EXIF\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Boone B Gorges", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"fileeye/pel": "^0.10.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
wp-content/plugins/openlab-exif-tools/openlab-exif-tools.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Plugin Name: OpenLab EXIF tools | ||
* Plugin URI: https://openlab.citytech.cuny.edu/ | ||
* Description: | ||
* Version: 1.0.0-alpha | ||
* Requires at least: 6.0 | ||
* Requires PHP: 7.3 | ||
* Author: OpenLab at City Tech | ||
* Author URI: https://openlab.citytech.cuny.edu/ | ||
* License: GPL-3.0-or-later | ||
* License URI: https://www.gnu.org/licenses/gpl-3.0.html | ||
* Text Domain: openlab-modules | ||
* Domain Path: /languages | ||
* | ||
* @package openlab-modules | ||
*/ | ||
|
||
namespace OpenLab\EXIF; | ||
|
||
const ROOT_DIR = __DIR__; | ||
const ROOT_FILE = __FILE__; | ||
|
||
require ROOT_DIR . '/vendor/autoload.php'; | ||
|
||
add_action( | ||
'plugins_loaded', | ||
function () { | ||
App::init(); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace OpenLab\EXIF; | ||
|
||
class App { | ||
private $cli; | ||
|
||
private function __construct() { | ||
add_action( 'bp_core_pre_avatar_handle_crop', [ $this, 'delete_gps_data_prior_to_avatar_crop' ], 10, 2 ); | ||
} | ||
|
||
public static function get_instance() { | ||
static $instance = null; | ||
|
||
if ( null === $instance ) { | ||
$instance = new self(); | ||
} | ||
|
||
return $instance; | ||
} | ||
|
||
public static function init() { | ||
$instance = self::get_instance(); | ||
|
||
if ( defined( 'WP_CLI' ) && WP_CLI ) { | ||
$instance->cli = CLI::get_instance(); | ||
$instance->cli::init(); | ||
} | ||
} | ||
|
||
public function delete_gps_data_prior_to_avatar_crop( $retval, $r ) { | ||
$image_path = bp_core_avatar_upload_path() . $r['original_file']; | ||
|
||
if ( ! file_exists( $image_path ) ) { | ||
return $retval; | ||
} | ||
|
||
$image = new Image( $image_path ); | ||
$image->delete_gps_data(); | ||
|
||
return $retval; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace OpenLab\EXIF; | ||
|
||
use WP_CLI; | ||
|
||
class CLI { | ||
protected $commands = [ | ||
'exif' => 'Exif', | ||
]; | ||
|
||
private function __construct() {} | ||
|
||
public static function get_instance() { | ||
static $instance = null; | ||
|
||
if ( null === $instance ) { | ||
$instance = new self(); | ||
} | ||
|
||
return $instance; | ||
} | ||
|
||
public static function init() { | ||
$instance = self::get_instance(); | ||
|
||
$instance->add_commands(); | ||
} | ||
|
||
private function add_commands() { | ||
foreach ( $this->commands as $cli_command => $class ) { | ||
$command = __NAMESPACE__ . '\\Command\\' . $class; | ||
|
||
WP_CLI::add_command( $cli_command, $command ); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
wp-content/plugins/openlab-exif-tools/src/Command/Exif.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace OpenLab\EXIF\Command; | ||
|
||
use OpenLab\EXIF\Image; | ||
|
||
use WP_CLI; | ||
|
||
class Exif { | ||
/** | ||
* Delete GPS-related EXIF data from one or more images. | ||
* | ||
* ## options | ||
* | ||
* [<path>] | ||
* : Path to the image file. | ||
* | ||
* @subcommand delete-gps-data | ||
*/ | ||
public function delete_gps_data( $args, $assoc_args ) { | ||
$path = isset( $args[0] ) ? $args[0] : null; | ||
|
||
if ( null !== $path ) { | ||
|
||
// If this is a directory, recurse. | ||
if ( is_dir( $path ) ) { | ||
$files = new \RecursiveIteratorIterator( | ||
new \RecursiveDirectoryIterator( $path ) | ||
); | ||
|
||
foreach ( $files as $file ) { | ||
if ( $file->isFile() ) { | ||
$this->delete_gps_data( [ $file->getPathname() ], $assoc_args ); | ||
} | ||
} | ||
} else { | ||
|
||
if ( false === strpos( $path, '/103/' ) ) { | ||
return; | ||
} | ||
|
||
$image = new Image( $path ); | ||
|
||
if ( $image->has_gps_data() ) { | ||
$deleted = $image->delete_gps_data(); | ||
if ( $deleted ) { | ||
WP_CLI::log( "Deleted GPS data from {$path}" ); | ||
} else { | ||
WP_CLI::log( "Failed to delete GPS data from {$path}" ); | ||
} | ||
} else { | ||
WP_CLI::log( "No GPS data found in {$path}" ); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.