asotshia
asotshia

Reputation: 121

How can I save this php created image?

What are some possible ways to save an image or make use of it that is generated from a PHP script. Using save as it does not help though.
This is not an image created by me that's why I want to avoid get_contents.

here is the picture

and here is the url

https://render01.fontshop.com/fonts/font_rend.php?idt=f&id=38005&rbe=fsifr&rt=how+do+I+save+this?&rs=38&w=500&bg=ffffff&fg=000000&tp=0.0

Upvotes: 1

Views: 2450

Answers (7)

Rohit
Rohit

Reputation: 401

use imagepng function.

It will return file to browser or save it specified location. Need to set parameter for function to save image on specified location.

Upvotes: 0

AllInOne
AllInOne

Reputation: 1450

You can do this from the terminal using the curl command.

curl -o out.png 'http://render01.fontshop.com/fonts/font_rend.php?idt=f&id=38005&rbe=fsifr&rt=how+do+I+save+this?&rs=38&w=500&bg=ffffff&fg=000000&tp=0.0'

This will save the file as out.png

Upvotes: 0

Roman
Roman

Reputation: 6458

I understand you want to save it on the client, with a browser, not on the server.

"Save as" worked fine for me (Firefox 7). In Chrome you'll have to specify the extension of the filename manually. Did not test other browsers, but it should work similarly

Upvotes: 0

Jon
Jon

Reputation: 437774

Since you are not generating the image in your own code, the simplest would be a combo of file_get_contents and file_put_contents:

$url = '...'; // your url here
$data = file_get_conents($url);
file_put_conents('image.png', $data);

In this specific case the render is a PNG image, but if there's a possibility of it being a JPEG or something else then you need to somehow detect that as well. I 'm not giving any suggestions for this because there's not enough info to go by.

Upvotes: 1

gustavotkg
gustavotkg

Reputation: 4399

Just write the content of the URL to a file

<?php
file_put_contents("img.png", file_get_contents("http://render01.fontshop.com/fonts/font_rend.php?idt=f&id=38005&rbe=fsifr&rt=how+do+I+save+this?&rs=38&w=500&bg=ffffff&fg=000000&tp=0.0"));

Upvotes: 1

Till Helge
Till Helge

Reputation: 9311

You can define a filename in imgpng() or the other functions to tell PHP to store the picture instead of sending it to the calling browser.

Upvotes: 0

Riz
Riz

Reputation: 10246

Using file_put_contents() function. If you don't have data in variable and want to readout use file_get_contents()

Upvotes: 1

Related Questions