denisoid
denisoid

Reputation: 163

Apply built-in color profile to image

I have one JPEG-picture with embeded color profile. Some web-browsers show image with applied profile, some not. How to apply color profile to image and delete profile, that all browsers display image identically.

I tried solve problem by image magick extension, but image still show different in different browsers:

    function add_color_profiles($source_path, $target_path){

            $all_exts = get_loaded_extensions();
            if(!in_array('imagick',$all_exts))
                    return true;

            $im1 = new Imagick($source_path);
            $im2 = new Imagick($target_path);

            $profiles = $im1->getImageProfiles();


            if(!$profiles)
                    return true;

            foreach($profiles as $name => $profile){

                    $im2->setImageProfile($name,$profile);
            }

            $im2->writeImage ($target_path);

            return true;
    }

Upvotes: 6

Views: 1146

Answers (1)

clover
clover

Reputation: 5170

Apply profile to an image (convert image colorspace to RGB):

$im->setImageColorspace(IMagick::COLORSPACE_RGB);

Strip profile information from an output file:

$im->profileImage('*', NULL);

Strip an image of all profiles, exif (comments GPS data etc.):

$im->stripImage();

Upvotes: 3

Related Questions