0

How do I successfully remove an images property items? I have tried loading the image and then looping thru using the image.ProperyIdList and then calling .RemovePropertyItem and then saving the image to a new file, but the new file still has all the metadata. I have also tried to zero out all the bytes for each propertyItem.value but that causes a genric gdi+ error when I save. I have also tried pushing the image into a memeory stream and back, thinking it would clear the metadata. Any ideas?

1 Answer 1

0

I was able to accomplish the following by using the code below. It is not the fastest but it does work. I basically strip off the metadata I want and then create a new image for the web with no properties, thus making sure the personal data is off the photo.

Using img As Image = Image.FromFile(fileName)
            Using newImage As New Bitmap(img.Width, img.Height)

                Using gr As Graphics = Graphics.FromImage(newImage)
                    gr.InterpolationMode = Drawing2D.InterpolationMode.Bilinear
                    gr.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height))
                End Using
                newImage.Save(newFileName)
            End Using
        End Using
1
  • Hmm, just did this, but noted the file size increased by about 14k, just for those who come after... (30.694 bytes up to 45,191 bytes after saving)
    – jwwishart
    Sep 6, 2012 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.