mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-25 00:44:03 -04:00
Fix technical issues from PR review
Image_lib.php fixes: - Remove incorrect 'GPS' => PelTag::GPS_OFFSET mapping (GPS handled separately) - Fix PNG transparency: change imagealphablending to false - Add animated GIF detection: skip processing for animations - Add logging in stripExifFallback to show which APP markers are removed Migration optimization: - Use get()->getRow() instead of countAllResults() for lighter query - More efficient existence check before insert All changes address CodeRabbit technical review comments while maintaining the simplified multiselect-only UI (no toggle needed).
This commit is contained in:
@@ -24,11 +24,12 @@ class MigrationEXIFStrippingOptions extends Migration
|
||||
];
|
||||
|
||||
foreach ($configs as $config) {
|
||||
$exists = $db->table('app_config')
|
||||
$existing = $db->table('app_config')
|
||||
->where('key', $config['key'])
|
||||
->countAllResults();
|
||||
->get()
|
||||
->getRow();
|
||||
|
||||
if ($exists == 0) {
|
||||
if ($existing === null) {
|
||||
$db->table('app_config')->insert($config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ class Image_lib
|
||||
'Copyright' => PelTag::COPYRIGHT,
|
||||
'Software' => PelTag::SOFTWARE,
|
||||
'DateTime' => PelTag::DATE_TIME,
|
||||
'GPS' => PelTag::GPS_OFFSET,
|
||||
];
|
||||
|
||||
public function stripEXIF(string $filepath, array $fields_to_keep = []): bool
|
||||
@@ -112,7 +111,7 @@ class Image_lib
|
||||
return false;
|
||||
}
|
||||
|
||||
imagealphablending($image, true);
|
||||
imagealphablending($image, false);
|
||||
imagesavealpha($image, true);
|
||||
|
||||
$result = imagepng($image, $filepath, 9);
|
||||
@@ -123,6 +122,15 @@ class Image_lib
|
||||
|
||||
private function stripExifGif(string $filepath): bool
|
||||
{
|
||||
$content = file_get_contents($filepath);
|
||||
if ($content === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strpos($content, "\x21\xF9\x04") !== false || strpos($content, 'NETSCAPE2.0') !== false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$image = @imagecreatefromgif($filepath);
|
||||
if ($image === false) {
|
||||
return false;
|
||||
@@ -195,6 +203,13 @@ class Image_lib
|
||||
return true;
|
||||
}
|
||||
|
||||
$marker_names = [];
|
||||
foreach ($markers as $marker_info) {
|
||||
$marker_byte = ord($content[$marker_info[0] + 1]);
|
||||
$marker_names[] = 'APP' . ($marker_byte - 0xE0);
|
||||
}
|
||||
log_message('warning', "stripExifFallback: Removing all APP markers from {$filepath}: " . implode(', ', $marker_names));
|
||||
|
||||
$new_content = $content;
|
||||
foreach (array_reverse($markers) as $marker_info) {
|
||||
$new_content = substr_replace($new_content, '', $marker_info[0], $marker_info[1]);
|
||||
|
||||
Reference in New Issue
Block a user