1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php header( 'Content-type: image/jpeg' ); if (!isset( $_GET [ 'file' ]) || ! file_exists ( $_GET [ 'file' ]) || strtolower ( substr ( $_GET [ 'file' ], strrpos ( $_GET [ 'file' ], '.' ))) != '.jpg' ) { $im = imagecreatetruecolor(100, 100); $white = imagecolorallocate( $im , 255, 255, 255); $black = imagecolorallocate( $im , 0, 0, 0); imagefill( $im , 50, 50, $white ); imagestring( $im , 5, 30, 40, 'Error' , $black ); imagejpeg( $im ); imagedestroy( $im ); exit (); } $src = imagecreatefromjpeg( $_GET [ 'file' ]); $sw = imagesx( $src ); $sh = imagesy( $src ); $x1 = (isset( $_GET [ 'x1' ]) && is_numeric ( $_GET [ 'x1' ]) && $_GET [ 'x1' ] >= 0 && $_GET [ 'x1' ] < $sw ) ? (int) $_GET [ 'x1' ] : 0; $y1 = (isset( $_GET [ 'y1' ]) && is_numeric ( $_GET [ 'y1' ]) && $_GET [ 'y1' ] >= 0 && $_GET [ 'y1' ] < $sh ) ? (int) $_GET [ 'y1' ] : 0; $x2 = (isset( $_GET [ 'x2' ]) && is_numeric ( $_GET [ 'x2' ]) && $_GET [ 'x2' ] >= 0 && $_GET [ 'x2' ] < $sw ) ? (int) $_GET [ 'x2' ] : $sw ; $y2 = (isset( $_GET [ 'y2' ]) && is_numeric ( $_GET [ 'y2' ]) && $_GET [ 'y2' ] >= 0 && $_GET [ 'y2' ] < $sh ) ? (int) $_GET [ 'y2' ] : $sh ; $tl = array ( 'x' => min ( $x1 , $x2 ), 'y' => min( $y1 , $y2 )); $br = array ( 'x' => max ( $x1 , $x2 ), 'y' => max( $y1 , $y2 )); $dw = abs ( $x1 - $x2 ); $dh = abs ( $y1 - $y2 ); $dst = imagecreatetruecolor( $dw , $dh ); imagecopyresized( $dst , $src , 0, 0, $tl [ 'x' ], $tl [ 'y' ], $dw , $dh , $br [ 'x' ], $br [ 'y' ]); imagejpeg( $dst ); imagedestroy( $dst ); imagedestroy( $src ); ?> |
رتبه موضوع:
نمایش بخشی از تصویر
|
05-03-1394، 07:47 ب.ظ
تشکر شده توسط: php
|
|
کاربران در حال بازدید این موضوع: 1 مهمان