AppleScript Photos export quality In AppleScript, I can export photos from Apple Photos. There are two options:

using originals, which discards all modifications I've made
not using originals, which exports them at 100% quality.

The export at 100% quality is practically uncompressed, even when the original photo is more compressed. This ends up taking more space than the original, effectively upsampling the photo, at no added benefit.
Is it possible to keep the original quality, but not lose the edits made in Photos?
Note that a switch for quality exists in Photos, as per screenshot below.

EDIT
I ended up writing and using this.
Note that this does still NOT solve my problem, as explained in the comments, but it gives me a suitable approximation.
(* 
Export Apple Photos
===================

Exports all photos in Apple Photos library and reduces them to 90% quality. 
The photos are in their current version (as opposed to the original). 
Quality reduction is done with `mogrify` as setting the quality isn't 
possible (nor it is possible to get the current quality -- everything 
gets exported at 100%). For more on this issue see [1].


TODO
----

* Albums in the top folder (i.e. outside any folder) aren't exported. 
  Only albums in folders are exported. To list them run this::

    tell application &quot;Photos&quot;
        repeat with alb in albums
            log (get name of alb)
        end repeat
    end tell

References
----------

[1] https://apple.stackexchange.com/questions/410229/applescript-photos-export-quality

*)


-- main
tell application &quot;Photos&quot;
    repeat with topFolder in folders
        my processFolder(topFolder, 0, (get name of topFolder))
    end repeat
end tell


-- recursively scan folders and export albums
on processFolder(fold, level, dirpath)
    tell application &quot;Photos&quot;
        log &quot;Folder &quot; &amp; (get name of fold)
        repeat with subFolder in (get folders of fold)
            set subPath to dirpath &amp; &quot;/&quot; &amp; (get name of subFolder)
            my exportAlbum(subFolder, subPath)
            my processFolder(subFolder, level + 1, subPath)
        end repeat
        my exportAlbum(fold, dirpath)
    end tell
end processFolder


-- export all albums in folder `f`
on exportAlbum(f, relativePath)
    set dest to &quot;/Volumes/DATA/ApplePhotos/&quot; as POSIX file as text -- the destination folder (use a valid path)
    
    tell application &quot;Photos&quot;
        repeat with i in (get albums of f)
            set tFolder to (the POSIX path of (dest as string) &amp; relativePath &amp; &quot;/&quot; &amp; (get name of i)) as POSIX file as text
            repeat 1 times
                tell application &quot;Finder&quot;
                    if exists tFolder then
                        log &quot;Skipping album &quot; &amp; (get name of i)
                        exit repeat
                    end if
                end tell
                log &quot;Album &quot; &amp; (get name of i) &amp; &quot; -&gt; &quot; &amp; tFolder as POSIX file as text
                my makeFolder(tFolder) -- create a folder named (the name of this album) in dest
                with timeout of 120 * 60 seconds -- 2 hours
                    
                    export (get media items of i) to (tFolder as alias) without using originals
                    my reduceSize(tFolder)
                end timeout
            end repeat
        end repeat
    end tell
end exportAlbum


-- util mkdir
on makeFolder(tPath)
    do shell script &quot;mkdir -p &quot; &amp; quoted form of POSIX path of tPath
end makeFolder


-- util shell script to reduce file size (quality 90)
--   note: it checks folder is not empty, otherwise mogrify will fail.
on reduceSize(tPath)
    set dirpath to quoted form of POSIX path of tPath &amp; &quot;/*.jpeg&quot;
    do shell script &quot;ls &quot; &amp; dirpath &amp; &quot;; if [ $? -eq 0 ]; then /usr/local/bin/mogrify -quality 90 &quot; &amp; dirpath &amp; &quot;; else echo No files in folder &quot; &amp; dirpath &amp; &quot;; fi&quot;
end reduceSize
You could use the third-party tool ImageMagick, which can perform a wide variety of image transformations, including converting to a lower quality. You can install it with Homebrew with brew install imagemagick. You would include it through the do shell script command, for example do shell script 'convert input.png -quality 85% output.jpg'.