title: how to get image data
body: <p>I want get image data to crop and after then save</p>
  
  <pre><code>    &lt;?php
  
      namespace App\Controller;
  
      use App\Entity\Services;
      use App\Form\ServicesType;
      use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
      use Symfony\Component\HttpFoundation\Request;
      use Symfony\Component\Routing\Annotation\Route;
      use Symfony\Component\HttpFoundation\File\Exception\FileException;
      use Symfony\Component\HttpFoundation\File\UploadedFile;
  
      class CreateServiceController extends AbstractController
      {
          /**
           * @Route("/create/service", name="create_service")
           */
          public function index(Request $request)
          {
  
              $service = new Services();
              $form = $this-&gt;createForm(ServicesType::class, $service);
              $form-&gt;handleRequest($request);
  
              if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
  
                  $service = $form-&gt;getData();
                  $service-&gt;setCreated(new \DateTime('now'));
  
                  /** @var UploadedFile $imagereFile */
                  $imageFile = $form-&gt;get('image')-&gt;getData();
  
                  if ($imageFile) {
                      $originalFilename = pathinfo($imageFile-&gt;getClientOriginalName(), PATHINFO_FILENAME);
  
                      $safeFilename = transliterator_transliterate('Any-Latin; Latin-ASCII; [^A-Za-z0-9_] remove; Lower()', $originalFilename);
                      $newFilename = $safeFilename.'-'.uniqid().'.'.$imageFile-&gt;guessExtension();
  
                      try {
                          $imageFile-&gt;move(
                              $this-&gt;getParameter('image_directory'),
                              $newFilename
                          );
  
  //problem here
                          $croped = \imagecrop( $this-&gt;getParameter('image_directory').$newFilename, ['x' =&gt; 0, 'y' =&gt; 0, 'width' =&gt; 100, 'height' =&gt; 100]);
                          imagejpeg($croped, $this-&gt;getParameter('image_directory').$newFilename, 75);
                      } catch (FileException $e) {
                          // ... handle exception if something happens during file upload
                      }
                      $service-&gt;setImage($newFilename);
                  }
  
                  // ... perform some action, such as saving the task to the database
                  // for example, if Task is a Doctrine entity, save it!
                  $entityManager = $this-&gt;getDoctrine()-&gt;getManager();
                  $entityManager-&gt;persist($service);
                  $entityManager-&gt;flush();
  
                  return $this-&gt;redirectToRoute('services');
              }
  
              return $this-&gt;render('update_service/index.html.twig', [
                  'form' =&gt; $form-&gt;createView(),
              ]);
          }
      }
  </code></pre>
  
  <p>I have this code but it does not work</p>
  
  <pre><code>Warning: imagecrop() expects parameter 1 to be resource, string given
  </code></pre>
  
  <blockquote>
    <p>//problem here</p>
    
    <p>$croped = \imagecrop( $this->getParameter('image_directory').$newFilename, ['x' => 0, 'y' => 0, 'width' => 100, 'height' => 100]);</p>
    
    <p>imagejpeg($croped, $this->getParameter('image_directory').$newFilename, 75);</p>
    
    <p>} catch (FileException $e) {</p>
    
    <p>// ... handle exception if something happens during file upload</p>
    
    <p>}</p>
    
    <p>$service->setImage($newFilename);</p>
    
    <p>}</p>
  </blockquote>