форум вебмастероff на AlfaSpace.NET

Ubuntu и Linux |реактивный бесплатный хостинг | Киноклуб. ВСЁ БЕСПЛАТНО!
база знаний хостинга | правила форума

  Начало ° Ответить ° Статистика ° Опрос ° Регистрация ° Поиск ° FAQ °
Форум вебмастеров на AlfaSpace.NET / Создание сайта / Imagemagic vs. GD2
Автор Сообщение
yMaT
Участник

60
# Дата: 11 Мар 2005 14:14


народ подскажите кто силен в пхп, сложно ли переделать этот Imagemagic скрипт в GD2?

1. in the spaw config file, put these variables
$maxwidth=200;
$maxheight=200;
$imagemagickpath = "/usr/local/bin";

You can find the location of imagemagick on your server (if installed) by typing "which convert" at the command line.

2. Edit the dialogs/img_library.php file
Do a search for:
return $img_name;
Just before it put
resize_photo($dir_name, $img_name);

Then at the bottom of the file place the resize_photo() function
------------------------------------------------
function resize_image ($file_path, $large_file) {
global $errors, $l, $maxwidth, $maxheight, $imagemagickpath;

// first, grab the dimensions of the photo
$imagedata = @GetImageSize($file_path.$large_file);
$imagewidth = $imagedata[0];
$imageheight = $imagedata[1];
$imagetype = $imagedata[2];

// figure out the ratio to which it should be shrunk, if at all - compare to the maxwidth and maxheight variables
$shrinkage = 1;

if ($imageheight < $imagewidth) { // HORIZONTAL PHOTO
// CHECK IF IMAGE NEEDS TO BE RESIZED
if ($imagewidth > $maxwidth) {
$shrinkage = $maxwidth/$imagewidth;
$dest_large_width = $maxwidth;
$dest_large_height = $shrinkage * $imageheight;
$dest_large_height = sprintf("%d", $dest_large_height);
} else {
$noresize = "yes";
}

} else { // PORTRAIT OR SQUARE PHOTO
// CHECK IF IMAGE NEEDS TO BE RESIZED
if ($imageheight > $maxheight) {
$shrinkage = $maxheight/$imageheight;
$dest_large_height = $maxheight;
$dest_large_width = $shrinkage*$imagewidth;
$dest_large_width = sprintf("%d", $dest_large_width);
} else {
$noresize = "yes";
}

}
$new_large_file =$file_path.$large_file;

if (!$noresize) {
$safe= escapeshellcmd($imagemagickpath."convert -size ".$dest_large_width."x".$dest_large_height." $new_large_file -resize ".$dest_large_width."x".$dest_large_height." +profile");
$safe .= ' "*" ';
$safe .= escapeshellcmd($new_large_file);
exec($safe);
exec("chmod 777 ".$new_large_file);
} else {
if (copy($large_file, $new_large_file)) {
} else {
$errors[] = $l->m('error_uploading');
return false;
}
}
} // end function resize_photo
-----------------------------------------------

Ваш ответ

Quote  Bold Style  Italic Style  Underlined Style  URL Link  Email Link  Script AutoTab  Preformatted Text  Отменить *Что это?
... Запретить смайлы


Перед отправкой "нелатинского" текста проверьте кодировку броузера!
 » Логин  » Пароль 
 
Powered by miniBB forum software © 2001-2008
Powered by miniBB-gzipper. Original size:21954, gzipped size:7684

Mp3 Download || Webs Studio™ || Song's Lyrics
eXTReMe Tracker Rambler's Top100 Рейтинг@Mail.ru Форум ТвойWeb [Valid RSS]