several months ago I subscribed this list and started my AppleScript journey. I expanded a lot my computing power and the way that my FileMaker Digital Assets Management interact with other applications.
Good, now I can import the most important image formats, including embedded Metadata, create four Versions from images (MasterFile, DisplayImage, WebImage and Thumbnail), then, the best of all I can create Custom Version with several option: Size, Format, Compression level, Profile.
Custom Versions are generated from FileMaker, from a Collection of Images, using the Internal MasterFile created on importing...
... everything works as expected... but I cannot find the solution for one important detail: the Image Resolution.
It seems that resolution is a property used to reed resolution not to modify... but I believe much more that I am not writing the correct code.
Below, the Conversion Handler of the importing script (I hope to be useful for some beginner like me)
on runConversion(theMasterFile)
tell application "Finder"
set theType to file type of theMasterFile
set saveExt to extension hidden of theMasterFile
set extension hidden of theMasterFile to true
set theFolder to (container of theMasterFile) as text
set theFilename to displayed name of theMasterFile
set extension hidden of theMasterFile to saveExt
end tell
tell application "Image Events"
launch
set imageFile to (open theMasterFile)
-- create the Hires Image
set theHiresImage to save imageFile as JPEG ¬
with compression level high in (theHiresFolder as text) & (theFilename) & ".jpg"
set theHiresImage to theHiresImage as alias
-- create the Preview Image
set saveFolder to thePreviewFolder
set newHeight to 1024
set newWidth to 1024
set theSize to dimensions of imageFile
set width to item 1 of theSize
set height to item 2 of theSize
if height > width then
scale imageFile to size newHeight
else
scale imageFile to size newWidth
end if
set thePreviewImage to save imageFile as JPEG ¬
with compression level high in ¬
(thePreviewFolder as text) & (theFilename) & ".jpg"
set thePreviewImage to thePreviewImage as alias
-- create the Web500px image
set saveFolder to theWebFolder
set newHeight to 500
set newWidth to 500
set theSize to dimensions of imageFile
set width to item 1 of theSize
set height to item 2 of theSize
if height > width then
scale imageFile to size newHeight
else
scale imageFile to size newWidth
end if
set theWebImage to save imageFile as JPEG ¬
with compression level high in ¬
(theWebFolder as text) & (theFilename) & ".jpg"
set theWebImage to theWebImage as alias
-- create Thumbnail
set saveFolder to theThumbFolder
set newHeight to 210
set newWidth to 210
set theSize to dimensions of imageFile
set width to item 1 of theSize
set height to item 2 of theSize
if height > width then
scale imageFile to size newHeight
else
scale imageFile to size newWidth
end if
set theThumbImage to save imageFile as ¬
JPEG with compression level high ¬
in (theThumbFolder as text) & (theFilename) & ".jpg"
set theThumbImage to theThumbImage as alias
close imageFile
end tell
tell application "ColorSyncScripting"
embed theHiresImage with source profile "Adobe RGB (1998)" matching with perceptual intent
set quality of first profile in theHiresImage to best
embed thePreviewImage with source profile "sRGB IEC61966-2.1" matching with perceptual intent
set quality of first profile in thePreviewImage to best
embed theWebImage with source profile "sRGB IEC61966-2.1" matching with perceptual intent
set quality of first profile in theWebImage to best
embed theThumbImage with source profile "sRGB IEC61966-2.1" matching with perceptual intent
set quality of first profile in theThumbImage to best
end tell
end runConversion