Symfony图片下载

I have action for download picture and post picture toamazonS3 and set url AmazonS3 in DB:

public function photoUploadAction($username)
{
    $em = $this->getDoctrine()->getManager();
    $request = $this->get('request');
    $profileRepository = $this->get('artel.profile.developer.repository');
    $developer = $profileRepository->findOneByUsername($username);
    $developer_username = $developer->getUserName();

    if (!$developer) {
        throw $this->createNotFoundException('Unable to find a profile.');
    }
    $authenticator = $this->get('artel.profile.authenticator');
    if (!$authenticator->check($developer)) {
        throw new AccessDeniedException('Access Denied!');
    }

    $url = sprintf(
        '%s%s',
        $this->container->getParameter('acme_storage.amazon_s3.base_url'),
        $this->getPhotoUploader()->upload($request->files->get('file'), $developer_username)
    );

    $developer->setImage($url);
    $em->persist($developer);

    $em->flush();

    return new Response($url);

and I need, if this picture have size 1024x768 or more, I have to change a one-size-height proportional to the width of 150. How I do this. What are the ways to solve this problem?