-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open image from an external URL #170
Comments
I agree, needing this too |
This would be outside scope of this library imo. Just use |
To download a file, you should use a proper library instead of using just I would suggest to create a class like: class DownloadAndDoStuff {
private function _download(string $remote_image_url, string $local_path = null) {
if(null === $local_path ) {
$local_path = dirname(__DIR__);
}
$file = curl_file_create($local_path);
$curl = new anlutro\cURL\cURL;
$response = $curl->rawPost($remote_image_url, ['file' => $file]);
return $local_path;
}
public function resizeImage(string $remote_image_url) {
if(!isset($this->remoteFiles[$remote_image_url])) {
$this->remoteFiles[$remote_image_url] = $this->_download($remote_image_url);
}
// File should be here: $this->remoteFiles[$remote_image_url] do whatever you want
}
public function cropImage(string $remote_image_url) {
if(!isset($this->remoteFiles[$remote_image_url])) {
$this->remoteFiles[$remote_image_url] = $this->_download($remote_image_url);
}
// File should be here: $this->remoteFiles[$remote_image_url] do whatever you want
}
public function flipImage(string $remote_image_url) {
if(!isset($this->remoteFiles[$remote_image_url])) {
$this->remoteFiles[$remote_image_url] = $this->_download($remote_image_url);
}
// File should be here: $this->remoteFiles[$remote_image_url] do whatever you want
}
} see https://github.com/anlutro/php-curl for more |
Is it possible to open an image from an external source, e.g. an API and then resize it.
The text was updated successfully, but these errors were encountered: