Issue
I´m currently using Imagemagick on a shared hosted Webspace. Imagemagick is also installed on this webspace. Its versionString is ImageMagick 6.8.9-9 Q16 x86_64 2018-06-26
and its versionNumber is 1673
.
Now my Question or problem:
I want to convert a REMOTE FILE
for example https://www.google.com/favicon.ico to a png image to use it afterwards. To achieve this I´m currently using this PHP Script:
<?php
exec( "/usr/bin/convert convert https://www.google.com/favicon.ico favicon.png" );
?>
But this command doesn´t create the file favicon.png
in the same folder. But if I download the favicon.ico file and store it on the server I can use this command and it works perfectly:
<?php
exec( "/usr/bin/convert convert favicon.ico favicon.png" );
?>
So how can I use a remote file with the convert command in imagemagick without storing the file on my server? I also tried to create a new Image Object with $Imagick->getImageBlob();
-> https://secure.php.net/manual/de/imagick.getimageblob.php and inserted the output into the exec(); command like this
<?php
exec( "/usr/bin/convert convert " . $Imagick->getImageBlob() . "favicon.png" );
?>
in PHP. But it only showed the error that this Command could be an attack.
I hope you can help me to solve this problem and thanks in advance!
PS: I can not edit anything in the Imagemagick settings or update the class/package either.
Solution
wget -O- https://www.google.com/favicon.ico | convert ico:- favicon.jpg
Explanation: You should download the file with the "wget" and output into a standard output then pipe it to "convert". "ico:-" - this means input file type "image/ico" and take it from stdin.
Or just use:
$imagick = new Imagick();
$imagick->readImageBlob("https://www.google.com/favicon.ico");
$image->writeImage('favicon.png');
Answered By - Nikolai Answer Checked By - Candace Johnson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.