[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-image-editor-imagick.php (summary)

WordPress Imagick Image Editor

File Size: 1081 lines (33 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Image_Editor_Imagick:: (23 methods):
  __destruct()
  test()
  supports_mime_type()
  load()
  set_quality()
  update_size()
  set_imagick_time_limit()
  resize()
  thumbnail_image()
  multi_resize()
  make_subsize()
  crop()
  rotate()
  flip()
  maybe_exif_rotate()
  save()
  remove_pdf_alpha_channel()
  _save()
  write_image()
  stream()
  strip_meta()
  pdf_setup()
  pdf_load_source()


Class: WP_Image_Editor_Imagick  - X-Ref

WordPress Image Editor Class for Image Manipulation through Imagick PHP Module

__destruct()   X-Ref
Imagick object.


test( $args = array()   X-Ref
Checks to see if current environment supports Imagick.

We require Imagick 2.2.0 or greater, based on whether the queryFormats()
method can be called statically.

return: bool
param: array $args

supports_mime_type( $mime_type )   X-Ref
Checks to see if editor supports the mime-type specified.

return: bool
param: string $mime_type

load()   X-Ref
Loads image from $this->file into new Imagick Object.

return: true|WP_Error True if loaded; WP_Error on failure.

set_quality( $quality = null )   X-Ref
Sets Image Compression quality on a 1-100% scale.

return: true|WP_Error True if set successfully; WP_Error on failure.
param: int $quality Compression Quality. Range: [1,100]

update_size( $width = null, $height = null )   X-Ref
Sets or updates current image size.

return: true|WP_Error
param: int $width
param: int $height

set_imagick_time_limit()   X-Ref
Sets Imagick time limit.

Depending on configuration, Imagick processing may take time.

Multiple problems exist if PHP times out before ImageMagick completed:
1. Temporary files aren't cleaned by ImageMagick garbage collection.
2. No clear error is provided.
3. The cause of such timeout can be hard to pinpoint.

This function, which is expected to be run before heavy image routines, resolves
point 1 above by aligning Imagick's timeout with PHP's timeout, assuming it is set.

However seems it introduces more problems than it fixes,
see https://core.trac.wordpress.org/ticket/58202.

Note:
- Imagick resource exhaustion does not issue catchable exceptions (yet).
See https://github.com/Imagick/imagick/issues/333.
- The resource limit is not saved/restored. It applies to subsequent
image operations within the time of the HTTP request.

return: int|null The new limit on success, null on failure.

resize( $max_w, $max_h, $crop = false )   X-Ref
Resizes current image.

At minimum, either a height or width must be provided.
If one of the two is set to null, the resize will
maintain aspect ratio according to the provided dimension.

return: true|WP_Error
param: int|null   $max_w Image width.
param: int|null   $max_h Image height.
param: bool|array $crop  {

thumbnail_image( $dst_w, $dst_h, $filter_name = 'FILTER_TRIANGLE', $strip_meta = true )   X-Ref
Efficiently resize the current image

This is a WordPress specific implementation of Imagick::thumbnailImage(),
which resizes an image to given dimensions and removes any associated profiles.

return: void|WP_Error
param: int    $dst_w       The destination width.
param: int    $dst_h       The destination height.
param: string $filter_name Optional. The Imagick filter to use when resizing. Default 'FILTER_TRIANGLE'.
param: bool   $strip_meta  Optional. Strip all profiles, excluding color profiles, from the image. Default true.

multi_resize( $sizes )   X-Ref
Create multiple smaller images from a single source.

Attempts to create all sub-sizes and returns the meta data at the end. This
may result in the server running out of resources. When it fails there may be few
"orphaned" images left over as the meta data is never returned and saved.

As of 5.3.0 the preferred way to do this is with `make_subsize()`. It creates
the new images one at a time and allows for the meta data to be saved after
each new image is created.

return: array An array of resized images' metadata by size.
param: array $sizes {

make_subsize( $size_data )   X-Ref
Create an image sub-size and return the image meta data value for it.

return: array|WP_Error The image data array for inclusion in the `sizes` array in the image meta,
param: array $size_data {

crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false )   X-Ref
Crops Image.

return: true|WP_Error
param: int  $src_x   The start x position to crop from.
param: int  $src_y   The start y position to crop from.
param: int  $src_w   The width to crop.
param: int  $src_h   The height to crop.
param: int  $dst_w   Optional. The destination width.
param: int  $dst_h   Optional. The destination height.
param: bool $src_abs Optional. If the source crop points are absolute.

rotate( $angle )   X-Ref
Rotates current image counter-clockwise by $angle.

return: true|WP_Error
param: float $angle

flip( $horz, $vert )   X-Ref
Flips current image.

return: true|WP_Error
param: bool $horz Flip along Horizontal Axis
param: bool $vert Flip along Vertical Axis

maybe_exif_rotate()   X-Ref
Check if a JPEG image has EXIF Orientation tag and rotate it if needed.

As ImageMagick copies the EXIF data to the flipped/rotated image, proceed only
if EXIF Orientation can be reset afterwards.

return: bool|WP_Error True if the image was rotated. False if no EXIF data or if the image doesn't need rotation.

save( $destfilename = null, $mime_type = null )   X-Ref
Saves current image to file.

return: array|WP_Error {
param: string $destfilename Optional. Destination filename. Default null.
param: string $mime_type    Optional. The mime-type. Default null.

remove_pdf_alpha_channel()   X-Ref
Removes PDF alpha after it's been read.


_save( $image, $filename = null, $mime_type = null )   X-Ref

return: array|WP_Error {
param: Imagick $image
param: string  $filename
param: string  $mime_type

write_image( $image, $filename )   X-Ref
Writes an image to a file or stream.

return: true|WP_Error
param: Imagick $image
param: string  $filename The destination filename or stream URL.

stream( $mime_type = null )   X-Ref
Streams current image to browser.

return: true|WP_Error True on success, WP_Error object on failure.
param: string $mime_type The mime type of the image.

strip_meta()   X-Ref
Strips all image meta except color profiles from an image.

return: true|WP_Error True if stripping metadata was successful. WP_Error object on error.

pdf_setup()   X-Ref
Sets up Imagick for PDF processing.
Increases rendering DPI and only loads first page.

return: string|WP_Error File to load or WP_Error on failure.

pdf_load_source()   X-Ref
Load the image produced by Ghostscript.

Includes a workaround for a bug in Ghostscript 8.70 that prevents processing of some PDF files
when `use-cropbox` is set.

return: true|WP_Error



Generated : Sat Nov 23 08:20:01 2024 Cross-referenced by PHPXref