PHP.mk документација

Imagick::getImageOrientation

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

imagick.getimageorientation.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека imagick.getimageorientation.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Imagick::getImageOrientation

Референца за `imagick.getimageorientation.php` со подобрена типографија и навигација.

imagick.getimageorientation.php

Imagick::getImageOrientation

(PECL imagick 2, PECL imagick 3)

Imagick::getImageOrientationGets the image orientation

= NULL

public Imagick::getImageOrientation(): int

Gets the image orientation. The return value is one of the Го поставува ориентацијата на сликата..

Параметри

Оваа функција нема параметри.

Вратени вредности

Returns an int on success.

Errors/Exceptions

Фрла ImagickException при грешка.

Белешки од корисници 2 забелешки

Imagick::setImageOrientation()
пред 13 години
Here's how you can use the getImageOrientation() information to auto-rotate images to their correct orientation...

<?php
// Note: $image is an Imagick object, not a filename! See example use below.
function autoRotateImage($image) {
    $orientation = $image->getImageOrientation();

    switch($orientation) {
        case imagick::ORIENTATION_BOTTOMRIGHT: 
            $image->rotateimage("#000", 180); // rotate 180 degrees
        break;

        case imagick::ORIENTATION_RIGHTTOP:
            $image->rotateimage("#000", 90); // rotate 90 degrees CW
        break;

        case imagick::ORIENTATION_LEFTBOTTOM: 
            $image->rotateimage("#000", -90); // rotate 90 degrees CCW
        break;
    }

    // Now that it's auto-rotated, make sure the EXIF data is correct in case the EXIF gets saved with the image!
    $image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
}
?>

Example use:

<?php
$image = new Imagick('my-image-file.jpg');
autoRotateImage($image);
// - Do other stuff to the image here -
$image->writeImage('result-image.jpg');
?>
Keisial на gmail точка com
пред 13 години
Using the getImageOrientation function, you'll get the Orientation value for an image as defined within the EXIF file format.  That means you will get back an integer representation one of the Orientation constants for ImageMagick, which looks like " imagick::ORIENTATION_UNDEFINED", with "_VALUE" values of: undefined (0), topleft (1), topright (2), bottomright (3), bottomleft (4), lefttop (5), righttop (6), rightbottom (7), and leftbottom (8).  When printed out directly, these predefined constants produce the number in parenthesis.  The undefined being set to 0 makes sense, since -- according to Wikipedia -- EXIF allows for eight possible values for an image (and not every image has a set of EXIF properties).

The EXIF Orientation is also called "the Rotation," again, according to Wikipedia: http://en.wikipedia.org/wiki/Exchangeable_image_file_format .  What's the point of that?  According to the official ImageMagick documentation, it's to rotate a photograph so that it is properly oriented after the shot.  This really seems to be a camera thing, since the ImageMagick documentation mentions: "If you pointed your camera almost straight up or down, the EXIF orientation setting may not resolve correctly. The same goes for angled or slanted shots. The orientation (and cameras) just have no senses for these situations." ( http://www.imagemagick.org/Usage/photos/ )

If you're having trouble getting this function to show the value for Image Orientation, then use the function and parameters of getImageProperties('*', FALSE); .  This produces an array of all properties associated with an image, and one of them will have the key value of exif:Orientation.  If it doesn't, then that means you will be getting back a zero from this function, indicating an "Undefined" orientation.

Some sample code :

<?php

            // Author: [email protected]
    
        // Imagick Type
        // ---------------------------------------------

    $imagick_type = new Imagick();
    
        // Open File
        // ---------------------------------------------
        
    $file_to_grab = "image_workshop_directory/test.jpg";
    
    $file_handle_for_viewing_image_file = fopen($file_to_grab, 'a+');
    
        // Grab File
        // ---------------------------------------------

    $imagick_type->readImageFile($file_handle_for_viewing_image_file);
    
        // Get Orientation Values
        // ---------------------------------------------

    $imagick_orientation = $imagick_type->getImageOrientation();
    
    switch($imagick_orientation)
    {
        case '0':
            $imagick_orientation_evaluated = "Undefined";
            break;
        
        case '1':
            $imagick_orientation_evaluated = "Top-Left";
            break;
        
        case '2':
            $imagick_orientation_evaluated = "Top-Right";
            break;
        
        case '3':
            $imagick_orientation_evaluated = "Bottom-Right";
            break;
        
        case '4':
            $imagick_orientation_evaluated = "Bottom-Left";
            break;
        
        case '5':
            $imagick_orientation_evaluated = "Left-Top";
            break;
        
        case '6':
            $imagick_orientation_evaluated = "Right-Top";
            break;
        
        case '7':
            $imagick_orientation_evaluated = "Right-Bottom";
            break;
        
        case '8':
            $imagick_orientation_evaluated = "Left-Bottom";
            break;
    }
    
        // Print Orientation Values
        // ---------------------------------------------
    
    print("# $imagick_orientation - $imagick_orientation_evaluated");

?>
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.