Beispiel #1
0
 public function getCustomImageSizeResponse($id, $width, $height)
 {
     $repository = $this->manager->getRepository('EnhavoMediaBundle:File');
     $file = $repository->find($id);
     if ($file === null) {
         throw new NotFoundResourceException();
     }
     if ($width && !$height) {
         $path = $this->path . '/custom/' . $width;
         $this->createPathIfNotExists($path);
         $filepath = $path . '/' . $id;
         if (!file_exists($filepath) || filemtime($filepath) < filemtime($this->getFilepath($file))) {
             Resize::make($this->getFilepath($file), $filepath, $width, 99999);
         }
     } else {
         $path = $this->path . '/custom/' . $width . 'x' . $height;
         $this->createPathIfNotExists($path);
         $filepath = $path . '/' . $id;
         if (!file_exists($filepath) || filemtime($filepath) < filemtime($this->getFilepath($file))) {
             Thumbnail::make($this->getFilepath($file), $filepath, $width, $height);
         }
     }
     $response = new BinaryFileResponse($filepath);
     $response->headers->set('Content-Type', $file->getMimeType());
     return $response;
 }
$extensions = array('.png', '.gif', '.jpg', '.jpeg', '.bmp', '.PNG', '.GIF', '.JPG', '.JPEG', '.BMP');
$extension = strrchr($_FILES['myfile']['name'], '.');
if (in_array($extension, $extensions)) {
    if (move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
        include_once '../resize.class.php';
        try {
            $obj = new Resize($target_path);
            $obj->setNewImage($destination_path . $markedImageName);
            //			$obj->setWaterMarkImage($path_2_watermark);
            //			$obj->setWaterMarkOpacity(100);
            //			$obj->setWaterMarkPosition('bottomLeft');
            $obj->setProportionalFlag('V');
            $obj->setProportional(1);
            // 			$obj->setDegrees(90);
            $obj->setNewSize($max_upload_size[1], $max_upload_size[0]);
            $obj->make();
        } catch (Exception $e) {
            die($e);
        }
        $result = 1;
    }
}
sleep(1);
?>

<script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php 
echo $result;
?>
, '', '<?php 
echo $link_2_upload . $markedImageName;
?>