WP_Image_Editor_Imagick::strip_meta PHP Method

strip_meta() protected method

Strips all image meta except color profiles from an image.
Since: 4.5.0
protected strip_meta ( ) : true | WP_Error
return true | WP_Error True if stripping metadata was successful. WP_Error object on error.
    protected function strip_meta()
    {
        if (!is_callable(array($this->image, 'getImageProfiles'))) {
            /* translators: %s: ImageMagick method name */
            return new WP_Error('image_strip_meta_error', sprintf(__('%s is required to strip image meta.'), '<code>Imagick::getImageProfiles()</code>'));
        }
        if (!is_callable(array($this->image, 'removeImageProfile'))) {
            /* translators: %s: ImageMagick method name */
            return new WP_Error('image_strip_meta_error', sprintf(__('%s is required to strip image meta.'), '<code>Imagick::removeImageProfile()</code>'));
        }
        /*
         * Protect a few profiles from being stripped for the following reasons:
         *
         * - icc:  Color profile information
         * - icm:  Color profile information
         * - iptc: Copyright data
         * - exif: Orientation data
         * - xmp:  Rights usage data
         */
        $protected_profiles = array('icc', 'icm', 'iptc', 'exif', 'xmp');
        try {
            // Strip profiles.
            foreach ($this->image->getImageProfiles('*', true) as $key => $value) {
                if (!in_array($key, $protected_profiles)) {
                    $this->image->removeImageProfile($key);
                }
            }
        } catch (Exception $e) {
            return new WP_Error('image_strip_meta_error', $e->getMessage());
        }
        return true;
    }