<?php
function createThumb( $fname , $thumbWidth , $thumbHeight ) {
echo "Ошибка. Изображения не существует $fname " ;
}
else {
if ( $width < $thumbWidth && $height < $thumbHeight ) {
continue ;
}
if ( $width > $height ) {
$new_width = $thumbWidth ;
$new_height = floor ( $height * ( $thumbWidth / $width ) ) ; }
else {
$new_height = $thumbHeight ;
$new_width = floor ( $width * ( $thumbHeight / $height ) ) ; }
header ( 'Content-Type: image/jpg' ) ; }
if ( $width < $thumbWidth && $height < $thumbHeight ) {
continue ;
}
if ( $width > $height ) {
$new_width = $thumbWidth ;
$new_height = floor ( $height * ( $thumbWidth / $width ) ) ; }
else {
$new_height = $thumbHeight ;
$new_width = floor ( $width * ( $thumbHeight / $height ) ) ; }
header ( 'Content-Type: image/png' ) ; imagepng ( $tmp_img , "thumbnails/$fname " ) ; }
}
}
$fname = $_GET [ 'fname' ] ;
createThumb( $fname , 100 , 100 ) ;
PD9waHAKCmZ1bmN0aW9uIGNyZWF0ZVRodW1iKCRmbmFtZSwgJHRodW1iV2lkdGgsICR0aHVtYkhlaWdodCl7CgkkZGlyID0gc2NhbmRpcignaW1hZ2VzJyk7CgkKCWlmKCFpbl9hcnJheSgkZm5hbWUsICRkaXIpKXsKCQllY2hvICLQntGI0LjQsdC60LAuINCY0LfQvtCx0YDQsNC20LXQvdC40Y8g0L3QtSDRgdGD0YnQtdGB0YLQstGD0LXRgiAkZm5hbWUiOwoJfQoJZWxzZXsKCQkkaW5mbyA9IHBhdGhpbmZvKCJpbWFnZXMvJGZuYW1lIik7CgkJaWYoc3RydG9sb3dlcigkaW5mb1snZXh0ZW5zaW9uJ109PSdqcGcnKSl7CgkJCQoJCQkkaW1nID0gaW1hZ2VjcmVhdGVmcm9tanBlZygiaW1hZ2VzLyRmbmFtZSIpOwoJCQkkd2lkdGggPSBpbWFnZXN4KCRpbWcpOwoJCQkkaGVpZ2h0ID0gaW1hZ2VzeSgkaW1nKTsKCQkJaWYoJHdpZHRoPCR0aHVtYldpZHRoICYmICRoZWl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