save as jpeg
@param string $path
@return \PlaygroundCore\Service\Image
510588
public function save($path = null)
    {
        if (is_null($path)) {
            $path = $this->file;
        }
        imagejpeg($this->image, $path);
        return $this;
    }
924192
public function objectUrl($path)
    {
        if (URL::isValidUrl($path)) {
            return $path;
        }

        return Storage::disk(config('admin.upload.disk'))->url($path);
    }
551381
public function createVideoFromImages($path = 'data/etape*.jpg', $target = false, $framerate = '25', $fps = 25)
    {
        try {
            // don't want this service to be a singleton. I have to reset the ffmpeg parameters for each call.
            $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false);

            $this->serviceLocator->get('playgroundcore_phpvideotoolkit')
            ->addPreInputCommand('-y')
            ->addPreInputCommand('-framerate', $framerate)
            ->addPreInputCommand('-pattern_type', 'glob')
            ->addCommand('-i', $path)
            ->addCommand('-c:v', 'libx264')
            ->addCommand('-vf', 'fps='. $fps)
            ->addCommand('-pix_fmt', 'yuv420p')
            ->setOutputPath($target)
            ->execute();
        } catch (FfmpegProcessOutputException $e) {
            throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos');
        } catch (\PHPVideoToolkit\Exception $e) {
            throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos');
        }

        return $target;
    }
264099
private static function createFromFileByMime($path)
    {
        $mime = File::getMimeType($path);
        switch ($mime) {
            case 'image/jpeg':
                $img = imagecreatefromjpeg($path);
                break;
            case 'image/gif':
                $img = imagecreatefromgif($path);
                break;
            case 'image/png':
                $img = imagecreatefrompng($path);
                break;
            default:
                throw new \Exception('can`t create thumbnail: unknown image type');
        }

        if ( ! $img) {
            throw new \Exception('can`t create thumbnail: can`t create image handle from file ' . $path);
        }

        return $img;
    }
1042293
public function getImageFileAltProperties($path)
    {
        $properties = new FilePropertyEntityRepository;
        $properties->setWherePath($path);
        $properties->addWhereFieldIsLike('key', 'alt_', false);

        return $properties;
    }
879134
public function dumpFile($path)
    {
        $path = $this->resolve($path);

        return $this->dump($this->getFileContents($path), $path);
    }
1185155
static public function uploadUrl($path)
    {
        if (strpos($path, 'images') === 0) {
            return Config::getRootUrl($path);
        }
        
        return Config::getUploadFileUrl($path);
    }
1340148
protected function createFileEntity($path) {
    $uri = $this->fileUnmanagedCopy($path);
    $file = $this->entityTypeManager->getStorage('file')->create([
      'uri' => $uri,
      'status' => 1,
    ]);
    $file->save();
    $this->storeCreatedContentUuids([$file->uuid() => 'file']);
    return $file->id();
  }
1353704
public function image($path, array $options = [])
    {
        $options = optionsParser($options, ['alt' => pathinfo($path, PATHINFO_BASENAME)])
            ->append('class', 'img-fluid')
            ->tooltip();

        return parent::image($path, $options->toArray());
    }
1262301
public function saveImage(string $path, string $name, ?string $extension = null, int $quality = 100): self
    {
        $this->image->save($path, $name, $extension, $quality);
        return $this;
    }
1371225
protected function get_thumbnail($path) {
        $thumbnail_fullpath = $this->get_thumbnail_path($path);

        // generate thumbnail if it doesn't exist or caching is disabled
        if (!file_exists($thumbnail_fullpath) || $this->config['images']['thumbnail']['cache'] === false) {
            $this->createThumbnail($path, $thumbnail_fullpath);
        }

        return $thumbnail_fullpath;
    }
269984
public function initFromPath($path)
    {
        $core = new \Imagick;

        try {

            $core->setBackgroundColor(new \ImagickPixel('transparent'));
            $core->readImage($path);
            $core->setImageType(defined('\Imagick::IMGTYPE_TRUECOLORALPHA') ? \Imagick::IMGTYPE_TRUECOLORALPHA : \Imagick::IMGTYPE_TRUECOLORMATTE);

        } catch (\ImagickException $e) {
            throw new \Hail\Image\Exception\NotReadableException(
                "Unable to read image from path ({$path}).",
                0,
                $e
            );
        }

        // build image
        $image = $this->initFromImagick($core);
        $image->setFileInfoFromPath($path);

        return $image;
    }
221418
public function saveFile($path, $content)
    {
        $path = $this->cleanFolder($path);

        return $this->disk->put($path, $content, 'public');
    }
631871
public function download($path)
    {
        $this->setupRequest([
            'path' => $this->normalizePath($path),
        ]);

        $this->apiEndpoint = 'files/download';

        $this->content = null;

        $response = $this->doDropboxApiContentRequest();

        return StreamWrapper::getResource($response->getBody());
    }
78969
public function makeImage($path, array $params)
    {
        $sourcePath = $this->getSourcePath($path);
        $cachedPath = $this->getCachePath($path, $params);

        if ($this->cacheFileExists($path, $params) === true) {
            return $cachedPath;
        }

        if ($this->sourceFileExists($path) === false) {
            throw new FileNotFoundException(
                'Could not find the image `'.$sourcePath.'`.'
            );
        }

        $source = $this->source->read(
            $sourcePath
        );

        if ($source === false) {
            throw new FilesystemException(
                'Could not read the image `'.$sourcePath.'`.'
            );
        }

        // We need to write the image to the local disk before
        // doing any manipulations. This is because EXIF data
        // can only be read from an actual file.
        $tmp = tempnam(sys_get_temp_dir(), 'Glide');

        if (file_put_contents($tmp, $source) === false) {
            throw new FilesystemException(
                'Unable to write temp file for `'.$sourcePath.'`.'
            );
        }

        try {
            $write = $this->cache->write(
                $cachedPath,
                $this->api->run($tmp, $this->getAllParams($params))
            );

            if ($write === false) {
                throw new FilesystemException(
                    'Could not write the image `'.$cachedPath.'`.'
                );
            }
        } catch (FileExistsException $exception) {
            // This edge case occurs when the target already exists
            // because it's currently be written to disk in another
            // request. It's best to just fail silently.
        } finally {
            unlink($tmp);
        }

        return $cachedPath;
    }
812159
private function createImage($path) {
		$mime = $this->mimeType($path);
      
		if ($mime[2] == 'jpg') {
			return imagecreatefromjpeg ($path);
		} else if ($mime[2] == 'png') {
			return imagecreatefrompng ($path);
		} else {
			return false; 
		} 
    }
179669
public function write($path)
  {
    if ($this->srcImage->getExtension() == Image::IMAGE_TYPE_JPG) {
      imagejpeg($this->cuttedRessource, $path, $this->srcImage->getJpgQuality());
    } else if ($this->srcImage->getExtension() == Image::IMAGE_TYPE_PNG) {
      imagepng($this->cuttedRessource, $path, $this->srcImage->getPngCompression());
    } else {
      throw new \Exception('Impossible de générer l\'image : extension non supportée');
    }
  }