Есть класс который служит для приведения фотографий к определенному стандарту 1024 х 756. ДЛя этого я использую GM.
Вопрос так ли я вызываю GM и как можно ускорить выполнение скрипта?
class CoreImgFiles {
private $files=[];
public $AllWaySavefiles=[];
public function __construct($allfiles)
{
self::rewriteArray($allfiles);
self::saveEvent();
}
private function rewriteArray($allfiles){
$files = [];
$file_count = count($allfiles['name'])-1;
for($i=$file_count;$i>=0;$i--)
{
$files[] = $allfiles['tmp_name'][$i];
unset($allfiles['name'][$i]);
unset($allfiles['type'][$i]);
unset($allfiles['tmp_name'][$i]);
unset($allfiles['error'][$i]);
unset($allfiles['size'][$i]);
}
unset($allfiles);
return $this->files=$files;
}
private function minimilize($savefile){
$image=new Gmagick($savefile);
$width=$image->getimagewidth();
$height=$image->getimageheight();
$standartWidth='';
$standartHeight='';
$x='';
$y='';
if($width>$height) {
$standartWidth=1024;
$standartHeight=756;
$masWidth=1300;
$masHeight=900;
$kw=$width/$masWidth;
$wx=$width/$kw;
$image->setCompressionQuality(80);
$image->profileimage('*',null);
$image->resizeimage($wx, $wx, null, 1, true);
$x = (($masWidth - $standartWidth) / 2);
$y = (($masHeight - $standartHeight) / 2);
}
if($width<$height) {
$standartWidth=1024;
$standartHeight=756;
$koef=$width/1024;
$wx=$height/$koef;
$image->setCompressionQuality(80);
$image->profileimage('*',null);
$image->resizeimage($wx, $wx, null, 1, true);
$x = 0;
$y = $wx/7.75;
}
$image->cropimage($standartWidth, $standartHeight, $x,$y);
$image->writeimage($savefile);
$image->destroy();
}
private function saveEvent(){
$event=mb_substr(sha1(date('YmdHis')), 0,10);
$Head="img/"."$event";
mkdir($Head,0777,true);
chmod($Head, 0777);
$AllWaySavefiles=[];
$LengthDaunloadFiles=count($this->files)-1;
for ($i=$LengthDaunloadFiles;$i>=0;$i--)
{
$newname = mb_substr(sha1(date('YmdHis',time()).mt_rand().$this->files[$i]),0,7).'.jpeg';
$savefile=$Head.'/'."$newname";
move_uploaded_file($this->files[$i],$savefile);
unset($this->files[$i]);
chmod($savefile, 0777);
self::minimilize($savefile);
$AllWaySavefiles[]=$savefile;
}
return $this->AllWaySavefiles=$AllWaySavefiles;
}
}
Оборудование для ресторана: новинки профессиональной кухонной техники
Частный дом престарелых в Киеве: комфорт, забота и профессиональный уход
Создал сайт на angularjs, но столкнулся с проблемой индексацииПрочитал кучу инструкций, но не смог наиболее актуальный и не платный
Есть переменная "$dates"В html-форме есть DatePicker с именем "datetime"
Загружаю json данные со стороннего сайта, некоторые символы приходят в UNICOD (точнее переменные в JSON) примерно таком: