The below code displays:
Prior: 271 272 274 282 283 296 305 306 531 33432 33437 34850 34855 36864 36867 36868 37121 37122 37377 37378 37379 37380 37381 37383 37385 37386 37500 40960 40961 40962 40963 20545 20546 41486 41487 41 488 41495 41728 41729 20507 20515 20521 20525 20526 20528 513 514 20537 20625 20624
then:
After:
so it seems to be removing the EXIF/metadata, but when I save the file and compare non_2, to _2 file, with the likes of https://pics.io/photo-metadata-viewer, I see exactly the same metadata. If I remove metadata using this tool, save, and reopen it, FAR less metadata exists.
What am I missing that causes the presumed removal of metadata with the code prior to save, not actually making it into the saved file?
$FullPath = "C:UsersPublicDownloadsFujifilm_FinePix6900ZOOM.jpg"
$FS = [System.IO.File]::Open($FullPath,3)
$Image = [System.Drawing.Image]::FromStream($FS, $false, $false)
$PropertyItems = $Image.PropertyIdList
write-host "Prior: $propertyItems"
foreach($propertyItem in $propertyItems)
{
$image.removepropertyitem($propertyItem)
}
$JpegCodec = [system.drawing.imaging.imagecodecinfo]::getimageencoders() | where-object { $_.MimeType -eq "image/jpeg" }
$EncoderParams = new-object system.drawing.imaging.encoderparameters
$Encoder = [system.drawing.imaging.encoder]::quality
$EncoderParam = new-object system.drawing.imaging.encoderparameter($Encoder, 100)
$EncoderParams.param[0] = $EncoderParam
$FullPath = "C:UsersPublicDownloadsFujifilm_FinePix6900ZOOM_2.jpg"
$Image.save($FullPath,$JpegCodec,$EncoderParams)
$PropertyItems = $image.PropertyIdList
write-host "After: $propertyItems"
$Image.dispose | out-null
$FS.close() | out-null