public function insertPhotoEntry($data) { $albumId = $data['album']; $photoName = $data['name']; $path = JPATH_SITE . '/images/com_immotoa/' . $albumId; $info = pathinfo($photoName); $extension = $info['extension']; // get the extension of the file $filename = $info['filename']; // get the extension of the file if (!is_dir($path)) { mkdir($path); chmod($path, 0755); } include JPATH_SITE . '/vendor/autoload.php'; $img = new abeautifulsite\SimpleImage($data['file']); $img->auto_orient()->best_fit(2048, 2048); $img->save($path . '/' . $photoName, 90); return true; }
private function upload($id) { if (isset($this->request->data['foto']) and count($this->request->data['foto']) > 0 and $this->request->data['foto']['name'] != '') { $file = new File($this->request->data['foto']['tmp_name'], true, 0644); $ext = explode('/', $this->request->data['foto']['type']); $file->copy(ROOT . DS . 'webroot' . DS . 'ImagemProdutos' . DS . $id . '.' . strtolower($ext[1])); $file->close(); try { $img = new \abeautifulsite\SimpleImage(ROOT . DS . 'webroot' . DS . 'ImagemProdutos' . DS . $id . '.' . strtolower($ext[1])); $img->auto_orient()->best_fit(500, 500)->save(ROOT . DS . 'webroot' . DS . 'ImagemProdutos' . DS . $id . '.' . strtolower($ext[1])); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } return $id . '.' . strtolower($ext[1]); } else { return null; } }
$command[] = '"' . $thumb->destination->root . '"'; exec(implode(' ', $command)); }; /** * GDLib Driver */ thumb::$drivers['gd'] = function ($thumb) { try { $img = new abeautifulsite\SimpleImage($thumb->root()); $img->quality = $thumb->options['quality']; if ($thumb->options['crop']) { @$img->thumbnail($thumb->options['width'], $thumb->options['height']); } else { $dimensions = clone $thumb->source->dimensions(); $dimensions->fitWidthAndHeight($thumb->options['width'], $thumb->options['height'], $thumb->options['upscale']); @$img->resize($dimensions->width(), $dimensions->height()); } if ($thumb->options['grayscale']) { $img->desaturate(); } if ($thumb->options['blur']) { $img->blur('gaussian', $thumb->options['blurpx']); } if ($thumb->options['autoOrient']) { $img->auto_orient(); } @$img->save($thumb->destination->root); } catch (Exception $e) { $thumb->error = $e; } };