Retourner au contenu associé (entrée de forum : Transformation d'image: effet de perspective)
Posté par Fnourry le 30 septembre 2005 à 16:15. En réponse au message Transformation d'image: effet de perspective. Évalué à 4.
<?php // Image::Trapeze(chemin de l'image JPG, base superieure, base inférieure) function trapeze($sImagePath, $nSupX, $nSubX) { $source = imagecreatefromjpeg($sImagePath); list($width, $height) = getimagesize($sImagePath); $thumb = imagecreate(max($nSupX, $nSubX), $height); imagefill($thumb, 0, 0, ImageColorAllocate( $thumb, 0, 0, 0 )); // <<---- Couleur de fond $nCoefX = ((float)($nSubX-$nSupX))/($height*2); $nPosStartX = ($width-$nSupX)/2; $nPosEndX = ($width-$nSubX)/2; $nPosX = ($width-$nSupX)/2 - min($nPosStartX, $nPosEndX); $nNewWidth = $nSupX; for($cpt=0; $cpt<$height; $cpt++) { imagecopyresized($thumb, $source, $nPosX, $cpt, 0, $cpt, $nNewWidth, 1, $width, 1); $nPosX -= $nCoefX; $nNewWidth += $nCoefX*2; } return $thumb; } // Fichier et nouvelle taille $filename = 'test.jpg'; // Content type header('Content-type: image/jpeg'); // Affichage imagejpeg(trapeze($filename, 100 , 100)); ?>
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
# C'est cadeau, ça fait plaisir
Posté par Fnourry . En réponse au message Transformation d'image: effet de perspective. Évalué à 4.
<?php // Image::Trapeze(chemin de l'image JPG, base superieure, base inférieure) function trapeze($sImagePath, $nSupX, $nSubX) { $source = imagecreatefromjpeg($sImagePath); list($width, $height) = getimagesize($sImagePath); $thumb = imagecreate(max($nSupX, $nSubX), $height); imagefill($thumb, 0, 0, ImageColorAllocate( $thumb, 0, 0, 0 )); // <<---- Couleur de fond $nCoefX = ((float)($nSubX-$nSupX))/($height*2); $nPosStartX = ($width-$nSupX)/2; $nPosEndX = ($width-$nSubX)/2; $nPosX = ($width-$nSupX)/2 - min($nPosStartX, $nPosEndX); $nNewWidth = $nSupX; for($cpt=0; $cpt<$height; $cpt++) { imagecopyresized($thumb, $source, $nPosX, $cpt, 0, $cpt, $nNewWidth, 1, $width, 1); $nPosX -= $nCoefX; $nNewWidth += $nCoefX*2; } return $thumb; } // Fichier et nouvelle taille $filename = 'test.jpg'; // Content type header('Content-type: image/jpeg'); // Affichage imagejpeg(trapeze($filename, 100 , 100)); ?>