У меня путь к изображению храниться в переменной $img. Объясните, желательно поподробней Буду очень благодарен!
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- <?PHP
- function imageResize($img, $newWidth, $newHeight) {
- $width = $size[0];
- $height = $size[1];
- if($width>$height){
- $need_ratio = $width/$newWidth;
- $n_width = $newWidth;
- $n_height = $height/$need_ratio;
- $ofset_y = ($newHeight - $n_height)/2;
- if($n_height>$newHeight){
- $need_ratio = $height/$newHeight;
- $n_width = $width/$need_ratio;
- $n_height = $newHeight;
- $ofset_x = ($newWidth - $n_width)/2;
- $ofset_y = ($newHeight - $n_height)/2;
- }
- }
- else {
- $need_ratio = $height/$newHeight;
- $n_width = $width/$need_ratio;
- $n_height = $newHeight;
- $ofset_x = ($newWidth - $n_width)/2;
- if($n_width>$newWidth){
- $need_ratio = $width/$newWidth;
- $n_width = $newWidth;
- $n_height = $height/$need_ratio;
- $ofset_y = ($newHeight - $n_height)/2;
- $ofset_x = ($newWidth - $n_width)/2;
- }
- }
- if($size[2]==IMAGETYPE_GIF){
- }
- else if($size[2]==IMAGETYPE_JPEG){
- }
- else {
- }
- $n_width,$n_height,$width,$height);
- if($size[2]==IMAGETYPE_GIF){
- }
- else if($size[2]==IMAGETYPE_JPEG){
- }
- else {
- }
- }
- ?>