Changeset 3458438
- Timestamp:
- 02/10/2026 09:55:59 PM (7 weeks ago)
- Location:
- nextgen-gallery-geo/trunk
- Files:
-
- 4 edited
-
azure-map.php (modified) (1 diff)
-
functions.php (modified) (8 diffs)
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nextgen-gallery-geo/trunk/azure-map.php
r3445193 r3458438 16 16 * @since 2.1.2 Function geo2_maps() amended. 17 17 * @since 2.1.4 Function geo2_maps() amended to add support for WebP files. 18 18 * 19 19 * @author Pawel Block <pb@pasart.net> 20 20 * @copyright Copyright (c) 2023, Pawel Block -
nextgen-gallery-geo/trunk/functions.php
r3446683 r3458438 17 17 * @since 2.1.4 Amended functions: geo2_maps_coordinates(), geo2_maps_exif(), geo2_maps_exif_camera(), geo2_maps_check_content(), geo2_maps_data(), geo2_maps_data_single(), geo2_maps_data_worldmap(), geo2_maps_enqueue_scripts(). New function: geo2_maps_is_webp(), geo2_maps_get_webp_metadata(), geo2_maps_webp_search_xmp(), geo2_maps_webp_search_xmp_gps(), geo2_maps_webp_search_xmp_exif_info(), geo2_maps_eval_fraction(), geo2_maps_is_valid_tiff_blob(), geo2_maps_parse_exif_blob(). 18 18 * @since 2.1.5 Amended functions: geo2_maps_get_webp_metadata(), geo2_maps_webp_search_xmp(), geo2_maps_webp_search_xmp_gps(), geo2_maps_webp_search_xmp_exif_info(), geo2_maps_parse_exif_blob(). 19 * @since 2.1.6 Amended functions: geo2_maps_coordinates(), geo2_maps_webp_search_xmp_gps(). New function: geo2_maps_coordinates(), geo2_maps_decimal_to_dms(). 19 20 * @copyright Copyright (c) 2023, Pawel Block 20 21 * @link http://www.geo2maps.plus … … 960 961 } elseif ( $xmp_streamed !== false && $sections === 'IFD0&EXIF' ) { 961 962 $xmp_search_data = geo2_maps_webp_search_xmp_exif_info( $xmp_streamed ); 962 $xmp_data = array_replace( $xmp_data, $xmp_search_data );963 $xmp_data = array_replace( $xmp_data, $xmp_search_data ); 963 964 } 964 965 // Reset for the main scan loop. … … 1107 1108 * 1108 1109 * @since 2.1.4 1109 * @since 2.1.5 Added support for WebD files create with older Adobe XMP Core 7.0 ( metadata saved in "" not in <> tags). 1110 * @since 2.1.5 Added support for WebP files create with older Adobe XMP Core 7.0 ( metadata saved in "" not in <> tags). 1111 * @since 2.1.6 Improved parsing of various coordinate formats and hemisphere indicators in XMP GPS data. 1110 1112 * 1111 1113 * @see geo2_maps_get_webp_metadata() … … 1131 1133 } 1132 1134 1133 if ( $lat && $lon ) { 1134 $lat_clean = str_replace( array( 'N', 'S' ), '', $lat ); 1135 $lon_clean = str_replace( array( 'E', 'W' ), '', $lon ); 1136 1137 $lat_parts = explode( ',', $lat_clean, 2 ); 1138 $lon_parts = explode( ',', $lon_clean, 2 ); 1139 1140 $lat_deg = isset( $lat_parts[0] ) ? (float) $lat_parts[0] : 0.0; 1141 $lat_min = isset( $lat_parts[1] ) ? (float) $lat_parts[1] : 0.0; 1142 1143 $lon_deg = isset( $lon_parts[0] ) ? (float) $lon_parts[0] : 0.0; 1144 $lon_min = isset( $lon_parts[1] ) ? (float) $lon_parts[1] : 0.0; 1145 1146 $result = array( 1147 'GPSLatitude' => array( $lat_deg, $lat_min, 0 ), 1148 'GPSLongitude' => array( $lon_deg, $lon_min, 0 ), 1149 'GPSLatitudeRef' => $lat_ref, 1150 'GPSLongitudeRef' => $lon_ref, 1151 ); 1152 } 1135 if ( ! $lat || ! $lon ) { 1136 return false; 1137 } 1138 1139 list($lat_decimal, $lat_dms, $lat_ref) = geo2_maps_parse_xmp_coord( $lat, 'lat' ); 1140 list($lon_decimal, $lon_dms, $lon_ref) = geo2_maps_parse_xmp_coord( $lon, 'lon' ); 1141 1142 $result = array( 1143 'GPSLatitudeDecimal' => $lat_decimal, 1144 'GPSLongitudeDecimal' => $lon_decimal, 1145 'GPSLatitude' => $lat_dms, 1146 'GPSLongitude' => $lon_dms, 1147 'GPSLatitudeRef' => $lat_ref, 1148 'GPSLongitudeRef' => $lon_ref, 1149 ); 1153 1150 1154 1151 return ! empty( $result ) ? $result : false; 1152 } 1153 1154 1155 /** 1156 * Convert a decimal degree into degrees, minutes, and seconds for webP files. 1157 * 1158 * @since 2.1.6 1159 * 1160 * @see geo2_maps_webp_search_xmp_gps() 1161 * @param int $val the degree in the form 123.456. Must be in the interval [-180, 180]. 1162 * @param string $type 'lat' for latitude or 'lon' for longitude, used to determine hemisphere reference. 1163 * @return array a triple with the degrees, minutes, and seconds. Each value is an array itself, suitable for passing to a PelEntryRational. If the degree is outside the allowed interval, null is returned instead. 1164 */ 1165 function geo2_maps_parse_xmp_coord( $val, $type ) { 1166 1167 // Detect hemisphere letter. 1168 $has_s = stripos( $val, 'S' ) !== false; 1169 $has_w = stripos( $val, 'W' ) !== false; 1170 1171 if ( $type === 'lat' ) { 1172 $ref = $has_s ? 'S' : 'N'; 1173 } else { 1174 $ref = $has_w ? 'W' : 'E'; 1175 } 1176 1177 // Remove hemisphere letters. 1178 $clean = str_replace( array( 'N', 'S', 'E', 'W' ), '', strtoupper( $val ) ); 1179 $clean = trim( $clean ); 1180 1181 // Detect negative sign. 1182 $negative = false; 1183 if ( strpos( $clean, '-' ) === 0 ) { 1184 $negative = true; 1185 $clean = ltrim( $clean, '-' ); 1186 } 1187 1188 // Locale decimal comma (only if single comma and no dot). 1189 if ( substr_count( $clean, ',' ) === 1 && preg_match( '/^\d+,\d+$/', $clean ) ) { 1190 $clean = str_replace( ',', '.', $clean ); 1191 } 1192 1193 // Split by comma to detect DMM or DMS. 1194 $parts = explode( ',', $clean ); 1195 1196 if ( count( $parts ) === 1 ) { 1197 // Decimal degrees. 1198 $decimal = floatval( $parts[0] ); 1199 1200 } elseif ( count( $parts ) === 2 ) { 1201 // DMM: deg, minutes.decimal. 1202 $deg = floatval( $parts[0] ); 1203 $min = floatval( $parts[1] ); 1204 $decimal = $deg + ( $min / 60 ); 1205 1206 } elseif ( count( $parts ) === 3 ) { 1207 // DMS: deg, min, sec. 1208 $deg = floatval( $parts[0] ); 1209 $min = floatval( $parts[1] ); 1210 $sec = floatval( $parts[2] ); 1211 $decimal = $deg + ( $min / 60 ) + ( $sec / 3600 ); 1212 1213 } else { 1214 // Garbage input. 1215 return array( 0, array( 0, 0, 0 ), $ref ); 1216 } 1217 1218 // Apply hemisphere rules. 1219 if ( $ref === 'S' || $ref === 'W' ) { 1220 $decimal = -abs( $decimal ); 1221 } elseif ( $negative ) { 1222 // Negative sign but no hemisphere letter. 1223 $decimal = -abs( $decimal ); 1224 $ref = ( $type === 'lat' ) ? 'S' : 'W'; 1225 } 1226 1227 // Convert to DMS for EXIF. 1228 $dms = geo2_maps_decimal_to_dms( abs( $decimal ) ); 1229 1230 return array( $decimal, $dms, $ref ); 1231 } 1232 1233 /** 1234 * Convert a decimal degree into degrees, minutes, and seconds for webP files. 1235 * 1236 * @since 2.1.6 1237 * 1238 * @see geo2_maps_webp_search_xmp_gps() 1239 * @param int $decimal the degree in the form 123.456. Must be in the interval [-180, 180]. 1240 * @return array a triple with the degrees, minutes, and seconds. Each value is an array itself, suitable for passing to a PelEntryRational. If the degree is outside the allowed interval, null is returned instead. 1241 */ 1242 function geo2_maps_decimal_to_dms( $decimal ) { 1243 $deg = floor( $decimal ); 1244 $min_float = ( $decimal - $deg ) * 60; 1245 $min = floor( $min_float ); 1246 $sec = ( $min_float - $min ) * 60; 1247 1248 return array( 1249 $deg, 1250 $min, 1251 $sec, 1252 ); 1155 1253 } 1156 1254 … … 1162 1260 * 1163 1261 * @since 2.1.4 1164 * @since 2.1.5 Added support for Web Dfiles create with older Adobe XMP Core 7.0 ( metadata saved in "" not in <> tags).1262 * @since 2.1.5 Added support for WebP files create with older Adobe XMP Core 7.0 ( metadata saved in "" not in <> tags). 1165 1263 * 1166 1264 * @see geo2_maps_get_webp_metadata() … … 1625 1723 * @since 2.1.3 Error handler amended to log errors instead of echoing in ajax requests. 1626 1724 * @since 2.1.4 Modified to use geo2_maps_get_jpg_metadata() and geo2_maps_get_webp_metadata() for EXIF extraction. 1725 * @since 2.1.6 Modified to use decimals acquired from XMP directly without conversion. 1627 1726 * 1628 1727 * @see function geo2_maps_pin_desc() in azure-map-functions.php … … 1685 1784 $geo['longitude_format'] = $gps['longitude_direction'] . ' ' . $gps['longitude_hour'] . '°' . $gps['longitude_minute'] . ''' . round( $gps['longitude_second'], 4 ) . '"'; 1686 1785 1687 $geo['latitude'] = $gps['latitude_string'] * ( $gps['latitude_hour'] + ( $gps['latitude_minute'] / 60 ) + ( $gps['latitude_second'] / 3600 ) ); 1688 $geo['longitude'] = $gps['longitude_string'] * ( $gps['longitude_hour'] + ( $gps['longitude_minute'] / 60 ) + ( $gps['longitude_second'] / 3600 ) ); 1786 1787 if ( isset( $exif['GPSLatitudeDecimal'] ) && ! empty( $exif['GPSLatitudeDecimal'] ) ) { 1788 $geo['latitude'] = $exif['GPSLatitudeDecimal']; 1789 } else { 1790 $geo['latitude'] = $gps['latitude_string'] * ( $gps['latitude_hour'] + ( $gps['latitude_minute'] / 60 ) + ( $gps['latitude_second'] / 3600 ) ); 1791 } 1792 if ( isset( $exif['GPSLongitudeDecimal'] ) && ! empty( $exif['GPSLongitudeDecimal'] ) ) { 1793 $geo['longitude'] = $exif['GPSLongitudeDecimal']; 1794 } else { 1795 $geo['longitude'] = $gps['longitude_string'] * ( $gps['longitude_hour'] + ( $gps['longitude_minute'] / 60 ) + ( $gps['longitude_second'] / 3600 ) ); 1796 } 1689 1797 } 1690 1798 } else { … … 2279 2387 // If not Worldmap. 2280 2388 if ( $options['worldmap'] !== 1 ) { 2281 // Get exif information ( needed for old galleries, created before NGG stored meta_data or Web Dimages for which NextGEN does not extract Metadata).2389 // Get exif information ( needed for old galleries, created before NGG stored meta_data or WebP images for which NextGEN does not extract Metadata). 2282 2390 if ( $options['exif'] === 1 && ( ( $options['lightbox'] === 'fancybox3' && $options['fancybox3_caption'] !== 'no' ) || $options['lightbox'] === 'infobox' ) ) { 2283 2391 // Detect WebP. -
nextgen-gallery-geo/trunk/plugin.php
r3446683 r3458438 25 25 * Plugin URI: https://wordpress.org/plugins/nextgen-gallery-geo/ 26 26 * Description: Geo2 Maps Add-on for NextGEN Gallery is a flexible plugin, displaying beautiful maps with your photos by using EXIF data or geocoding. 27 * Version: 2.1. 527 * Version: 2.1.6 28 28 29 29 * Author URI: http://www.geo2maps.plus -
nextgen-gallery-geo/trunk/readme.txt
r3446683 r3458438 4 4 Donate link: https://www.paypal.com/donate/?hosted_button_id=7JWUJ2J9RXWYU 5 5 Requires at least: 3.0.1 6 Tested up to: 6.9 6 Tested up to: 6.9.1 7 7 Requires PHP: 7.2.0 8 Stable tag: 2.1. 58 Stable tag: 2.1.6 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 181 181 == Changelog == 182 182 183 = V2.1.6 - 10.02.2026 = 184 185 * Update: Corrected conversion of GPS coordinates read from XMP. Added support for less likely occurring coordinate formats. 186 183 187 = V2.1.5 - 25.01.2026 = 184 188 185 * Update: Support added for Web Dfiles created with an older library Adobe XMP Core 7.0189 * Update: Support added for WebP files created with an older library Adobe XMP Core 7.0 186 190 187 191 * Bugfix: Mistake corrected which prevented extracting WebD metadata from EXIP chunk.
Note: See TracChangeset
for help on using the changeset viewer.