Начинающий
Сообщений: 11
Зарегистрирован: 13.02.2011 13:10
|
Добрый день, помогите перепилить функцию, может кто уже вносил подобные изменения, задача сделать так:
Текущий режим работы: вписыввание изображение в указанный прямоугольник аля 800х600, без изменения пропорций.
Нужный режим обрезка боковых или верхнижних полей для вписывания в такую же область аля 800х600.
GeSHi: PHP function createthumbnail($filetype, $origfile, $thumbfile, $new_w, $new_h) { global $settings; $ratio_x = $old_x / $new_w; $ratio_y = $old_y / $new_h; if ($ratio_x > $ratio_y) { $thumb_w = round($old_x / $ratio_x); $thumb_h = round($old_y / $ratio_x); } else { $thumb_w = round($old_x / $ratio_y); $thumb_h = round($old_y / $ratio_y); }; if ($settings['thumb_compression'] == "gd1") { $result = imagecopyresized($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); } else { if ($filetype == 3) { } $result = imagecopyresampled($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); } if ($filetype == 1) { imagegif($thumbimage, $thumbfile); } elseif ($filetype == 2) { imagejpeg($thumbimage, $thumbfile); } elseif ($filetype == 3) { imagepng($thumbimage, $thumbfile); } }
Добавлено за 0.037 секунд, используя GeSHi 1.0.8.10
Да, замечания по поводу обрезки вертикальных фотографий почти в 2 раза я учитываю, и про панорамы помню.
--------------------------------------------------------------
ответ не получил..................
назвал другой функцией - createthumbcrop и обрабатываю ей только эскизы. Теперь пользовательская галлерея, доска объявлений, ну и основная галлерея может выглядеть одинаковыми эскизами,
GeSHi: PHP function createthumbcrop($filetype, $origfile, $thumbfile, $new_w, $new_h) { global $settings; $ratio_x = $old_x / $new_w; $ratio_y = $old_y / $new_h; $crop_y = 0; $crop_x = 0; if ($ratio_x < $ratio_y) { $thumb_w = round($old_x / $ratio_x); $thumb_h = round($old_y / $ratio_x); $crop_y = ($old_y - ($new_h * $ratio_x))/2; } else { $thumb_w = round($old_x / $ratio_y); $thumb_h = round($old_y / $ratio_y); $crop_x = ($old_x - ($new_w * $ratio_y))/2; } if ($settings['thumb_compression'] == "gd1") { $result = imagecopyresized($thumbimage, $origimage, 0, 0, $crop_x, $crop_y, $thumb_w, $thumb_h, $old_x, $old_y); } else { if ($filetype == 3) { } $result = imagecopyresampled($thumbimage, $origimage, 0, 0, $crop_x, $crop_y, $thumb_w, $thumb_h, $old_x, $old_y); } if ($filetype == 1) { imagegif($thumbimage, $thumbfile); } elseif ($filetype == 2) { imagejpeg($thumbimage, $thumbfile); } elseif ($filetype == 3) { imagepng($thumbimage, $thumbfile); } }
Добавлено за 0.022 секунд, используя GeSHi 1.0.8.10
Вложения не в тех масштабах отобразились, суть в том что остается только то, что вписывается в ваши размеры.
mpflash присоединено следующее:изображения:
Изменил(а) mpflash, 24.04.2015 22:28
|