Ejemplo n.º 1
0
 /**
  * @Route("/flyer/image_base64", name="flyer_image_base64")
  */
 public function getImageBase64Action(Request $request)
 {
     $cloudinaryApi = $this->get('speicher210_cloudinary.api');
     $photoId = $request->get('photoId');
     $width = $request->get('width');
     $height = $request->get('height');
     $crop = $request->get('crop');
     $format = $request->get('format');
     $img = $cloudinaryApi->resource($photoId, array('width' => $width, 'height' => $height, 'crop' => $crop, 'format' => $format));
     $thumb = \PhpThumb_Factory::create($img['url']);
     $data = "data:image/png;base64,";
     $data .= base64_encode($thumb->getImageAsString());
     return new JsonResponse(array('img' => $data));
 }
Ejemplo n.º 2
0
 public function imgToBase64($src)
 {
     $thumb = \PhpThumb_Factory::create($src);
     $data = "data:image/png;base64,";
     return $data . base64_encode($thumb->getImageAsString());
 }