В связи с мистическими событиями, все GD скрипты приходится переписывать под Imagick.
Самое интересное, в сети практически не найти ни нормальной документации по нему, ни примеров (особенно на русском, но нам впринципе пох). Поэтому выложу свою капчу, которая использует простой алгоритм MultiSwirl, описанный на сайте .
// Это строка, которую мы будем рисовать на изображении
$str = rand(1000, 999999);
$_SESSION['captcha'] = $str;
/*
** Здесь можно указать путь к своему шрифту
** $font = dirname(__FILE__) . '/MyriadPro-Bold.otf';
*/
/*
** Задаем углы закручивания
** и сдвиг, относительно центра перед закручиванием
*/
$corner1 = rand(30,50);
$corner2 = rand(30,50);
$roll = rand(20, 50);
// Создаем объект
$image = new Imagick();
$draw = new ImagickDraw();
$image->newImage(150, 50, new ImagickPixel('#ffffff'));
/*
** Если используем свой шрифт, передаем его в ImageDraw
** $draw->setFont($font);
*/
// Задаем размер шрифта
$draw->setFontSize(40);
// Накладываем нашу надпись
$image->annotateImage($draw, 10, 40, 0, $str);
Далее пошло уже закручивание изображения: сначала в одну сторону, потом в другую.
// Двигаем изображение и закручиваем его
$image->rollImage($roll,0);
$image->swirlImage(-$corner1);
$image->rollImage(-$roll*2,0);
$image->swirlImage($corner2);
$image->rollImage($roll,0);
Что можно сделать еще:
1. поиграться с углами
2. поставить пизданутый шрифт
3. уменьшить межбуквенный интервал
4. выводить не только цифры
5. Добавить несколько полос и также свирлом вместе с символами
Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/templates/compiled/%%F3^F3B^F3B39BC9%%topic_list.tpl.php on line 147
Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/templates/compiled/%%F3^F3B^F3B39BC9%%topic_list.tpl.php on line 147
0
Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 326
Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 326
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 329
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 329
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 334
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 334
8 сентября 2009, 18:19
Описываю способ создание юзербаров для пользователей всемирно любимой <a href="http://pyha.ru">пыхи</a>.
Результат:
<img src="http://epsyl.ru/wp-content/uploads/2009/08/barphp.gif">
Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/templates/compiled/%%F3^F3B^F3B39BC9%%topic_list.tpl.php on line 147
Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/templates/compiled/%%F3^F3B^F3B39BC9%%topic_list.tpl.php on line 147
+1
Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 326
Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 326
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 329
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 329
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 334
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 334
18 августа 2009, 16:52