0

php gd function で画像を反転しようとしていますimageflip()。GDをインストールしました。WindowsでWAMPとcodeigniterを使用しています。(そして、wampにimagemagickを実装するのはちょっと難しいので、私はしたくないです)。imageflip() は、私が見ているように動作するはずです。PHP バージョン 5.4.16 を使用しています。

多分私は何かが足りない...

からphpinfo():

gd

GD Support          enabled
GD Version          bundled (2.1.0 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.4.10
GIF Read Support    enabled
GIF Create Support  enabled
JPEG Support        enabled
libJPEG Version     8
PNG Support         enabled
libPNG Version      1.2.50
WBMP Support        enabled
XPM Support         enabled 
libXpm Version      30411
XBM Support         enabled

Directive               Local Value     Master Value
gd.jpeg_ignore_ warning     0               0

私はこのコードを持っています:

foreach($products_settings as &$ps) {                
    $filename = $_SERVER['DOCUMENT_ROOT'] . $ps['product_file'];                
    $source_image = imagecreatefromjpeg($filename);  

    //Put source image-resource into array
    $ps['source_image'] = $source_image;
}

そしてそれは動作します..

私が使用するimagerotate()と、それも機能します...

foreach($products_settings as &$ps) {                
    $filename = $_SERVER['DOCUMENT_ROOT'] . $ps['product_file'];                
    $source_image = imagecreatefromjpeg($filename);  

    //rotate image
    $angle = $ps['product_angle'];
    if (intval($angle) <> 0) {
        $source_image = imagerotate($source_image, 360-$angle, imageColorAllocateAlpha($source_image, 255, 255, 255, 127));
    }

    //Put source image-resource into array
    $ps['source_image'] = $source_image;
}

...しかし、imageflip を使用する場合 ( http://php.net/manual/en/function.imageflip.php )

foreach($products_settings as &$ps) {                
    $filename = $_SERVER['DOCUMENT_ROOT'] . $ps['product_file'];                
    $source_image = imagecreatefromjpeg($filename);  
    imageflip($source_image, IMG_FLIP_BOTH);   //code execution stops here

    //Put source image-resource into array
    $ps['source_image'] = $source_image;
}  

その後、imageflip()コードが停止します(ログメッセージをログに記録しない行の後に追加すると)。理由がわかりません。その理由は何でしょうか?codeigniter/php/apache のエラー ログに何も表示されません。マニュアルには、失敗すると関数が false を返すと書かれていますが、他の gd 関数 (など)imagerotateと同じ画像に対して他の gd 関数を使用しているため、画像が正しいことはわかっています。imageColorAllocateAlpha

私もこれを試しました:

try {
    imageflip($source_image, IMG_FLIP_BOTH); 
}
catch (Exception $e) {
    log_message('DEBUG', 'img err' . $e->__toString());
}

しかし、何も記録されません...

これをデバッグする方法は?

4

1 に答える 1

1

imageflipPHPバージョン 5.4.16には機能がありません。PHP 5.5 をインストールすると、その機能を使用できます。

PHP 5.5 をインストールできず、GD で画像を反転する必要がある場合は、古いバージョンの PHP で動作するコードを使用することもできます。

私はいくつかのマイナーな問題についてコードに完全に同意しているわけではありませんが、実際にこれがどのように行われるかをよく示しています。

于 2013-09-01T09:30:19.790 に答える