Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Assign sRGB profile to JPGs that have already been downsampled without changing image quality or size?

New Here ,
Nov 17, 2018 Nov 17, 2018

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!

3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Nov 17, 2018 Nov 17, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 17, 2018 Nov 17, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 17, 2018 Nov 17, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 17, 2018 Nov 17, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2018 Nov 17, 2018

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:

Screen Shot 6.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 17, 2018 Nov 17, 2018

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.

Screen Shot 2018-11-17 at 4.44.25 PM.png

Screen Shot 2018-11-17 at 4.45.31 PM.png

Screen Shot 2018-11-17 at 4.59.10 PM.png

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2018 Nov 18, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 18, 2018 Nov 18, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2018 Nov 18, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2018 Nov 17, 2018

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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 18, 2018 Nov 18, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2018 Nov 18, 2018
LATEST
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)*:

Re: Assign sRGB profile to JPGs that have already been downsampled without changing image quality or...

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:

Installation

Running

First use

Dummies

Getting started with the CLI

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:

Prepression: ExifTool

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines