Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-75850

Add the ability to configure automatic EXIF data removal from uploaded images

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_403_STABLE, MOODLE_404_STABLE, MOODLE_405_STABLE
    • MOODLE_405_STABLE
    • MDL-75850-main-fix
    • Hide

      1. Setup requirements:

      1. Install the exiftool to your local machine by following the instructions on https://exiftool.sourceforge.net/install.html.
        If you have any problems following the instructions on the web page, you can always search on your favourite search engine, as I did. I'm running my machine on Ubuntu, so I searched "How to install exiftool on ubuntu", and I found the easiest way to do it by only running "sudo apt install exiftool," which didn't exist in the installation instructions.
      2. Download two attached files: pic.jpg and pic.tiff

      2. Test default setting for fresh install

      1. Create a new instance, but don't install it yet.
      2. Pull the patch
      3. Install via Web
      4. Navigate to Site Admin > Server > File redact > EXIF remover
      5. VERIFY the exifremoverenabled is enabled.

      Please repeat the whole process, but for the step 3, install the new instance via CLI.

      3. Test upgrade

      1. Login as admin.
      2. Run the upgrade.
      3. During the upgrade, VERIFY there is a new setting. EXIF remover setting.
      4. VERIFY the Enable EXIF remover checkbox is disabled as default.
      5. Please enable it and leave the other config as-is.
      6. Save changes.
      7. Create a course and navigate to the course page.
      8. Turn ON the edit mode.
      9. Add a File resources
      10. Specify the name with "Test EXIF remover".
      11. At the description, Add an image by uploading the pic.jpg
      12. At the Select files. Upload the pic.tiff
      13. Click the Save and Display button.
      14. VERIFY you see the pic.jpg image.
      15. Download the image by clicking the image with a right mouse click to show the context menu and then click the "save image as".
      16. VERIFY there is a text "Click pic.tiff link to view the file" and the "pic.tiff" text is clickable.
      17. Click the "pic.tiff" link to download the image.
      18. Open a new browser tab and access https://exif.tools/
      19. Upload the two images that you have downloaded to the website to view the metada. Please, do it one by one.
      20. VERIFY the downloaded jpg file doesn't contain the GPS, Aperture, Field Of View, and other existing tag names before the removal.
      21. VERIFY the downloaded tiff file still has the EXIF tags.
      22. Repeat the steps based on the below config table and specify the VERIFY column to pass or fail depend on the manual test result. The file redact settings is in the Site admin > Server > File redact > EXIF remover.
      Test name Enabled Path to Exiftool Remove tags Expected JPG Expected TIFF Expected Orientation tag Verify
      Test 1 Yes Empty Any value All tags removed Tags persist Removed Pass/Fail
      Test 2 Yes /usr/bin/exiftool GPS Only GPS tags removed GPS tags removed Still exist Pass/Fail
      Test 3 Yes /usr/bin/exiftool All All tags removed All tags removed Still exist Pass/Fail

      Steps to run the PHPUnit for EXIF remover

      1. Open config.php and add the below codes:

        define('TEST_PATH_TO_EXIFTOOL', '/usr/bin/exiftool');

        /usr/bin/exiftool is a path to the exiftool. You can replace it according to the location on your machine.

      1. VERIFY all the tests in lib/tests/fileredact/manager_test.php are passed.
      2. VERIFY all the tests in lib/tests/fileredact/exifremover_service_test.php are passed.
      Show
      1. Setup requirements: Install the exiftool to your local machine by following the instructions on https://exiftool.sourceforge.net/install.html . If you have any problems following the instructions on the web page, you can always search on your favourite search engine, as I did. I'm running my machine on Ubuntu, so I searched "How to install exiftool on ubuntu", and I found the easiest way to do it by only running "sudo apt install exiftool," which didn't exist in the installation instructions. Download two attached files: pic.jpg and pic.tiff 2. Test default setting for fresh install Create a new instance, but don't install it yet. Pull the patch Install via Web Navigate to Site Admin > Server > File redact > EXIF remover VERIFY the exifremoverenabled is enabled. Please repeat the whole process, but for the step 3, install the new instance via CLI. 3. Test upgrade Login as admin. Run the upgrade. During the upgrade, VERIFY there is a new setting. EXIF remover setting. VERIFY the Enable EXIF remover checkbox is disabled as default. Please enable it and leave the other config as-is. Save changes. Create a course and navigate to the course page. Turn ON the edit mode. Add a File resources Specify the name with "Test EXIF remover". At the description, Add an image by uploading the pic.jpg At the Select files. Upload the pic.tiff Click the Save and Display button. VERIFY you see the pic.jpg image. Download the image by clicking the image with a right mouse click to show the context menu and then click the "save image as". VERIFY there is a text " Click pic.tiff link to view the file " and the "pic.tiff" text is clickable. Click the "pic.tiff" link to download the image. Open a new browser tab and access https://exif.tools/ Upload the two images that you have downloaded to the website to view the metada. Please, do it one by one. VERIFY the downloaded jpg file doesn't contain the GPS, Aperture, Field Of View, and other existing tag names before the removal. VERIFY the downloaded tiff file still has the EXIF tags. Repeat the steps based on the below config table and specify the VERIFY column to pass or fail depend on the manual test result. The file redact settings is in the Site admin > Server > File redact > EXIF remover. Test name Enabled Path to Exiftool Remove tags Expected JPG Expected TIFF Expected Orientation tag Verify Test 1 Yes Empty Any value All tags removed Tags persist Removed Pass/Fail Test 2 Yes /usr/bin/exiftool GPS Only GPS tags removed GPS tags removed Still exist Pass/Fail Test 3 Yes /usr/bin/exiftool All All tags removed All tags removed Still exist Pass/Fail Steps to run the PHPUnit for EXIF remover Open config.php and add the below codes: define( 'TEST_PATH_TO_EXIFTOOL' , '/usr/bin/exiftool' ); /usr/bin/exiftool is a path to the exiftool. You can replace it according to the location on your machine. VERIFY all the tests in lib/tests/fileredact/manager_test.php are passed. VERIFY all the tests in lib/tests/fileredact/exifremover_service_test.php are passed.
    • 6
    • Team Hedgehog 2024 Review 1, Team Hedgehog 2024 Sprint 2.1, Team Hedgehog 2024 Sprint 2.2, Team Hedgehog 2024 Sprint 2.3, Team Hedgehog 2024 Review 2, Team Hedgehog 2024 Sprint 3.1, Team Hedgehog 2024 Sprint 3.2

      eporter

      I9NIT3D

      Description

      It should be possible to strip EXIF data, such as geolocation data from images uploaded to Moodle. We want to avoid stripping data such as orientation which could affect the correct displaying of the image, avoid image quality degradation if possible and also maximise the file types supported.

      Steps to Reproduce

      1. Use a browser to navigate to: https://sectesting.moodle.com/course/edit.php?id=8
      2. Upload the attached pic.jpg image.
      3. You can download the image after saving and then upload it to https://exifdata.com/
      4. You can see the Geo Coordinates

      Additional Information from michaelh 

      This appears to affect images in most places (eg course image, images in course description, user profile description, attached or inline in forum posts etc). The only place I tested which was not affected was user profile images, which is actually explained on MDL-70057 (and I think is probably coincidence due to the way profile images are set up). This has been determined to not be an effective method for EXIF removal as it requiresd resaving which causes quality degredation in soe formats (eg JPEG).

      Analysis by meirza.arson@moodle.com found the best approach for this was to utilise a third party library which gives the required functionality on a range of formats, allows us to retain important EXIF data such as orientation, and does not degrade image quality.

       

        1. external-link.png
          external-link.png
          48 kB
        2. MDL-75850.png
          MDL-75850.png
          202 kB
        3. MDL-75850 - 2.png
          MDL-75850 - 2.png
          1.63 MB
        4. MDL-75850 - 3.png
          MDL-75850 - 3.png
          80 kB
        5. pic.jpg
          pic.jpg
          154 kB
        6. pic.tiff
          133 kB

            meirza.arson@moodle.com Meirza
            systems Systems
            David Woloszyn David Woloszyn
            Ilya Tregubov Ilya Tregubov
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 weeks, 4 days, 3 hours, 47 minutes
                2w 4d 3h 47m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.