How can I embed an ICC color profile in a JPEG file?

25 views (last 30 days)
Matlab (R2020a) offers no native option to embed ICC color profiles in JPEG files. How can I do it?

Accepted Answer

Vlad Atanasiu
Vlad Atanasiu on 17 Jul 2020
Here is how to embed an ICC color profile in JPEG file.
Step 1. Download Phil Harvey's ExifTool from https://exiftool.org: for PC the "Windows Executable" and for Mac the Perl library.
Step 2. Change the ExifTool name: for PC from exiftool(-k).exe to exiftool.exe and for Mac from exiftool to exiftool.pl.
Step 3. Locate the ICC color profiles on your hard disk. The file names of some of the most common profiles are sRGB Profile.icc and AdobeRGB1998.icc.
Step 4. Execute the code below, in which you adapt the paths of your image, ExifTool and ICC profile files.
Note: If you wish to embed an ICC color profile in a TIFF file, follow Steve Eddins's advices at https://blogs.mathworks.com/steve/2009/10/20/embedding-an-icc-profile-into-a-tiff-file/.
% Image file location (change as needed).
image_url = fullfile('image_path','image.jpg');
% ICC color profile file location (change as needed).
icc_url = fullfile('icc_profiles_path','icc_profile.icc');
% ExifTool file location (change as needed).
if ispc
exiftool_url = fullfile('exiftool_path','exiftool.exe');
else
exiftool_url = fullfile('exiftool_path','exiftool.pl');
end
% Copy ICC color profile from ICC definition file into image file.
icc_embed_status = system(...
[ '"', exiftool_url, ...
'" -q -tagsFromFile "', ...
icc_url, '" -ICC_Profile "', ...
image_url,'"' ]);
% Delete image backup file produced by exiftool.
if icc_embed_status == 0
delete([image_url,'_original'])
else
icc_status = 'No ICC color profiles embeded in JPEG files.';
end

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!