wp-includes/class-wp-image-editor-imagick.php:150Loads image from $this->file into new Imagick Object.
true|WP_Error public function load() { if ( $this->image instanceof Imagick ) { return true; } $is_stream = wp_is_stream( $this->file ); $is_file = ! $is_stream && is_file( $this->file ); // Only allow loading files or streams. if ( ! $is_file && ! $is_stream ) { return new WP_Error( 'error_loading_image', __( 'File does not exist?' ), $this->file ); } // Establish the provided filename based on the kind of resource being loaded. $given_filename = $this->file; if ( 0 === strncasecmp( $given_filename, 'file://', 7 ) ) { $given_filename = basename( substr( $given_filename, 7 ) ); // 7 is the strlen of 'file://'. } elseif ( 1 === preg_match( '~^https?://~i', $this->file ) ) { /* * For URLs, it will be the final path segment. * * Example: * * https://wordpress.org/i/happy.png?size=40px * ╰───────╯ * this is the given filename * * If the stream returns a `Content-Disposition` header it would * provide an alternative name, but this is used as a reasonable * proxy to avoid adding the additional complexity of reading and * parsing the returned HTTP headers. */ $url_path = wp_parse_url( $this->file, PHP_URL_PATH ); // This URL can not be parsed, so it is not a valid image resource. if ( false === $url_path ) { return new WP_Error( 'error_loading_image', __( 'File is not an image.' ), $this->file ); } /** * The URL has an empty path, so continue with an empty string. * * This is the case with a URL such as `https://example.com?file_id=123` */ if ( null === $url_path ) { $url_path = ''; } $last_path_at = strrpos( $url_path, '/' ); $given_filename = is_int( $last_path_at ) ? substr( $url_path, $last_path_at + 1 ) : $url_path; $given_filename = rawurldecode( $given_filename ); } /* * Strip off any potential `Imagick` format specifiers. * * If a real file exists with the identified format specifier, then * `Imagick` may not treat it as a format, but WordPress will reject * it anyway to avoid adding more complexity into this detection. * * `Imagick` reads only the first `FORMAT:` specifier on a name, but * stripping a segment would promote a second specifier to the front * of the name handed to `Imagick`, which would then honor it. * * Loop to capture all format specifiers for comparison. * * Exclude Windows drive-letter prefixes from here. */ $imagick_formats = array(); while ( false !== ( $format_ends_at = strpos( $given_filename, ':' ) ) && 1 !== preg_match( '~^[a-z]:~i', $given_filename ) ) { $imagick_formats[] = strtoupper( substr( $given_filename, 0, $format_ends_at ) ); $given_filename = substr( $given_filename, $format_ends_at + 1 ); } $file_extension = strtolower( pathinfo( $given_filename, PATHINFO_EXTENSION ) ); /*Introduced in 3.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/class-wp-image-editor-imagick.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.