Title: WP_Image_Editor_Imagick::strip_meta
Published: April 12, 2016
Last modified: August 20, 2026

---

# WP_Image_Editor_Imagick::strip_meta(): true|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/strip_meta/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/strip_meta/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/strip_meta/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/strip_meta/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/strip_meta/?output_format=md#wp--skip-link--target)

Strips all image meta except color profiles from an image.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/strip_meta/?output_format=md#return)󠁿

 true|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) True
if stripping metadata was successful. [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
object on error.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/strip_meta/?output_format=md#source)󠁿

    ```php
    protected function strip_meta() {

    	if ( ! is_callable( array( $this->image, 'getImageProfiles' ) ) ) {
    		return new WP_Error(
    			'image_strip_meta_error',
    			sprintf(
    				/* translators: %s: ImageMagick method name. */
    				__( '%s is required to strip image meta.' ),
    				'<code>Imagick::getImageProfiles()</code>'
    			)
    		);
    	}

    	if ( ! is_callable( array( $this->image, 'removeImageProfile' ) ) ) {
    		return new WP_Error(
    			'image_strip_meta_error',
    			sprintf(
    				/* translators: %s: ImageMagick method name. */
    				__( '%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, true ) ) {
    				$this->image->removeImageProfile( $key );
    			}
    		}
    	} catch ( Exception $e ) {
    		return new WP_Error( 'image_strip_meta_error', $e->getMessage() );
    	}

    	return true;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-image-editor-imagick.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-image-editor-imagick.php#L1267)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-image-editor-imagick.php#L1267-L1320)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/strip_meta/?output_format=md#related)󠁿

| Uses | Description | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

| Used by | Description | 
| [WP_Image_Editor_Imagick::thumbnail_image()](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/thumbnail_image/)`wp-includes/class-wp-image-editor-imagick.php` |

Efficiently resize the current image

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/strip_meta/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.5.0](https://developer.wordpress.org/reference/since/4.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_image_editor_imagick%2Fstrip_meta%2F)
before being able to contribute a note or feedback.