Copy link to clipboard
Copied
I have a batch of JPGs without an embedded RGB profile that I need to change to sRGB. The images have been extracted from a very large and complex PSD file that the web designer provided, and then "Exported as JPG" to appropriate file size and quality for quick loading of the web pages that are being built. Unfortunately I did not notice until too late that the "Embed Color Profile" check box was unchecked. I know I can just open the JPGs and Convert to Profile > sRGB, but then I have to save the JPG again, which results in a further loss of image quality and/or a change of the file size. I don't want to change the image in anyway except to embed the sRGB profile. I can't figure out any way to achieve this, and I don't think it's possible, but I thought I'd put it out there to see if anyone else has a better solution than diving back into the complex original PSD file and extracting the images again, this time with the "Embed Color Profile" check box checked. Thanks!
Copy link to clipboard
Copied
What OS are you using? OSX comes with an AppleScript droplet that uses a shell script to embed a chosen profile into the files dragged on to the droplet. The script name is Embed.app.
Copy link to clipboard
Copied
I am using OS 10.12.6. Where can I find "Embed.app"? A search on my computer and online has not come up with it. Sounds like it could be just what I need.
Copy link to clipboard
Copied
I found the apple script at: Prepression: ColorSync AppleScript Archive
Embed
I copied it into a new Script Editor file and compiled it and saved it. That allows me to run the script and embed the sRGB profile to one file at a time. I'm not sure how to create a droplet from this. But even so, just using the script will save me loads of time. Thank you.
Here is the script:
(*
Embed
©2009 Apple, Inc.
Use sips to embed a profile into an image.
*)
on run
display dialog "Embed a profile into an image."
set chosenFile to choose file with prompt "Choose an image " default location path to desktop folder
open chosenFile
end run
on open draggedItems
set embedProf to choose file with prompt "Choose profile to embed" default location POSIX file "/System/Library/ColorSync/Profiles"
repeat with thisFile in (draggedItems as list)
try
-- use 'sips --embedProfile' to embed the specified profile
-- or use 'sips --embedProfileIfNone' to embed the specified profile only if the image doesn't have an embeded profile
set profPath to quoted form of POSIX path of embedProf
set filePath to quoted form of POSIX path of thisFile
set cmdLine to ("sips --embedProfile " & profPath & " " & filePath) as string
do shell script cmdLine
end try
end repeat
end open
Copy link to clipboard
Copied
Ok, I created a droplet of the script by exporting it from Script Editor as an app. Now I can drag multiple files onto the droplet and embed them as sRGB. Great!! Except the file sizes are changing… getting much larger. An untagged JPG that was 149KB went to 347KB and the other went from 61KB to 92KB. Any idea why just embedding the sRGB profile with this script is causing the file size to grow so dramatically? Thanks for any info you might have. Much appreciated.
Copy link to clipboard
Copied
Have you tried opening one of the untagged jpgs in Photoshop and resaving it with a profile? I think it is expected behavior for embedded profiles to add weight.
Are these jpgs for web display or print? If they are for web only you might consider leaving them untagged because browsers (at least on the Mac side) display untagged RGB color as sRGB.
Here's tagged sRGB in Photoshop vs. the same file with no profile in Safari:
Copy link to clipboard
Copied
When I open a PSD and Export as JPG with a quality setting of 50 and no embedded profile, the file size is 46KB. When I do the exact same export, but embed the sRGB the file size is 49KB. So, at least when exporting as JPG from within Photoshop, the embedded color profile only adds 3KB. But when I run the untagged 46KB file through the droplet to embed the sRGB, it grows to 86KB. The sRGB profile itself is only 3KB, so I have no idea why the file size is increasing so much.
ExifTool looks a bit beyond my knowledge scope.
The client who is building the website just told me not to worry about the untagged images for now, so hopefully it won't be a problem. Good to know that Safari displays untagged images as sRGB.
Thanks for your input!
Copy link to clipboard
Copied
Looks like the shell script is recompressing the file as well as adding the profile onthe save.
It's hard to imagine a web only scenario where editing in the sRGB space and then including the profile would be worth any file size increase. Mobile operating systems don't have any options for screen calibration, and last I checked iOS browsers will honor embedded profiles, but the destination monitor profile is assumed to be sRGB, so a color manged conversion would be sRGB to sRGB.
You could edit in a larger space like ProPhoto in an attempt to get at the full color gamut of a client's wider gamut display, and in that case you would have to include the profile to maintain the color appearance in a browser that honors embedded profiles.
Copy link to clipboard
Copied
The AppleScript is running sips --embedprofile <profilename> <jpegname>
The hope is that it is just going to stick a profile in the file, but the documentation for sips doesn't promise this.
I tested in a 10.10.5 machine and I can confirm that it is reading the image and recompressing; in my case it was getting much smaller.
So this is a failure, not of sips, but of our expectations of it.
Others on the web have had the same expectations and surprise.
Copy link to clipboard
Copied
Right, if you don't include a compression number there must be a default. You can't get around the double compression, but you could include the compression number used for the original save to jpeg. So this would be 60 quality:
(*
Embed
©2009 Apple, Inc.
Use sips to embed a profile into an image.
*)
on run
display dialog "Embed a profile into an image."
set chosenFile to choose file with prompt "Choose an image " default location path to desktop folder
open chosenFile
end run
on open draggedItems
set embedProf to choose file with prompt "Choose profile to embed" default location POSIX file "/System/Library/ColorSync/Profiles"
repeat with thisFile in (draggedItems as list)
try
-- use 'sips --embedProfile' to embed the specified profile
-- or use 'sips --embedProfileIfNone' to embed the specified profile only if the image doesn't have an embeded profile
set profPath to quoted form of POSIX path of embedProf
set filePath to quoted form of POSIX path of thisFile
set cmdLine to ("sips -s format jpeg -s formatOptions 60 --embedProfile " & profPath & " " & filePath) as string
do shell script cmdLine
end try
end repeat
end open
But if the embedded sRGB profile is having an meaningful affect on browser viewing, someone should be able to post a screen capture showing a difference between sRGB and no profile.
Copy link to clipboard
Copied
Another option is ExifTool...
Mac OS Terminal.app command line code to recursively embedd an sRGB ICC profile in all JPG files under a top level directory, overwriting original files without creating backups:
exiftool -overwrite_original -ext jpg '-ICC_Profile<=/Library/Application Support/Adobe/Color/Profiles/Recommended/sRGB Color Space Profile.icm' -r '/Users/username/Desktop/input file or folder'
There should only an approx. 3-5kb file size change in the before/after image for a matrix based sRGB profile (ExifTool does not change the binary image data, only metadata).
Prepression: Automator – DIY ExifTool GUI Services
__________________
MS Windows OS command line code to recursively embedd an sRGB ICC profile in all JPG files under a top level directory, overwriting original files without creating backups:
exiftool -overwrite_original -ext jpg "-ICC_Profile<=C:\Windows\System32\spool\drivers\color\sRGB Color Space Profile.icm" -r "C:\Users\username\Desktop\input file or folder"
Copy link to clipboard
Copied
Stephen, any chance you would be willing to write up step by step instructions for using exiftool to accomplish this sRGB embed (Mac OS 10.12.6) without changing the image quality and only adding 3KB to the file size? I'm not a programmer, so the instructions would need to be understandable by a graphic artist. Thanks.
Copy link to clipboard
Copied
Stephen, any chance you would be willing to write up step by step instructions for using exiftool to accomplish this sRGB embed (Mac OS 10.12.6) without changing the image quality and only adding 3KB to the file size? I'm not a programmer, so the instructions would need to be understandable by a graphic artist. Thanks.
You should give yourself more credit... However I do understand, many GUI users are reluctant or avoid using a CLI when they should not be. I was the same once myself, however I was missing out as I wanted to do things that only CLI tools or scripting would allow and CLI is much easier than JavaScript for a non-coder to learn.
P.S. There are ways to run CLI without needing to enter the code more than once and there are also some GUI front ends for CLI tools, however they are often a crutch and only offer simple edits, then you still need to enter CLI code for other uses.
My post #6 did cover the exact command required (however it does presume some knowledge)*:
You need to know/find the exact file path and spelling to various files and folders. You can usually get info/properties and copy the path or drag the file or sometimes folder into a text editor to capture the path or drag the file or folder into a command line tool to capture the path.
*Until I can write a blogpost covering ExifTool for new users/GUI users, please start with these links:
Some visual and or animated examples that I have created in either the Bridge or Photoshop forums and their scripting sub-forums may also help:
Re: Bridge not showing time created, only date
Re: changing UPPER to lowercase keywords in Bridge or Lightroom
Re: Script or Action to Batch Determine Transparency?
Re: Action that can read and put metadata from CSV file?
Searching either the Bridge or Photoshop forums or their scripting sub-forums for the keyword “Exiftool” will bring up many hits with various examples.
I also have some posts on ExifTool here that may help with some examples:
Find more inspiration, events, and resources on the new Adobe Community
Explore Now