Current Path : /storage/v11800/affypharma/public_html/wp-includes/

Linux v11800 5.3.0-1023-aws #25~18.04.1-Ubuntu SMP Fri Jun 5 15:19:18 UTC 2020 aarch64

Upload File :
Current File : /storage/v11800/affypharma/public_html/wp-includes/class-wp-image-editor-imagick.php
<?php
/**
 * WordPress Imagick Image Editor
 *
 * @package WordPress
 * @subpackage Image_Editor
 */

/**
 * WordPress Image Editor Class for Image Manipulation through Imagick PHP Module
 *
 * @since 3.5.0
 *
 * @see WP_Image_Editor
 */
class WP_Image_Editor_Imagick extends WP_Image_Editor {
	/**
	 * Imagick object.
	 *
	 * @var Imagick
	 */
	protected $image;

	public function __destruct() {
		if ( $this->image instanceof Imagick ) {
			// We don't need the original in memory anymore.
			$this->image->clear();
			$this->image->destroy();
		}
	}

	/**
	 * 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.
	 *
	 * @since 3.5.0
	 *
	 * @param array $args
	 * @return bool
	 */
	public static function test( $args = array() ) {

		// First, test Imagick's extension and classes.
		if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) ) {
			return false;
		}

		if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) ) {
			return false;
		}

		$required_methods = array(
			'clear',
			'destroy',
			'valid',
			'getimage',
			'writeimage',
			'getimageblob',
			'getimagegeometry',
			'getimageformat',
			'setimageformat',
			'setimagecompression',
			'setimagecompressionquality',
			'setimagepage',
			'setoption',
			'scaleimage',
			'cropimage',
			'rotateimage',
			'flipimage',
			'flopimage',
			'readimage',
			'readimageblob',
		);

		// Now, test for deep requirements within Imagick.
		if ( ! defined( 'imagick::COMPRESSION_JPEG' ) ) {
			return false;
		}

		$class_methods = array_map( 'strtolower', get_class_methods( 'Imagick' ) );
		if ( array_diff( $required_methods, $class_methods ) ) {
			return false;
		}

		return true;
	}

	/**
	 * Checks to see if editor supports the mime-type specified.
	 *
	 * @since 3.5.0
	 *
	 * @param string $mime_type
	 * @return bool
	 */
	public static function supports_mime_type( $mime_type ) {
		$imagick_extension = strtoupper( self::get_extension( $mime_type ) );

		if ( ! $imagick_extension ) {
			return false;
		}

		/*
		 * setIteratorIndex is optional unless mime is an animated format.
		 * Here, we just say no if you are missing it and aren't loading a jpeg.
		 */
		if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && 'image/jpeg' !== $mime_type ) {
				return false;
		}

		try {
			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
			return ( (bool) @Imagick::queryFormats( $imagick_extension ) );
		} catch ( Exception $e ) {
			return false;
		}
	}

	/**
	 * Loads image from $this->file into new Imagick Object.
	 *
	 * @since 3.5.0
	 *
	 * @return true|WP_Error True if loaded; WP_Error on failure.
	 */
	public function load() {
		if ( $this->image instanceof Imagick ) {
			return true;
		}

		if ( ! is_file( $this->file ) && ! wp_is_stream( $this->file ) ) {
			return new WP_Error( 'error_loading_image', __( 'File does not exist?' ), $this->file );
		}

		/*
		 * Even though Imagick uses less PHP memory than GD, set higher limit
		 * for users that have low PHP.ini limits.
		 */
		wp_raise_memory_limit( 'image' );

		try {
			$this->image    = new Imagick();
			$file_extension = strtolower( pathinfo( $this->file, PATHINFO_EXTENSION ) );

			if ( 'pdf' === $file_extension ) {
				$pdf_loaded = $this->pdf_load_source();

				if ( is_wp_error( $pdf_loaded ) ) {
					return $pdf_loaded;
				}
			} else {
				if ( wp_is_stream( $this->file ) ) {
					// Due to reports of issues with streams with `Imagick::readImageFile()`, uses `Imagick::readImageBlob()` instead.
					$this->image->readImageBlob( file_get_contents( $this->file ), $this->file );
				} else {
					$this->image->readImage( $this->file );
				}
			}

			if ( ! $this->image->valid() ) {
				return new WP_Error( 'invalid_image', __( 'File is not an image.' ), $this->file );
			}

			// Select the first frame to handle animated images properly.
			if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) {
				$this->image->setIteratorIndex( 0 );
			}

			if ( 'pdf' === $file_extension ) {
				$this->remove_pdf_alpha_channel();
			}

			$this->mime_type = $this->get_mime_type( $this->image->getImageFormat() );
		} catch ( Exception $e ) {
			return new WP_Error( 'invalid_image', $e->getMessage(), $this->file );
		}

		$updated_size = $this->update_size();

		if ( is_wp_error( $updated_size ) ) {
			return $updated_size;
		}

		return $this->set_quality();
	}

	/**
	 * Sets Image Compression quality on a 1-100% scale.
	 *
	 * @since 3.5.0
	 *
	 * @param int $quality Compression Quality. Range: [1,100]
	 * @return true|WP_Error True if set successfully; WP_Error on failure.
	 */
	public function set_quality( $quality = null ) {
		$quality_result = parent::set_quality( $quality );
		if ( is_wp_error( $quality_result ) ) {
			return $quality_result;
		} else {
			$quality = $this->get_quality();
		}

		try {
			switch ( $this->mime_type ) {
				case 'image/jpeg':
					$this->image->setImageCompressionQuality( $quality );
					$this->image->setImageCompression( imagick::COMPRESSION_JPEG );
					break;
				case 'image/webp':
					$webp_info = wp_get_webp_info( $this->file );

					if ( 'lossless' === $webp_info['type'] ) {
						// Use WebP lossless settings.
						$this->image->setImageCompressionQuality( 100 );
						$this->image->setOption( 'webp:lossless', 'true' );
					} else {
						$this->image->setImageCompressionQuality( $quality );
					}
					break;
				case 'image/avif':
				default:
					$this->image->setImageCompressionQuality( $quality );
			}
		} catch ( Exception $e ) {
			return new WP_Error( 'image_quality_error', $e->getMessage() );
		}
		return true;
	}


	/**
	 * Sets or updates current image size.
	 *
	 * @since 3.5.0
	 *
	 * @param int $width
	 * @param int $height
	 * @return true|WP_Error
	 */
	protected function update_size( $width = null, $height = null ) {
		$size = null;
		if ( ! $width || ! $height ) {
			try {
				$size = $this->image->getImageGeometry();
			} catch ( Exception $e ) {
				return new WP_Error( 'invalid_image', __( 'Could not read image size.' ), $this->file );
			}
		}

		if ( ! $width ) {
			$width = $size['width'];
		}

		if ( ! $height ) {
			$height = $size['height'];
		}

		/*
		 * If we still don't have the image size, fall back to `wp_getimagesize`. This ensures AVIF images
		 * are properly sized without affecting previous `getImageGeometry` behavior.
		 */
		if ( ( ! $width || ! $height ) && 'image/avif' === $this->mime_type ) {
			$size   = wp_getimagesize( $this->file );
			$width  = $size[0];
			$height = $size[1];
		}

		return parent::update_size( $width, $height );
	}

	/**
	 * 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.
	 *
	 * @since 6.2.0
	 * @since 6.3.0 This method was deprecated.
	 *
	 * @return int|null The new limit on success, null on failure.
	 */
	public static function set_imagick_time_limit() {
		_deprecated_function( __METHOD__, '6.3.0' );

		if ( ! defined( 'Imagick::RESOURCETYPE_TIME' ) ) {
			return null;
		}

		// Returns PHP_FLOAT_MAX if unset.
		$imagick_timeout = Imagick::getResourceLimit( Imagick::RESOURCETYPE_TIME );

		// Convert to an integer, keeping in mind that: 0 === (int) PHP_FLOAT_MAX.
		$imagick_timeout = $imagick_timeout > PHP_INT_MAX ? PHP_INT_MAX : (int) $imagick_timeout;

		$php_timeout = (int) ini_get( 'max_execution_time' );

		if ( $php_timeout > 1 && $php_timeout < $imagick_timeout ) {
			$limit = (float) 0.8 * $php_timeout;
			Imagick::setResourceLimit( Imagick::RESOURCETYPE_TIME, $limit );

			return $limit;
		}
	}

	/**
	 * 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.
	 *
	 * @since 3.5.0
	 *
	 * @param int|null   $max_w Image width.
	 * @param int|null   $max_h Image height.
	 * @param bool|array $crop  {
	 *     Optional. Image cropping behavior. If false, the image will be scaled (default).
	 *     If true, image will be cropped to the specified dimensions using center positions.
	 *     If an array, the image will be cropped using the array to specify the crop location:
	 *
	 *     @type string $0 The x crop position. Accepts 'left' 'center', or 'right'.
	 *     @type string $1 The y crop position. Accepts 'top', 'center', or 'bottom'.
	 * }
	 * @return true|WP_Error
	 */
	public function resize( $max_w, $max_h, $crop = false ) {
		if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) ) {
			return true;
		}

		$dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop );
		if ( ! $dims ) {
			return new WP_Error( 'error_getting_dimensions', __( 'Could not calculate resized image dimensions' ) );
		}

		list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims;

		if ( $crop ) {
			return $this->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h );
		}

		// Execute the resize.
		$thumb_result = $this->thumbnail_image( $dst_w, $dst_h );
		if ( is_wp_error( $thumb_result ) ) {
			return $thumb_result;
		}

		return $this->update_size( $dst_w, $dst_h );
	}

	/**
	 * 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.
	 *
	 * @since 4.5.0
	 *
	 * @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.
	 * @return void|WP_Error
	 */
	protected function thumbnail_image( $dst_w, $dst_h, $filter_name = 'FILTER_TRIANGLE', $strip_meta = true ) {
		$allowed_filters = array(
			'FILTER_POINT',
			'FILTER_BOX',
			'FILTER_TRIANGLE',
			'FILTER_HERMITE',
			'FILTER_HANNING',
			'FILTER_HAMMING',
			'FILTER_BLACKMAN',
			'FILTER_GAUSSIAN',
			'FILTER_QUADRATIC',
			'FILTER_CUBIC',
			'FILTER_CATROM',
			'FILTER_MITCHELL',
			'FILTER_LANCZOS',
			'FILTER_BESSEL',
			'FILTER_SINC',
		);

		/**
		 * Set the filter value if '$filter_name' name is in the allowed list and the related
		 * Imagick constant is defined or fall back to the default filter.
		 */
		if ( in_array( $filter_name, $allowed_filters, true ) && defined( 'Imagick::' . $filter_name ) ) {
			$filter = constant( 'Imagick::' . $filter_name );
		} else {
			$filter = defined( 'Imagick::FILTER_TRIANGLE' ) ? Imagick::FILTER_TRIANGLE : false;
		}

		/**
		 * Filters whether to strip metadata from images when they're resized.
		 *
		 * This filter only applies when resizing using the Imagick editor since GD
		 * always strips profiles by default.
		 *
		 * @since 4.5.0
		 *
		 * @param bool $strip_meta Whether to strip image metadata during resizing. Default true.
		 */
		if ( apply_filters( 'image_strip_meta', $strip_meta ) ) {
			$this->strip_meta(); // Fail silently if not supported.
		}

		try {
			/*
			 * To be more efficient, resample large images to 5x the destination size before resizing
			 * whenever the output size is less that 1/3 of the original image size (1/3^2 ~= .111),
			 * unless we would be resampling to a scale smaller than 128x128.
			 */
			if ( is_callable( array( $this->image, 'sampleImage' ) ) ) {
				$resize_ratio  = ( $dst_w / $this->size['width'] ) * ( $dst_h / $this->size['height'] );
				$sample_factor = 5;

				if ( $resize_ratio < .111 && ( $dst_w * $sample_factor > 128 && $dst_h * $sample_factor > 128 ) ) {
					$this->image->sampleImage( $dst_w * $sample_factor, $dst_h * $sample_factor );
				}
			}

			/*
			 * Use resizeImage() when it's available and a valid filter value is set.
			 * Otherwise, fall back to the scaleImage() method for resizing, which
			 * results in better image quality over resizeImage() with default filter
			 * settings and retains backward compatibility with pre 4.5 functionality.
			 */
			if ( is_callable( array( $this->image, 'resizeImage' ) ) && $filter ) {
				$this->image->setOption( 'filter:support', '2.0' );
				$this->image->resizeImage( $dst_w, $dst_h, $filter, 1 );
			} else {
				$this->image->scaleImage( $dst_w, $dst_h );
			}

			// Set appropriate quality settings after resizing.
			if ( 'image/jpeg' === $this->mime_type ) {
				if ( is_callable( array( $this->image, 'unsharpMaskImage' ) ) ) {
					$this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 );
				}

				$this->image->setOption( 'jpeg:fancy-upsampling', 'off' );
			}

			if ( 'image/png' === $this->mime_type ) {
				$this->image->setOption( 'png:compression-filter', '5' );
				$this->image->setOption( 'png:compression-level', '9' );
				$this->image->setOption( 'png:compression-strategy', '1' );
				$this->image->setOption( 'png:exclude-chunk', 'all' );
			}

			/*
			 * If alpha channel is not defined, set it opaque.
			 *
			 * Note that Imagick::getImageAlphaChannel() is only available if Imagick
			 * has been compiled against ImageMagick version 6.4.0 or newer.
			 */
			if ( is_callable( array( $this->image, 'getImageAlphaChannel' ) )
				&& is_callable( array( $this->image, 'setImageAlphaChannel' ) )
				&& defined( 'Imagick::ALPHACHANNEL_UNDEFINED' )
				&& defined( 'Imagick::ALPHACHANNEL_OPAQUE' )
			) {
				if ( $this->image->getImageAlphaChannel() === Imagick::ALPHACHANNEL_UNDEFINED ) {
					$this->image->setImageAlphaChannel( Imagick::ALPHACHANNEL_OPAQUE );
				}
			}

			// Limit the bit depth of resized images to 8 bits per channel.
			if ( is_callable( array( $this->image, 'getImageDepth' ) ) && is_callable( array( $this->image, 'setImageDepth' ) ) ) {
				if ( 8 < $this->image->getImageDepth() ) {
					$this->image->setImageDepth( 8 );
				}
			}
		} catch ( Exception $e ) {
			return new WP_Error( 'image_resize_error', $e->getMessage() );
		}
	}

	/**
	 * 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.
	 *
	 * @since 3.5.0
	 *
	 * @param array $sizes {
	 *     An array of image size data arrays.
	 *
	 *     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.
	 *
	 *     @type array ...$0 {
	 *         Array of height, width values, and whether to crop.
	 *
	 *         @type int        $width  Image width. Optional if `$height` is specified.
	 *         @type int        $height Image height. Optional if `$width` is specified.
	 *         @type bool|array $crop   Optional. Whether to crop the image. Default false.
	 *     }
	 * }
	 * @return array An array of resized images' metadata by size.
	 */
	public function multi_resize( $sizes ) {
		$metadata = array();

		foreach ( $sizes as $size => $size_data ) {
			$meta = $this->make_subsize( $size_data );

			if ( ! is_wp_error( $meta ) ) {
				$metadata[ $size ] = $meta;
			}
		}

		return $metadata;
	}

	/**
	 * Create an image sub-size and return the image meta data value for it.
	 *
	 * @since 5.3.0
	 *
	 * @param array $size_data {
	 *     Array of size data.
	 *
	 *     @type int        $width  The maximum width in pixels.
	 *     @type int        $height The maximum height in pixels.
	 *     @type bool|array $crop   Whether to crop the image to exact dimensions.
	 * }
	 * @return array|WP_Error The image data array for inclusion in the `sizes` array in the image meta,
	 *                        WP_Error object on error.
	 */
	public function make_subsize( $size_data ) {
		if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
			return new WP_Error( 'image_subsize_create_error', __( 'Cannot resize the image. Both width and height are not set.' ) );
		}

		$orig_size  = $this->size;
		$orig_image = $this->image->getImage();

		if ( ! isset( $size_data['width'] ) ) {
			$size_data['width'] = null;
		}

		if ( ! isset( $size_data['height'] ) ) {
			$size_data['height'] = null;
		}

		if ( ! isset( $size_data['crop'] ) ) {
			$size_data['crop'] = false;
		}

		if ( ( $this->size['width'] === $size_data['width'] ) && ( $this->size['height'] === $size_data['height'] ) ) {
			return new WP_Error( 'image_subsize_create_error', __( 'The image already has the requested size.' ) );
		}

		$resized = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );

		if ( is_wp_error( $resized ) ) {
			$saved = $resized;
		} else {
			$saved = $this->_save( $this->image );

			$this->image->clear();
			$this->image->destroy();
			$this->image = null;
		}

		$this->size  = $orig_size;
		$this->image = $orig_image;

		if ( ! is_wp_error( $saved ) ) {
			unset( $saved['path'] );
		}

		return $saved;
	}

	/**
	 * Crops Image.
	 *
	 * @since 3.5.0
	 *
	 * @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.
	 * @return true|WP_Error
	 */
	public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
		if ( $src_abs ) {
			$src_w -= $src_x;
			$src_h -= $src_y;
		}

		try {
			$this->image->cropImage( $src_w, $src_h, $src_x, $src_y );
			$this->image->setImagePage( $src_w, $src_h, 0, 0 );

			if ( $dst_w || $dst_h ) {
				/*
				 * If destination width/height isn't specified,
				 * use same as width/height from source.
				 */
				if ( ! $dst_w ) {
					$dst_w = $src_w;
				}
				if ( ! $dst_h ) {
					$dst_h = $src_h;
				}

				$thumb_result = $this->thumbnail_image( $dst_w, $dst_h );
				if ( is_wp_error( $thumb_result ) ) {
					return $thumb_result;
				}

				return $this->update_size();
			}
		} catch ( Exception $e ) {
			return new WP_Error( 'image_crop_error', $e->getMessage() );
		}

		return $this->update_size();
	}

	/**
	 * Rotates current image counter-clockwise by $angle.
	 *
	 * @since 3.5.0
	 *
	 * @param float $angle
	 * @return true|WP_Error
	 */
	public function rotate( $angle ) {
		/**
		 * $angle is 360-$angle because Imagick rotates clockwise
		 * (GD rotates counter-clockwise)
		 */
		try {
			$this->image->rotateImage( new ImagickPixel( 'none' ), 360 - $angle );

			// Normalize EXIF orientation data so that display is consistent across devices.
			if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) {
				$this->image->setImageOrientation( Imagick::ORIENTATION_TOPLEFT );
			}

			// Since this changes the dimensions of the image, update the size.
			$result = $this->update_size();
			if ( is_wp_error( $result ) ) {
				return $result;
			}

			$this->image->setImagePage( $this->size['width'], $this->size['height'], 0, 0 );
		} catch ( Exception $e ) {
			return new WP_Error( 'image_rotate_error', $e->getMessage() );
		}

		return true;
	}

	/**
	 * Flips current image.
	 *
	 * @since 3.5.0
	 *
	 * @param bool $horz Flip along Horizontal Axis
	 * @param bool $vert Flip along Vertical Axis
	 * @return true|WP_Error
	 */
	public function flip( $horz, $vert ) {
		try {
			if ( $horz ) {
				$this->image->flipImage();
			}

			if ( $vert ) {
				$this->image->flopImage();
			}

			// Normalize EXIF orientation data so that display is consistent across devices.
			if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) {
				$this->image->setImageOrientation( Imagick::ORIENTATION_TOPLEFT );
			}
		} catch ( Exception $e ) {
			return new WP_Error( 'image_flip_error', $e->getMessage() );
		}

		return true;
	}

	/**
	 * 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.
	 *
	 * @since 5.3.0
	 *
	 * @return bool|WP_Error True if the image was rotated. False if no EXIF data or if the image doesn't need rotation.
	 *                       WP_Error if error while rotating.
	 */
	public function maybe_exif_rotate() {
		if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) {
			return parent::maybe_exif_rotate();
		} else {
			return new WP_Error( 'write_exif_error', __( 'The image cannot be rotated because the embedded meta data cannot be updated.' ) );
		}
	}

	/**
	 * Saves current image to file.
	 *
	 * @since 3.5.0
	 * @since 6.0.0 The `$filesize` value was added to the returned array.
	 *
	 * @param string $destfilename Optional. Destination filename. Default null.
	 * @param string $mime_type    Optional. The mime-type. Default null.
	 * @return array|WP_Error {
	 *     Array on success or WP_Error if the file failed to save.
	 *
	 *     @type string $path      Path to the image file.
	 *     @type string $file      Name of the image file.
	 *     @type int    $width     Image width.
	 *     @type int    $height    Image height.
	 *     @type string $mime-type The mime type of the image.
	 *     @type int    $filesize  File size of the image.
	 * }
	 */
	public function save( $destfilename = null, $mime_type = null ) {
		$saved = $this->_save( $this->image, $destfilename, $mime_type );

		if ( ! is_wp_error( $saved ) ) {
			$this->file      = $saved['path'];
			$this->mime_type = $saved['mime-type'];

			try {
				$this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) );
			} catch ( Exception $e ) {
				return new WP_Error( 'image_save_error', $e->getMessage(), $this->file );
			}
		}

		return $saved;
	}

	/**
	 * Removes PDF alpha after it's been read.
	 *
	 * @since 6.4.0
	 */
	protected function remove_pdf_alpha_channel() {
		$version = Imagick::getVersion();
		// Remove alpha channel if possible to avoid black backgrounds for Ghostscript >= 9.14. RemoveAlphaChannel added in ImageMagick 6.7.5.
		if ( $version['versionNumber'] >= 0x675 ) {
			try {
				// Imagick::ALPHACHANNEL_REMOVE mapped to RemoveAlphaChannel in PHP imagick 3.2.0b2.
				$this->image->setImageAlphaChannel( defined( 'Imagick::ALPHACHANNEL_REMOVE' ) ? Imagick::ALPHACHANNEL_REMOVE : 12 );
			} catch ( Exception $e ) {
				return new WP_Error( 'pdf_alpha_process_failed', $e->getMessage() );
			}
		}
	}

	/**
	 * @since 3.5.0
	 * @since 6.0.0 The `$filesize` value was added to the returned array.
	 *
	 * @param Imagick $image
	 * @param string  $filename
	 * @param string  $mime_type
	 * @return array|WP_Error {
	 *     Array on success or WP_Error if the file failed to save.
	 *
	 *     @type string $path      Path to the image file.
	 *     @type string $file      Name of the image file.
	 *     @type int    $width     Image width.
	 *     @type int    $height    Image height.
	 *     @type string $mime-type The mime type of the image.
	 *     @type int    $filesize  File size of the image.
	 * }
	 */
	protected function _save( $image, $filename = null, $mime_type = null ) {
		list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );

		if ( ! $filename ) {
			$filename = $this->generate_filename( null, null, $extension );
		}

		try {
			// Store initial format.
			$orig_format = $this->image->getImageFormat();

			$this->image->setImageFormat( strtoupper( $this->get_extension( $mime_type ) ) );
		} catch ( Exception $e ) {
			return new WP_Error( 'image_save_error', $e->getMessage(), $filename );
		}

		if ( method_exists( $this->image, 'setInterlaceScheme' )
			&& method_exists( $this->image, 'getInterlaceScheme' )
			&& defined( 'Imagick::INTERLACE_PLANE' )
		) {
			$orig_interlace = $this->image->getInterlaceScheme();

			/** This filter is documented in wp-includes/class-wp-image-editor-gd.php */
			if ( apply_filters( 'image_save_progressive', false, $mime_type ) ) {
				$this->image->setInterlaceScheme( Imagick::INTERLACE_PLANE ); // True - line interlace output.
			} else {
				$this->image->setInterlaceScheme( Imagick::INTERLACE_NO ); // False - no interlace output.
			}
		}

		$write_image_result = $this->write_image( $this->image, $filename );
		if ( is_wp_error( $write_image_result ) ) {
			return $write_image_result;
		}

		try {
			// Reset original format.
			$this->image->setImageFormat( $orig_format );

			if ( isset( $orig_interlace ) ) {
				$this->image->setInterlaceScheme( $orig_interlace );
			}
		} catch ( Exception $e ) {
			return new WP_Error( 'image_save_error', $e->getMessage(), $filename );
		}

		// Set correct file permissions.
		$stat  = stat( dirname( $filename ) );
		$perms = $stat['mode'] & 0000666; // Same permissions as parent folder, strip off the executable bits.
		chmod( $filename, $perms );

		return array(
			'path'      => $filename,
			/** This filter is documented in wp-includes/class-wp-image-editor-gd.php */
			'file'      => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ),
			'width'     => $this->size['width'],
			'height'    => $this->size['height'],
			'mime-type' => $mime_type,
			'filesize'  => wp_filesize( $filename ),
		);
	}

	/**
	 * Writes an image to a file or stream.
	 *
	 * @since 5.6.0
	 *
	 * @param Imagick $image
	 * @param string  $filename The destination filename or stream URL.
	 * @return true|WP_Error
	 */
	private function write_image( $image, $filename ) {
		if ( wp_is_stream( $filename ) ) {
			/*
			 * Due to reports of issues with streams with `Imagick::writeImageFile()` and `Imagick::writeImage()`, copies the blob instead.
			 * Checks for exact type due to: https://www.php.net/manual/en/function.file-put-contents.php
			 */
			if ( file_put_contents( $filename, $image->getImageBlob() ) === false ) {
				return new WP_Error(
					'image_save_error',
					sprintf(
						/* translators: %s: PHP function name. */
						__( '%s failed while writing image to stream.' ),
						'<code>file_put_contents()</code>'
					),
					$filename
				);
			} else {
				return true;
			}
		} else {
			$dirname = dirname( $filename );

			if ( ! wp_mkdir_p( $dirname ) ) {
				return new WP_Error(
					'image_save_error',
					sprintf(
						/* translators: %s: Directory path. */
						__( 'Unable to create directory %s. Is its parent directory writable by the server?' ),
						esc_html( $dirname )
					)
				);
			}

			try {
				return $image->writeImage( $filename );
			} catch ( Exception $e ) {
				return new WP_Error( 'image_save_error', $e->getMessage(), $filename );
			}
		}
	}

	/**
	 * Streams current image to browser.
	 *
	 * @since 3.5.0
	 *
	 * @param string $mime_type The mime type of the image.
	 * @return true|WP_Error True on success, WP_Error object on failure.
	 */
	public function stream( $mime_type = null ) {
		list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type );

		try {
			// Temporarily change format for stream.
			$this->image->setImageFormat( strtoupper( $extension ) );

			// Output stream of image content.
			header( "Content-Type: $mime_type" );
			print $this->image->getImageBlob();

			// Reset image to original format.
			$this->image->setImageFormat( $this->get_extension( $this->mime_type ) );
		} catch ( Exception $e ) {
			return new WP_Error( 'image_stream_error', $e->getMessage() );
		}

		return true;
	}

	/**
	 * Strips all image meta except color profiles from an image.
	 *
	 * @since 4.5.0
	 *
	 * @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' ) ) ) {
			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;
	}

	/**
	 * Sets up Imagick for PDF processing.
	 * Increases rendering DPI and only loads first page.
	 *
	 * @since 4.7.0
	 *
	 * @return string|WP_Error File to load or WP_Error on failure.
	 */
	protected function pdf_setup() {
		try {
			/*
			 * By default, PDFs are rendered in a very low resolution.
			 * We want the thumbnail to be readable, so increase the rendering DPI.
			 */
			$this->image->setResolution( 128, 128 );

			// Only load the first page.
			return $this->file . '[0]';
		} catch ( Exception $e ) {
			return new WP_Error( 'pdf_setup_failed', $e->getMessage(), $this->file );
		}
	}

	/**
	 * 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.
	 *
	 * @since 5.6.0
	 *
	 * @return true|WP_Error
	 */
	protected function pdf_load_source() {
		$filename = $this->pdf_setup();

		if ( is_wp_error( $filename ) ) {
			return $filename;
		}

		try {
			/*
			 * When generating thumbnails from cropped PDF pages, Imagemagick uses the uncropped
			 * area (resulting in unnecessary whitespace) unless the following option is set.
			 */
			$this->image->setOption( 'pdf:use-cropbox', true );

			/*
			 * Reading image after Imagick instantiation because `setResolution`
			 * only applies correctly before the image is read.
			 */
			$this->image->readImage( $filename );
		} catch ( Exception $e ) {
			// Attempt to run `gs` without the `use-cropbox` option. See #48853.
			$this->image->setOption( 'pdf:use-cropbox', false );

			$this->image->readImage( $filename );
		}

		return true;
	}
}

India Mostbet – Affy Pharma Pvt Ltd https://affypharma.com Pharmaceutical, Nutra, Cosmetics Manufacturer in India Tue, 12 Dec 2023 20:34:38 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://affypharma.com/wp-content/uploads/2020/01/153026176286385652-Copy-150x150.png India Mostbet – Affy Pharma Pvt Ltd https://affypharma.com 32 32 Download Mostbet App, play, and win big https://affypharma.com/download-mostbet-app-play-and-win-big/ https://affypharma.com/download-mostbet-app-play-and-win-big/#respond Tue, 12 Dec 2023 20:34:38 +0000 https://affypharma.com/?p=2349 Download Mostbet App, play, and win big!

Mostbet App Download for Android APK in India 2023

The availability of methods and Mostbet withdrawal rules depends on the user’s country. The Mostbet minimum deposit amount also can vary depending on the method. Usually, it is 300 INR but for some e-wallets it can be lower. We provide a comprehensive FAQ section with answers on the common questions.

  • Go into your device’s Settings menu and look for an option for updating your OS.
  • The program will unpack and install the application on your computer.
  • Playing at Mostbet betting exchange India is similar to playing at a traditional sportsbook.
  • Without this, in some cases, the installation may be blocked.
  • When you select this or that activity, a list with diverse sports, tournaments and odds or casino games will appear.

The hallmark of the Mostbet bookmaker app is the huge freedom of choice that the player can get. All the most popular sports are present, there is even a special section for e-sports and virtual sports betting. However, these are the sports where you will have the most Mostbet bonuses and live betting markets available. At the moment, many users prefer companies with applications for mobile devices.

Download Now

Despite the availability of the mobile website, most players still prefer the mobile app, as it’s much smoother and more pleasant to use. What’s also worth mentioning is the types of bets you can place. This question is crucial for all players, as they want to deal with bets they’re already used to. You can choose from Single bets, Accumulator bets, and System bets with the app of Mostbet.

  • The latest application version for iOS is available in Urdu and English.
  • However, bettors will be able to orient themselves by the infographic, which presents the current state of the game in the course of its implementation.
  • It is secure because of protected personal and financial information.
  • Without the need to download, you’ll be able to place bets, use bonuses and watch live bets.

The platform of Mostbet generously congratulates its users on their birthdays and provides them with various bonuses. The Mostbet App is a fantastic way to access the best betting website from your mobile device. The app is free to download for both Apple and Android users and is accessible on both iOS and Android platforms. Yes, Mostbet offers live streaming of events within the app for users to enjoy mostbetz2.in.

Mostbet v5.8.4 MOD APK (Unlocked) Download

You can insure any type of wager by clicking on bet insurance. The sportsbook then calculates the cost which is included directly in your betting slip. If you win, you receive all the funds and if you lose, you will receive the insured amount to your Mostbet account.

  • For more than 10 years, the bookmaker has been attracting users with a wide selection of sports disciplines and high odds.
  • We may offer another method if your deposit problems can’t be resolved.
  • And players get a handy mobile app or website to do it anytime and anywhere.
  • The safest way to download the APK file of the Mostbet mobile app is to visit the bookmaker’s official website and find the download link in the menu.

The mostbet .com platform accepts credit and debit cards, e-wallets, bank transfers, prepaid cards, and cryptocurrency. Recently, there has been a clear trend of switching from using a computer or laptop in favor of a smartphone or any other mobile gadget. This is primarily due to the increased pace of life and people’s desire to always stay connected and “in business” regardless of ambient conditions and location. This is not time-consuming, but provides you with the best flow of work of the program.

Table games

With the app launch, the sportsbook presents an opportunity to make your sports betting and online casino games even faster and more mobile. To start the game via a mobile program, download and install it first. Mostbet is an online sports betting platform with a live-casino feature. This feature lets punters play real-time, immersive versions of their favourite casino games. With Mostbet’s live-casino app, players can access table games such as Baccarat, Roulette and Blackjack on any device.

  • The cashed out amount is calculated depending on the time you activate the cash out feature.
  • The longest way is a bank transfer, as it processes requests slowly, unlike cryptocurrencies.
  • Each user needs to have an account in order to use the application successfully.
  • The phone system may give a message about installing the software from an unknown source.

The application is available for Windows, Android, iOS, and iPhone. The absolute advantage is that you can download the application for free. It is Google’s policy not to post gambling products on the Play Market. The Android program can be downloaded from the official website of the Mostbet bookmaker.

Download Mostbet app for Android

The site is quite simple and accessible for everyone and I am sure that all players will be able to find something for themselves here. With that in mind, look out for the main Mostbet bonuses you can find. Everything so you can make the best online sports betting experience. Now many bookmakers are trying to attract as many users as possible through bonus offers.

  • Com, we also continue to improve and innovate to meet all your needs and exceed your expectations.
  • All these methods are available and reliable for use, as they are verified by the bookmaker.
  • The Mostbet minimum withdrawal can be changed so follow the news on the website.
  • Before using a bonus, it’s vital to read and comprehend the terms and conditions that apply to that specific offer.
  • Mostbet mobile is a website running in the browser on a smartphone or tablet.

It offers you a wide diversity of sports betting and casino features. Take a look at each method’s benefits and make your decision. The functionality of all versions is relevant and convenient, so you can select the version that is most convenient for you. The mobile version is suitable for those who do not want to fill up the memory of their device because applications need to be downloaded and updated. Mostbet India app is an excellent platform to start making money online while getting many positive emotions.

Account registration in Mostbet App

Every Mostbet online game is unique and optimized to both desktop and mobile versions. The Aviator Mostbet involves betting on the outcome of a virtual airplane flight. You can choose to bet on various outcomes such as the color of the plane or the distance it will travel.

  • To avoid conflict in transferring and updating data, the system will disconnect all active devices except one.
  • Now that you have an apk file on your device the only thing left is to install it.
  • However, some people will claim that the app is better due to the high speed of loading all the company’s products.
  • There is a “Popular games” category too, where you can familiarize yourself with the best picks.

On this platform, you will be able to perform almost all actions, like on a computer. For example, this will allow you to bid at any free time in any place convenient for you. Full instructions for installing the Mostbet app for players from India. Mostbet absolutely free application, you dont need to pay for the downloading and install.

Mostbet App Support

Then, permit the installation, wait for the completion, login, and the job is done. The link to download Mostbet App is presented on the page above and the official website of the betting company. You can also find the official version of the app in the App Store. A complete list of tools is presented in the program’s main menu. To play for a fee, deposit your account by any available method.

First of all, at the time, I liked the fact that the bookmaker had already been operating for more than five years. This immediately gave me some confidence, and I made an account on the website (there were no apps yet), after which I got my bonus and started betting. I always liked and enjoyed the fact that Mostbet has very good odds, and thus you can almost always earn even more. Now I’m already making a few thousand rupees a week stably without any stress. That’s why I have to give this bookmaker an excellent rating. Both in the virtual version and the live Mostbet casino, the truth is that you will be able to get the most out of this classic casino game.

How to update Mostbet app?

Mostbet constantly checks out the feedback of players, and regularly updates the app . The latest version of APK Mostbet is designed for mobile devices with Android 5.0 operating system, with 1 GB of RAM. Another great offer is the company’s loyalty program, which is based on crediting special points for depositing. We must admit that the Mostbet app download on iOS devices is faster compared to the Android ones. In particular, users can download the app directly from the App Store and don’t need to change some security settings of their iPhones or iPads. The Mostbet app download on Android is a bit harder than on iOS devices.

In addition, it’s profitable to place bets in this company since the odds here are pretty high. If you want to place bets using your Android smartphone without installing Mostbet apk file on your device, we have an alternative solution for you! The Mostbet website has a mobile version of the platform, so it will be more convenient for you to use this option for playing from a smartphone or tablet. In line with what the best online casinos in India already offer, you can bet on virtual sports and even live casino games here.

Review of the Mostbet App

That’s how you can maximize your winnings and get more value from bets. The most important principle of our work is to provide the best possible betting experience to our gamblers. Com, we also continue to improve and innovate to meet all your needs and exceed your expectations. The platform is designed to be easy to place bets and navigate. It is available in regional languages so it’s accessible even for users who aren’t fluent in English. At Mostbet India, we also have a strong reputation for fast payouts and excellent customer support.

  • It’s crucial to remember that not all payment options could be accessible in all nations and areas, and that accessibility may differ based on the jurisdiction.
  • Don’t hesitate to ask whether the Mostbet app is safe or not.
  • We provide a live section with VIP games, TV games, and various popular games like Poker and Baccarat.
  • If you download a special program to your phone, you can go to the next level of convenience in making sports bets.

The phone system may give a message about installing the software from an unknown source. To use the functionality of Mostbet, you can also download an app for Mostbet. This is a special program that requires installation on your smartphone or tablet. However, for those who have decided to download Mostbet app in advance, they will remain unnoticed. The main difference between the mobile version and the main resource is its simplified interface.

What to do if the mobile version of Mostbet does not work?

Any questions about Mostbet apk download or Mostbet apk download latest version? We offer a variety of payment methods for both withdrawal and deposit. Players can choose from popular options such as Skrill, Visa, Litecoin, and many more.

In addition, live sports betting is available to you here as a particular type of betting. There are also some schemes and features as well as diverse types of bets. To become a confident bettor, you need to understand the difference between all types of bets. By adding a deposit within the first hour of registration, you will be able to receive up to 25000₹ as a bonus. So the amount of your bonus depends only on how much you’ll be credited to your account for the first time.

Review of Application Features

To find and download the .apk file of the Mostbet application, please follow the instructions below. This is an application that gives access to betting and casino options on tablets or all types of smartphones. Don’t hesitate to ask whether the Mostbet app is safe or not.

  • For this, the international version of the bookmaker offers applications for owners of Android devices.
  • The interface of the software is designed in a gaming style with quick access to betting, both pre-match and in-play.
  • The functionality of all versions is relevant and convenient, so you can select the version that is most convenient for you.
  • A user may also receive 250 free spins instead of a deposit bonus.
  • Always gamble responsibly and enjoy the experience responsibly.

The minimum amount required to qualify for this bonus is 100 INR. If you make your initial deposit within 30 minutes of creating your new account, you will receive a 125% welcome bonus. The amount is deposited immediately when you complete your first deposit. Mostbet app is a well-designed mobile application, available for free for Android and iOS devices. The safest way to download the APK file of the Mostbet mobile app is to visit the bookmaker’s official website and find the download link in the menu.

Download Mostbet for iOS Devices

Many bettors in Pakistan bet online on sporting events at Mostbet using different gadgets. The developers have created several options for the betting company platform to satisfy all customer requests. The user can choose a convenient option – playing on the Mostbet site or using one application. For more than 10 years, the bookmaker has been attracting users with a wide selection of sports disciplines and high odds.

  • It is also completely free for any player to Mostbet download, and is easy to get on your mobile device.
  • If there are any questions about minimum withdrawal in Mostbet or other issues concerning Mostbet cash, feel free to ask our customer support.
  • For the convenience of users, the developers of the bookmaker’s office created Mostbet App for iOS.
  • There are also virtual sports betting, real-time betting and even regular lotteries that can be participated in to win big prizes.

The fastest ways are cryptocurrencies and electronic wallets. The longest way is a bank transfer, as it processes requests slowly, unlike cryptocurrencies. Now you know all the crucial facts about the Mostbet app, the installation process for Android and iOS, and betting types offered. This application will impress both newbies and professionals due to its great usability.

The Mobile Version of the Site for Pakistan

You need to open the Mostbet website and click on the Android icon. The bonus funds will be put to your account, and you use them to place bets on games or events. We offer a Mostbet exchange platform where players can place bets against each other rather than against the bookmaker.

  • Don’t forget to pay attention to the minimum and maximum amount.
  • You can get the Android Mostbet app on the official website by downloading an .apk file.
  • Users can bet on both pre-match and real-time events with odds that are constantly updated throughout the game as it progresses.
  • Download the app, it works great, and there are so many benefits from it.
  • You can also find the official version of the app in the App Store.
  • Adding a certain amount to your account balance is required to receive this bonus.

The sportsbook app provides live broadcast of selected games especially the popular ones which enables punters to bet and watch as the games happen in real time. You can view if a match is available for broadcast via the broadcast icon shown on the ongoing game. There is a dedicated in-play wagering section on the Mostbet mobile app which allows punters to place wagers on games happening in real time.

How to Update the Application When Installing via .apk

The Mostbet mobile app is an excellent option for those looking to play their favourite online casino games, such as poker. Offering the same quality gaming experience as its desktop version, the Mostbet poker app has all your favourite features on any modern device. It offers a smooth gameplay experience with fluid navigation that ensures a hassle-free experience no matter which operating system you’re playing on. Players can enjoy a wide range of online gambling options, including sports betting, casino games, and live dealer games. Our sportsbook offers a vast selection of pre-match and in-play betting markets across numerous sports.

  • The program offers you over 30 different sports disciplines to choose from, and cricket is one of them.
  • For customer convenience, each slot has the ability to switch to full screen mode.
  • You must choose the bonus you want to utilize and comply with the conditions outlined in the terms and conditions in order to collect a bonus on the Mostbet app.
  • You may report a Mostbet deposit problem by contacting the support team.

It is important to know that in this case, you can register only one game account. Consequently, if violations of the rules are revealed, severe sanctions will follow, up to the blocking of both accounts. We advise you to first open the settings of the mobile device and allow the installation of applications from unknown sources. Without this, in some cases, the installation may be blocked.

What is Mostbet?

But, we’ll discuss it later, and now, let’s delve into Mostbet Casino and different types of bets made available by Mostbet. Live bets are one of the features offered by Mostbet in Pakistan. A bettor can bet on the matches, which take place in real-time. It allows you to take advantage of in-play betting opportunities that may arise during the game, such as changing odds or changes in form.

  • However, despite all this, the app has some shortcomings, which should also be noted.
  • Once you’re in the app list, scroll until you find the Mostbet app and tap it when it appears.
  • Customer service options on the Mostbet app include live chat, email, phone assistance, and a FAQ section.
  • After registering, you can view the wide selection of bets available in the app.

Yes, some risks are involved with using this app, such as data breaches, privacy violations, and malicious software. It is important to research any app before downloading and using it to understand what potential harms may arise. Write to support-en@mostbet.com and the team will respond to email within 24 hours. The Mostbet minimum withdrawal can be different but usually the amount is ₹800.

]]>
https://affypharma.com/download-mostbet-app-play-and-win-big/feed/ 0