Skip to content

Conversation

cristianoliveira
Copy link
Contributor

@cristianoliveira cristianoliveira commented Oct 17, 2025

Summary:
This commit removes the custom handling of EXIF orientation from the JavaScript components, simplifying the rendering logic. It adds support in Go code for resolving the orientation based on the EXIF tag.

Detailed Changes:

  • scheduler/actions/images/encoding/codec.go:
    • Implemented the use of imageorient.Decode to handle image orientation based on EXIF metadata in the image decoding process.
  • scheduler/actions/images/encoding/codec_test.go:
    • Added test to verify orientation handling in the decoding process.
  • scheduler/actions/images/encoding/exif.go:
    • Removed the metadata image_exif_orientation injection for new uploads

DEPS

  • go.mod:
    • Added github.com/disintegration/imageorient package for handling image orientation based on EXIF metadata.

How to check

  • First upload an image that contains an orientation in exif (see the attached examples)
  • Upon upload, the thumbnails should be presented in a intuitive orientation
  • (extra check) Inspect the HTML the thumbs should not contain the classes ort-rotate-x
  • Look also the preview in Home, they should be displayed correctly

Sample:
orientation.zip

Summary:
This commit removes the custom handling of EXIF orientation from the JavaScript components, simplifying the rendering logic. It adds support in Go code for resolving the orientation based on the EXIF tag.

Detailed Changes:
 - frontend/assets/editor.diaporama/res/js/editor.js:
   - Removed all logic related to handling `image_exif_orientation` metadata for styling image elements.
 - frontend/assets/editor.diaporama/res/js/preview.js:
   - Removed EXIF orientation handling logic for image preview adjustments.
 - go.mod:
   - Added `github.com/disintegration/imageorient` package for handling image orientation based on EXIF metadata.
 - go.sum:
   - Updated checksums corresponding to the new Go module additions.
 - scheduler/actions/images/encoding/codec.go:
   - Implemented the use of `imageorient.Decode` to handle image orientation based on EXIF metadata in the image decoding process.
 - scheduler/actions/images/encoding/codec_test.go:
   - Added test to verify orientation handling in the decoding process.
"io"

"github.com/disintegration/imageorient"
"github.com/disintegration/imaging"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we can replace this library as a next step

}}
/>);

} No newline at end of file
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could introduce prettier to enforce removal of the trailing spaces

@cristianoliveira cristianoliveira force-pushed the fix/exif-thumb-orientation-with-lib branch from 89706d7 to 6590239 Compare October 17, 2025 12:23
@cristianoliveira cristianoliveira force-pushed the fix/exif-thumb-orientation-with-lib branch from 6590239 to ac3b57c Compare October 17, 2025 12:25
@cristianoliveira
Copy link
Contributor Author

Looks good!

Demo

output.mp4

Copy link
Member

@cdujeu cdujeu left a comment

Choose a reason for hiding this comment

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

will not be backward compat I think

Copy link
Member

Choose a reason for hiding this comment

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

I don't agree here : old thumbnails will still need the CSS fix!

=> We should let all that code here, and in the backend, just ensure that we do not set this metadata anymore for new ones (EXIF extraction job)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense

I changed to stop injecting the exif orientation for now on, so the new uploads don't contain it, while the old that contains the metadata, the css rotation is applied

Demo

output.mp4

Copy link
Member

@cdujeu cdujeu left a comment

Choose a reason for hiding this comment

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

Last minor check on formats :-)


// Decode reads an image from the provided reader
func (c defaultCodec) Decode(reader io.Reader) (image.Image, error) {
return imaging.Decode(reader)
Copy link
Member

Choose a reason for hiding this comment

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

Sorry to bother again :-)
Does this have any perf implication for formats that do not support exif ? It seems that exif is JPG/TIFF only, maybe we should use the "standard" decode for BMP, PNG, WEBP...?

Copy link
Contributor Author

@cristianoliveira cristianoliveira Oct 17, 2025

Choose a reason for hiding this comment

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

There might be a minor performance hit. For our case I believe is better to configure it upon decoder instantiation, to avoid having non-intuitive rotation only for one format type. Something like:

	t.codec = encoding.NewImageCodec(fileFormat, &encoding.CodecOptions{
		EnforceExifOrientation: true,
	})

Then in case is not enforced it uses the standard encoding

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I notice also that there are some img types that simply don't support exif at all, for instance, GIF / BMP. I see the underlining library handle these already

Copy link
Member

@cdujeu cdujeu left a comment

Choose a reason for hiding this comment

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

Ok for me

@cristianoliveira cristianoliveira merged commit a5ccfdb into v5-dev Oct 20, 2025
2 checks passed
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.

2 participants