Remove EXIF orientation tag after image processing
Ensures EXIF orientation is cleared when cloning and after rotation, preventing incorrect display in EXIF-aware viewers. Failures are logged as debug messages without interrupting processing.
This commit is contained in:
parent
f4893a39e9
commit
bbda970d57
1 changed files with 25 additions and 0 deletions
|
|
@ -113,6 +113,18 @@ public class ImageCreatorAlternate : IImageCreator
|
||||||
// Clone editable image so we don't mutate the original reference unexpectedly.
|
// Clone editable image so we don't mutate the original reference unexpectedly.
|
||||||
using var working = imgSharp.Clone();
|
using var working = imgSharp.Clone();
|
||||||
|
|
||||||
|
// Ensure the EXIF orientation tag is not present on the working image so
|
||||||
|
// the final saved file has correct upright pixels and won't be
|
||||||
|
// re-oriented by EXIF-aware viewers.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
working.Metadata?.ExifProfile?.RemoveValue(ExifTag.Orientation);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger?.LogDebug(ex, "[Alternate] Failed to clear EXIF orientation on working image");
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure DataFoto is set (extracted earlier) so time-based text is available
|
// Ensure DataFoto is set (extracted earlier) so time-based text is available
|
||||||
imgState.DataFoto = imgState.CreationDate ?? DateTime.Now;
|
imgState.DataFoto = imgState.CreationDate ?? DateTime.Now;
|
||||||
|
|
||||||
|
|
@ -500,6 +512,19 @@ public class ImageCreatorAlternate : IImageCreator
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After applying the pixel rotation, remove the EXIF orientation tag so
|
||||||
|
// viewers do not re-apply the rotation. Leaving the tag causes some
|
||||||
|
// viewers to display the image in the wrong (original) orientation.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
img.Metadata?.ExifProfile?.RemoveValue(ExifTag.Orientation);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Non-fatal: log and continue
|
||||||
|
_logger?.LogDebug(ex, "[Alternate] Could not clear EXIF orientation tag");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private System.Drawing.Size ComputeBigSize(int width, int height)
|
private System.Drawing.Size ComputeBigSize(int width, int height)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue