private function saveImageContents(Image $client, SourceImage $image, $saveTo, OutputInterface $output, $stackName = null, $format = 'jpg')
    {
        if (!$stackName) {
            $output->writeln('Getting source image contents for <info>'.$image->hash.'</info> from <comment>'.$image->organization.'</comment>');
        } else {
            $output->writeln('Rendering image  <info>'.$image->hash.'</info> from <comment>'.$image->organization.'</comment> on stack <info>'.$stackName.'</info>');
        }

        $contents = $this->rokkaHelper->getSourceImageContents($client, $image->hash, $image->organization, $stackName, $format);
        if (!$contents) {
            $output->writeln($this->formatterHelper->formatBlock([
                'Error!',
                'Error getting image contents from Rokka.io!',
            ], 'error', true));

            return false;
        }

        // TODO: verify if target file exists, ask for permission to overwrite unless --force
        $ret = file_put_contents($saveTo, $contents, FILE_BINARY);
        if (false == $ret) {
            $output->writeln($this->formatterHelper->formatBlock([
                'Error!',
                'Error writing image contents to <info>'.$saveTo.'</info>!',
            ], 'error', true));

            return false;
        }

        $output->writeln('Image saved to <info>'.$saveTo.'</info>');

        return true;
    }
private function saveImageContents(Image $client, SourceImage $image, $saveTo, OutputInterface $output, $stackName = null, $format = 'jpg')
    {
        if (!$stackName) {
            $output->writeln('Getting source image contents for <info>'.$image->hash.'</info> from <comment>'.$image->organization.'</comment>');
        } else {
            $output->writeln('Rendering image  <info>'.$image->hash.'</info> from <comment>'.$image->organization.'</comment> on stack <info>'.$stackName.'</info>');
        }

        $contents = $this->rokkaHelper->getSourceImageContents($client, $image->hash, $image->organization, $stackName, $format);
        if (!$contents) {
            $output->writeln($this->formatterHelper->formatBlock([
                'Error!',
                'Error getting image contents from Rokka.io!',
            ], 'error', true));

            return false;
        }

        // TODO: verify if target file exists, ask for permission to overwrite unless --force
        $ret = file_put_contents($saveTo, $contents, FILE_BINARY);
        if (false == $ret) {
            $output->writeln($this->formatterHelper->formatBlock([
                'Error!',
                'Error writing image contents to <info>'.$saveTo.'</info>!',
            ], 'error', true));

            return false;
        }

        $output->writeln('Image saved to <info>'.$saveTo.'</info>');

        return true;
    }
private function saveImageContents ( Image $ client , SourceImage $ image , $ saveTo , OutputInterface $ output , $ stackName = null , $ format = 'jpg' ) { if ( ! $ stackName ) { $ output -> writeln ( 'Getting source image contents for <info>' . $ image -> hash . '</info> from <comment>' . $ image -> organization . '</comment>' ) ; } else { $ output -> writeln ( 'Rendering image  <info>' . $ image -> hash . '</info> from <comment>' . $ image -> organization . '</comment> on stack <info>' . $ stackName . '</info>' ) ; } $ contents = $ this -> rokkaHelper -> getSourceImageContents ( $ client , $ image -> hash , $ image -> organization , $ stackName , $ format ) ; if ( ! $ contents ) { $ output -> writeln ( $ this -> formatterHelper -> formatBlock ( [ 'Error!' , 'Error getting image contents from Rokka.io!' , ] , 'error' , true ) ) ; return false ; } // TODO: verify if target file exists, ask for permission to overwrite unless --force $ ret = file_put_contents ( $ saveTo , $ contents , FILE_BINARY ) ; if ( false == $ ret ) { $ output -> writeln ( $ this -> formatterHelper -> formatBlock ( [ 'Error!' , 'Error writing image contents to <info>' . $ saveTo . '</info>!' , ] , 'error' , true ) ) ; return false ; } $ output -> writeln ( 'Image saved to <info>' . $ saveTo . '</info>' ) ; return true ; }
Downloads and saves an image from Rokka.

@param Image           $client    The Image client to use
@param SourceImage     $image     The image to download
@param string          $saveTo    The destination stream to save the image to
@param OutputInterface $output    The output interface to display messages
@param null            $stackName The stack name to use, leave empty to use the source image on Rokka
@param string          $format    The file format to retrieve the image if using a Stack

@return bool the status of the operation, True if the image has been saved correctly, false otherwise
Downloads and saves an image from Rokka .