I am trying to receive and use an api from another site using php. How would I get the link?
https://assetgame.roblox.com/Asset/?id=942531508
this links downloads a file auto, but how would I save it using php (to a path on my site)?
And changing the file extention to .PNG?
file_put_contents("gh", "https://assetgame.roblox.com/Asset/?id=942531508");
you want to brother with gd library for converting if this is not a png
Related
I am trying to use a custom font in an image made with PHP GD.
I intend to call int imageloadfont(string $file), but I'm not sure what $file to give if I want to get a Google Font directly from their website.
Do I need to download the font or is there a way to get it remotely?
You can use the .ttf file from Google servers directly if you have allow_url_fopen enabled in your PHP installation. Look into the stylesheet to get the correct url.
However, for best performance, availability and security, you should download the file and use a local path.
I have installed imageMagick and imagick for php and I played with it a bit. I made some thumbnails of images etc.
What I want to do is to use it to make a thumbnail of image, which is located inside dropbox.
I wonder if this is possible.
Something like this:
$thumb = new Imagick($path);
$thumb->resizeImage(50,50,Imagick::FILTER_LANCZOS,1);
$thumb->writeImage('C:\pic.jpg');
Where the $path is the directory to the image located inside dropbox. I have used the Dropbox API to connect to dropbox and see all my files there but my question is how to get an absolute path which I can use in my object $thumb? Is this possible?
Thanks
Dimitris
You can pass a URL directly into ImageMagick, like this:
$thumb = new Imagick("http://skyscan.co.uk/la/79067.jpg");
$thumb->resizeImage(50,50,Imagick::FILTER_LANCZOS,1);
$thumb->writeImage('out.jpg');
If you are access the data over HTTP then there won't be a file system path for you to use. You'll need to use the API to get the file over HTTP and then either save it in a temporary location or pass the data directly to ImageMagick.
You could use a file path if you were accessing the files from your local disk and syncing them with the regular dropbox application in the background.
I'm using Filepicker.io to upload PDFs to my application. I have all those URLs and now I am trying to merge some of those PDFs using the PDF Tool Kit PHP library. It was not working for me so I ran some tests using the "file_exists" on PHP and it kept returning false.
I think this has to do with the fact that the URL does not have a ".pdf" extension at the end. This is what they look like: "https://www.filepicker.io/api/file/LCvbgpqEQLGwt8bfnqc1"
Does anyone know how I can pull the PDF using PHP in order to merge those files using the PDF Toolkit Library?
Thanks!
Alain F.
file_exists doesn't work with URLs, only with local files. Instead download the file to the temp dir using the copy command.
If the file can't be downloaded, the copy command will return false.
$exists = copy('https://www.filepicker.io/api/file/LCvbgpqEQLGwt8bfnqc1', '/tmp/example.pdf');
if (!$exists) throw new Exception("PDF could not be downloaded");
Use the downloaded file in the PDF Tool Kit.
EDIT: This does not solve this particular problem but does address the theory that it didn't work because "the URL does not have a ".pdf" extension at the end."
You can add things to the end of the filepicker URL with a trailing +
The following urls are equivalent:
https://www.filepicker.io/api/file/LCvbgpqEQLGwt8bfnqc1
https://www.filepicker.io/api/file/LCvbgpqEQLGwt8bfnqc1+name.pdf
our website has a certification image created by PHP GD, and I can print and watch it on a web page. But I couldn't make it a downloadable PDF file. Is there a way I can do that?
You can first save the image somewhere and then use the FPDF lib to write it in a PDF file
you could use imagick to do this..
the below command does the trick if your server is properly configured - Imagick is installed, GhostScript is installed, php is allowed to execute shell commands, etc
shell_exec('convert /path/to/input.png /path/to/output.pdf')
I have to make thumbnails from banners in swf file format (flash 9). I want to use php, but if that's not possible anything which work in a linux command line is fine by me.
I tried to open them with ffmpeg-php, but it says: Can't open movie file /where/the/file/is
The file is there and is readable by the user.
Any ideas?