Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(exif): Enable EXIF Writing using FIMD_EXIF_RAW #14

Merged
merged 1 commit into from
May 9, 2024

Conversation

ProbablePrime
Copy link
Member

FreeImage keeps two separate copies of Exif Metadata in memory:

  • One is used/found in MDM_EXIF_MAIN and its extensions(e.g. MDM_EXIF_GPS).
  • Another one is used when files are actually written that support the EXIF Format.
  • In some cases you want to access, the raw data.
  • A good example of this is when using MetadataModel.DestroyModel to wipe EXIF data on an image that you wanted persisted if that file is exported again from FreeImage.
  • DestoryModel was also corrected to DestroyModel, this will result in a breaking change version but that's worth it!

With this you can use the following to clear and persist that "clearing" of the exif data on a FreeImage image:

ImageMetadata imageMetadata = new ImageMetadata(dib, true, true);
var model = imageMetadata[FREE_IMAGE_MDMODEL.FIMD_EXIF_RAW];
model.DestroyModel();

When you then write that subsequent image to a file, the file will not contain any EXIF data!

This is based on:

As this change doesn't touch the native library, you won't need to compile that again. This is a purely .NET change. -

FreeImage keeps two separate copies of Exif Metadata in memory:
- One is used/found in MDM_EXIF_MAIN and its extensions(e.g. MDM_EXIF_GPS).
- Another one is used when files are actually written that support the EXIF Format.
- In some cases you want to access, the raw data.
- A good example of this is when using MetadataModel.DestroyModel to wipe EXIF data on an image that you wanted persisted if that file is exported again from FreeImage.
- DestoryModel was also corrected to DestroyModel, this will result in a breaking change version but that's worth it!

With this you can use the following to clear and persist that "clearing" of the exif data on a FreeImage image:
```cs
ImageMetadata imageMetadata = new ImageMetadata(dib, true, true);
var model = imageMetadata[FREE_IMAGE_MDMODEL.FIMD_EXIF_RAW];
model.DestroyModel();
```

When you then write that subsequent image to a file, the file will not contain any EXIF data!

This is based on:
- https://sourceforge.net/p/freeimage/discussion/36111/thread/2d087f91/ where i discovered FIMD_EXIF_RAW
- https://sourceforge.net/p/freeimage/discussion/36111/thread/8233f5bc/ where I learnt how you might use it.

As this change doesn't touch the native library, you won't need to compile that again. This is a purely .NET change.
-
@ProbablePrime
Copy link
Member Author

@ProbablePrime
Copy link
Member Author

ProbablePrime commented May 9, 2024

While this is straight forward, I'm still wanting at least 1 team review from Geenz or Froox. Due to the nature of free-image being very complicated.

@@ -148,7 +148,7 @@ public bool RemoveTag(string key)
/// which will remove all tags of this model from the bitmap.
/// </summary>
/// <returns>Returns true on success, false on failure.</returns>
public bool DestoryModel()
public bool DestroyModel()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling is important.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially when it tells a "destory"

@Geenz
Copy link

Geenz commented May 9, 2024

Looks good to me.

@ProbablePrime ProbablePrime removed the request for review from Frooxius May 9, 2024 00:53
@ProbablePrime
Copy link
Member Author

Ok, I'll roll a new version thanks!, this unblocks some work im doing!

@ProbablePrime ProbablePrime merged commit 0717e93 into main May 9, 2024
2 checks passed
@ProbablePrime ProbablePrime deleted the prime/feat/clear-exif branch May 9, 2024 00:54
@ProbablePrime
Copy link
Member Author

More context now available here: Yellow-Dog-Man/Resonite-Issues#2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants