get_size example

return new WP_Error(
                                'rest_image_rotation_failed',
                                __( 'Unable to rotate this image.' ),
                                array( 'status' => 500 )
                            );
                        }
                    }

                    break;

                case 'crop':
                    $size = $image_editor->get_size();

                    $crop_x = round( ( $size['width'] * $args['left'] ) / 100.0 );
                    $crop_y = round( ( $size['height'] * $args['top'] ) / 100.0 );
                    $width  = round( ( $size['width'] * $args['width'] ) / 100.0 );
                    $height = round( ( $size['height'] * $args['height'] ) / 100.0 );

                    if ( $size['width'] !== $width && $size['height'] !== $height ) {
                        $result = $image_editor->crop( $crop_x$crop_y$width$height );

                        if ( is_wp_error( $result ) ) {
                            return new WP_Error(
                                
if ( $image instanceof WP_Image_Editor ) {
                        $image->flip( ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
                    } else {
                        $image = _flip_image_resource( $image( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
                    }
                }
                break;
            case 'crop':
                $sel = $operation->sel;

                if ( $image instanceof WP_Image_Editor ) {
                    $size = $image->get_size();
                    $w    = $size['width'];
                    $h    = $size['height'];

                    $scale = 1 / _image_get_preview_ratio( $w$h ); // Discard preview scaling.                     $image->crop( $sel->x * $scale$sel->y * $scale$sel->w * $scale$sel->h * $scale );
                } else {
                    $scale = 1 / _image_get_preview_ratio( imagesx( $image )imagesy( $image ) ); // Discard preview scaling.                     $image = _crop_image_resource( $image$sel->x * $scale$sel->y * $scale$sel->w * $scale$sel->h * $scale );
                }
                break;
        }
    }
return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}";
    }

    /** * Builds and returns proper suffix for file based on height and width. * * @since 3.5.0 * * @return string|false suffix */
    public function get_suffix() {
        if ( ! $this->get_size() ) {
            return false;
        }

        return "{$this->size['width']}x{$this->size['height']}";
    }

    /** * Check if a JPEG image has EXIF Orientation tag and rotate it if needed. * * @since 5.3.0 * * @return bool|WP_Error True if the image was rotated. False if not rotated (no EXIF data or the image doesn't need to be rotated). * WP_Error if error while rotating. */
Home | Imprint | This part of the site doesn't use cookies.