6
\$\begingroup\$

Recently I came across a bunch of weird JPEGs; here's one of them.

In Firefox 16.0.2 and ACDSee it looks much more vibrant:

1

However in Internet Explorer 9/MS Paint/Paint.NET 3.5.10 (on Windows 7 64-bit) it looks quite dull in comparison and many colors also look completely different:

2

Lots of other apps have problems with the file as well. Here's the image in CDisplay for example:

3

The default browser and Photos app on my Android ICS device refuse to even display the image. Also, when I tried to upload it here I ended up with this:

4

Nice, huh‽ Here's some technical information about the image:

ExifTool Version Number         : 9.05
File Name                       : numeat_pg1.jpg
Directory                       : .
File Size                       : 1281 kB
File Modification Date/Time     : 2012:11:14 06:48:45+05:30
File Access Date/Time           : 2012:11:14 06:48:45+05:30
File Permissions                : rw-rw-rw-
File Type                       : JPEG
MIME Type                       : image/jpeg
JFIF Version                    : 1.02
Exif Byte Order                 : Little-endian (Intel, II)
Compression                     : LZW
Photometric Interpretation      : CMYK
Orientation                     : Horizontal (normal)
Samples Per Pixel               : 4
X Resolution                    : 300
Y Resolution                    : 300
Planar Configuration            : Chunky
Resolution Unit                 : inches
Software                        : Adobe Photoshop CS3 Macintosh
Modify Date                     : 2009:11:24 11:39:46
Color Space                     : Uncalibrated
Exif Image Width                : 753
Exif Image Height               : 1130
Thumbnail Offset                : 424
Thumbnail Length                : 8043
Current IPTC Digest             : 460cf28926b856dab09c01a1b0a79077
Application Record Version      : 2
IPTC Digest                     : 460cf28926b856dab09c01a1b0a79077
Displayed Units X               : inches
Displayed Units Y               : inches
Global Angle                    : 30
Global Altitude                 : 30
Copyright Flag                  : False
Photoshop Thumbnail             : (Binary data 8043 bytes, use -b option to extract)
Photoshop Quality               : 10
Photoshop Format                : Standard
Progressive Scans               : 3 Scans
XMP Toolkit                     : Adobe XMP Core 4.1-c036 46.276720, Mon Feb 19 2007 22:13:43
Document ID                     : uuid:86F2476580DADE118414CEB96D2C8252
Instance ID                     : uuid:87F2476580DADE118414CEB96D2C8252
Native Digest                   : 256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;5845CA8BEE434E1A12E4DC06C8A7E272
Creator Tool                    : Adobe Photoshop CS3 Macintosh
Create Date                     : 2009:11:24 11:39:46-08:00
Metadata Date                   : 2009:11:24 11:39:46-08:00
Format                          : image/jpeg
Color Mode                      : CMYK
ICC Profile Name                : SWOP (Coated), 20%, UCR, 280%
History                         : 
Derived From Instance ID        : uuid:E269F3C87FDADE118414CEB96D2C8252
Derived From Document ID        : uuid:D2CA5D9C5DD0DE11B0D7B511ADC90DF9
Profile CMM Type                : ADBE
Profile Version                 : 2.1.0
Profile Class                   : Output Device Profile
Color Space Data                : CMYK
Profile Connection Space        : Lab
Profile Date Time               : 2009:03:25 15:57:18
Profile File Signature          : acsp
Primary Platform                : Apple Computer Inc.
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : none
Device Model                    : 
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82489
Profile Creator                 : ADBE
Profile ID                      : 0
A To B0                         : (Binary data 395328 bytes, use -b option to extract)
A To B1                         : (Binary data 395328 bytes, use -b option to extract)
A To B2                         : (Binary data 395328 bytes, use -b option to extract)
B To A0                         : (Binary data 291144 bytes, use -b option to extract)
B To A1                         : (Binary data 291144 bytes, use -b option to extract)
B To A2                         : (Binary data 291144 bytes, use -b option to extract)
Profile Copyright               : Copyright 2009 Adobe Systems Incorporated
Profile Description             : SWOP (Coated), 20%, UCR, 280%
Gamut                           : (Binary data 37009 bytes, use -b option to extract)
Media White Point               : 0.9642 1 0.82489
DCT Encode Version              : 100
APP14 Flags 0                   : [14]
APP14 Flags 1                   : (none)
Color Transform                 : YCCK
Image Width                     : 753
Image Height                    : 1130
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 4
Image Size                      : 753x1130
Thumbnail Image                 : (Binary data 8043 bytes, use -b option to extract)

I've been informed that all these problems are thanks to the fact that the image doesn't use the default Windows/Mac sRGB color profile. Searching the net led me to this question, which seems to be the exact opposite of what I want to achieve. So I thought I'd ask here as well.

I have no plans to print these images and I do not have access to Photoshop. How can I convert all the JPEG images to sRGB, hopefully with no further quality loss? Is there any free portable command-line (highly preferable) or GUI program I can use to easily and losslessly batch convert many JPEGs to sRGB?

\$\endgroup\$
0

3 Answers 3

11
\$\begingroup\$

It is normally the responsibility of the viewing software to convert from the color-space of the file to that of the display. From what I understand, you want to do the conversion yourself because you use programs that simply assume sRGB as a color-space.

A lossless conversion is not possible for this. On a properly calibrated system you will also make things worse because you will lose accuracy by converting to sRGB and then lose accuracy when converting to your monitor's color-space.

Nconvert can perform a lossy conversion for you:

nconvert -q 100 -opthuff -dct 2 -subsampling 2 -icc_out sRGB.icc -o <output-filename> <input-filename>

Assuming all files are in the same directory, for example you can on Linux:

foreach x (*.jpg)
    nconvert -icc_out sRGB.icc -o $x:r_srgb.jpg $x

For this you need nconvert and an icc profile for sRGB.

On Windows you will use the FOR statement. I believe there is built-in help to get the proper syntax.

\$\endgroup\$
4
  • \$\begingroup\$ Ah, so lossless conversion of YCCK to sRGB is not possible? If so, will the nconvert command you specified above result in minimal loss due to JPEG re-encoding? Also, will using the sRGB ICC profile allow the image to retain the vibrant colors as displayed by Firefox? \$\endgroup\$
    – Karan
    Commented Nov 15, 2012 at 3:13
  • 1
    \$\begingroup\$ You are confusing two things, compression quality and the accuracy of the conversion. You will lose accuracy during this conversion even if you went to a lossless format, which you can by specifying -out png for example. You can lose less information by going to a higher-bit-depth format (say 48-bit TIFF) but your display cannot show this, so it would only be useful if you were looking to process the files. \$\endgroup\$
    – Itai
    Commented Nov 15, 2012 at 3:51
  • \$\begingroup\$ How does nconvert know the original color profile of an image to convert from? \$\endgroup\$
    – user74070
    Commented Jan 19, 2021 at 21:38
  • \$\begingroup\$ @Boris Files that are problematic in the question are those with a profile specified in them. Otherwise, sRGB is assumed default and so there is no point converting to sRGB. In these cases, nconvert reads the profile from the source image. Now, if you have a file without a profile or you know the profile is incorrect, you can tell nconvert which input profile to assume by giving it the -icc_in parameter. \$\endgroup\$
    – Itai
    Commented Jan 19, 2021 at 21:47
2
\$\begingroup\$

As it was said, lossless is not an option here. To minimize losses throughout the workflow you can use ArgyllCMS. It is a free opensource pre-press quality library for colour conversion and other colour-related things, like profiling. It has a utility cctiff which handles colour space conversions for TIFF and JPEG files. Argyll comes with its own sRGB.icm profile.

Here is how you can use it in your case:

cctiff -e sRGB.icm -ip source.jpg -ip sRGB.icm -p -q100 source.jpg sRGB_converted.jpg

-e sRGB.icm -- to embed sRGB profile into the output file

-ip source.jpg -- to take the source profile right from the source file and use perceptual intent

-ip sRGB.icm -- to convert to sRGB, using perceptual intent

-p -- to use more precise floating point conversion (little slower)

-q100 -- to record the output JPEG is 100% quality.

Sometimes using relative colorimetric intent ( -ir ) makes for better result, Another option is to use a similar library, lcms2.

Depending on the quality and compression of the source file, you may find that the benefit of using Argyll is negligible compared to nconvert and other utilities. The higher is the source quality, the more sense it make to use Argyll. End-user monitors are usually poorly calibrated and profiled, so the colour that you see may look very different on a different monitor, like it is in the shops that sell TVs - same broadcast looks totally different on two TVs standing one right to another.

\$\endgroup\$
1
\$\begingroup\$

It appears that the image uses CMYK (as opposed to RGB) color model. Besides ensuring that your image is converted to sRGB and tagged as sRGB, you also need to convert it to RGB. If you save the results as PNG instead of JPG, you won't induce any further compression-based image loss.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.