• Resolved brening

    (@brening)


    Hallo!
    I am using the crop method for an object of the WP_Image_Editor class. I have several images for which this method does not work correctly. For example: https://postlmg.cc/WdXRVBXk
    My code:

    
    $image_path = 'https://postlmg.cc/WdXRVBXk';
    $image_path1 = '/localhost/blue1.jpeg';
    
    $image = wp_get_image_editor($image_path);
    $image->crop(0, 2532, 918, 918);
    $image->save($image_path1);
    

    The new image is stretched and the area does not correspond to the data specified in the parameters.
    Help me solve the problem.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter brening

    (@brening)

    I found out that for images with a size of 3024*4032, the wp_get_image_editor function confuses the height and width. Therefore, the crop method then incorrectly selects the area. But I didn’t find a regularity when exactly the function wp_get_image_editor confuses height and width. That’s why I still need help.

    Thread Starter brening

    (@brening)

    Everything was solved with one line of code:
    $image->maybe_exif_rotate();

    This function check if a JPEG image has EXIF Orientation tag and rotate it if needed.
    Maybe it will help someone.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Crop Issue’ is closed to new replies.