imagick не работает с tmp
Как не пытался запустить, никак не хочет работать с .tmp файлами, GD работает а imagick нет, пробовал и через readImageFile открыть никак, смотрел примеры там используют: /**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.php.geshi_code {font-family:monospace;}
.php.geshi_code .imp {font-weight: bold; color: red;}
.php.geshi_code .kw1 {color: #b1b100;}
.php.geshi_code .kw2 {color: #000000; font-weight: bold;}
.php.geshi_code .kw3 {color: #990000;}
.php.geshi_code .co1 {color: #666666; font-style: italic;}
.php.geshi_code .co2 {color: #666666; font-style: italic;}
.php.geshi_code .co3 {color: #0000cc; font-style: italic;}
.php.geshi_code .co4 {color: #009933; font-style: italic;}
.php.geshi_code .coMULTI {color: #666666; font-style: italic;}
.php.geshi_code .es0 {color: #000099; font-weight: bold;}
.php.geshi_code .es1 {color: #000099; font-weight: bold;}
.php.geshi_code .es2 {color: #660099; font-weight: bold;}
.php.geshi_code .es3 {color: #660099; font-weight: bold;}
.php.geshi_code .es4 {color: #006699; font-weight: bold;}
.php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;}
.php.geshi_code .es6 {color: #009933; font-weight: bold;}
.php.geshi_code .es_h {color: #000099; font-weight: bold;}
.php.geshi_code .br0 {color: #009900;}
.php.geshi_code .sy0 {color: #339933;}
.php.geshi_code .sy1 {color: #000000; font-weight: bold;}
.php.geshi_code .st0 {color: #0000ff;}
.php.geshi_code .st_h {color: #0000ff;}
.php.geshi_code .nu0 {color: #cc66cc;}
.php.geshi_code .nu8 {color: #208080;}
.php.geshi_code .nu12 {color: #208080;}
.php.geshi_code .nu19 {color:#800080;}
.php.geshi_code .me1 {color: #004000;}
.php.geshi_code .me2 {color: #004000;}
.php.geshi_code .re0 {color: #000088;}
.php.geshi_code span.xtra { display:block; }
$_FILES['poster']['tmp_name']
А у меня никак не хочет, вот пример
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .php.geshi_code {font-family:monospace;} .php.geshi_code .imp {font-weight: bold; color: red;} .php.geshi_code .kw1 {color: #b1b100;} .php.geshi_code .kw2 {color: #000000; font-weight: bold;} .php.geshi_code .kw3 {color: #990000;} .php.geshi_code .co1 {color: #666666; font-style: italic;} .php.geshi_code .co2 {color: #666666; font-style: italic;} .php.geshi_code .co3 {color: #0000cc; font-style: italic;} .php.geshi_code .co4 {color: #009933; font-style: italic;} .php.geshi_code .coMULTI {color: #666666; font-style: italic;} .php.geshi_code .es0 {color: #000099; font-weight: bold;} .php.geshi_code .es1 {color: #000099; font-weight: bold;} .php.geshi_code .es2 {color: #660099; font-weight: bold;} .php.geshi_code .es3 {color: #660099; font-weight: bold;} .php.geshi_code .es4 {color: #006699; font-weight: bold;} .php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;} .php.geshi_code .es6 {color: #009933; font-weight: bold;} .php.geshi_code .es_h {color: #000099; font-weight: bold;} .php.geshi_code .br0 {color: #009900;} .php.geshi_code .sy0 {color: #339933;} .php.geshi_code .sy1 {color: #000000; font-weight: bold;} .php.geshi_code .st0 {color: #0000ff;} .php.geshi_code .st_h {color: #0000ff;} .php.geshi_code .nu0 {color: #cc66cc;} .php.geshi_code .nu8 {color: #208080;} .php.geshi_code .nu12 {color: #208080;} .php.geshi_code .nu19 {color:#800080;} .php.geshi_code .me1 {color: #004000;} .php.geshi_code .me2 {color: #004000;} .php.geshi_code .re0 {color: #000088;} .php.geshi_code span.xtra { display:block; }
$poster = $_FILES['poster']['tmp_name'];
if(class_exists('imagick')
{
$img = new imagick($poster);
$img->stripImage();
$img->setCompressionQuality(75);
$img->writeImage($poster);
$img->clear();
$img->destroy();
}
Выдаёт такую ошибку
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .ini.geshi_code {font-family:monospace;} .ini.geshi_code .imp {font-weight: bold; color: red;} .ini.geshi_code .co0 {color: #666666; font-style: italic;} .ini.geshi_code .sy0 {color: #000066; font-weight:bold;} .ini.geshi_code .st0 {color: #933;} .ini.geshi_code .re0 {color: #000066; font-weight:bold;} .ini.geshi_code .re1 {color: #000099;} .ini.geshi_code .re2 {color: #660066;} .ini.geshi_code span.xtra { display:block; }
012/06/23 15:56:36 [error] 1932#788: *1 FastCGI sent in stderr: "PHP Fatal error: Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `C:UsersАдминистраторAppDataLocalTempphp3F15.tmp' @ error/constitute.c/ReadImage/544' in C:functions_uploads.php:157
Stack trace:
#0 C:htdocsfunctions_uploads.php(157): Imagick->__construct('C:Users??????...')
#1 C:htdocsedit.php(179): upload_poster(Array)
#2 {main}
thrown in C:htdocsfunctions_uploads.php on line 157" while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: "POST /edit?section=editing&id=61 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1", referrer: "http://localhost/edit?id=61"
Как быть?
$_FILES['poster']['tmp_name']
А у меня никак не хочет, вот пример
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .php.geshi_code {font-family:monospace;} .php.geshi_code .imp {font-weight: bold; color: red;} .php.geshi_code .kw1 {color: #b1b100;} .php.geshi_code .kw2 {color: #000000; font-weight: bold;} .php.geshi_code .kw3 {color: #990000;} .php.geshi_code .co1 {color: #666666; font-style: italic;} .php.geshi_code .co2 {color: #666666; font-style: italic;} .php.geshi_code .co3 {color: #0000cc; font-style: italic;} .php.geshi_code .co4 {color: #009933; font-style: italic;} .php.geshi_code .coMULTI {color: #666666; font-style: italic;} .php.geshi_code .es0 {color: #000099; font-weight: bold;} .php.geshi_code .es1 {color: #000099; font-weight: bold;} .php.geshi_code .es2 {color: #660099; font-weight: bold;} .php.geshi_code .es3 {color: #660099; font-weight: bold;} .php.geshi_code .es4 {color: #006699; font-weight: bold;} .php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;} .php.geshi_code .es6 {color: #009933; font-weight: bold;} .php.geshi_code .es_h {color: #000099; font-weight: bold;} .php.geshi_code .br0 {color: #009900;} .php.geshi_code .sy0 {color: #339933;} .php.geshi_code .sy1 {color: #000000; font-weight: bold;} .php.geshi_code .st0 {color: #0000ff;} .php.geshi_code .st_h {color: #0000ff;} .php.geshi_code .nu0 {color: #cc66cc;} .php.geshi_code .nu8 {color: #208080;} .php.geshi_code .nu12 {color: #208080;} .php.geshi_code .nu19 {color:#800080;} .php.geshi_code .me1 {color: #004000;} .php.geshi_code .me2 {color: #004000;} .php.geshi_code .re0 {color: #000088;} .php.geshi_code span.xtra { display:block; }
$poster = $_FILES['poster']['tmp_name'];
if(class_exists('imagick')
{
$img = new imagick($poster);
$img->stripImage();
$img->setCompressionQuality(75);
$img->writeImage($poster);
$img->clear();
$img->destroy();
}
Выдаёт такую ошибку
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .ini.geshi_code {font-family:monospace;} .ini.geshi_code .imp {font-weight: bold; color: red;} .ini.geshi_code .co0 {color: #666666; font-style: italic;} .ini.geshi_code .sy0 {color: #000066; font-weight:bold;} .ini.geshi_code .st0 {color: #933;} .ini.geshi_code .re0 {color: #000066; font-weight:bold;} .ini.geshi_code .re1 {color: #000099;} .ini.geshi_code .re2 {color: #660066;} .ini.geshi_code span.xtra { display:block; }
012/06/23 15:56:36 [error] 1932#788: *1 FastCGI sent in stderr: "PHP Fatal error: Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `C:UsersАдминистраторAppDataLocalTempphp3F15.tmp' @ error/constitute.c/ReadImage/544' in C:functions_uploads.php:157
Stack trace:
#0 C:htdocsfunctions_uploads.php(157): Imagick->__construct('C:Users??????...')
#1 C:htdocsedit.php(179): upload_poster(Array)
#2 {main}
thrown in C:htdocsfunctions_uploads.php on line 157" while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: "POST /edit?section=editing&id=61 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1", referrer: "http://localhost/edit?id=61"
Как быть?
1 ответов
Видимо, imagick получает информацию о типе изображения из расширения, который не узнать из временного имени. Попробуйте сначала перенести временный файл в папку для изображений через move_uploaded_file(), и работать уже с ним.