Asked  7 Months ago    Answers:  5   Viewed   23 times

Possible Duplicate:
Saving image from PHP URL

I have an image as a url link from the 3rd party web thumb site (IE What I would like to do is run a script that takes the image and saves it in a directory on my server using php. How to do this? would I use File Write?



No need to create a GD resource, as someone else suggested.

$input = '';
$output = '';
file_put_contents($output, file_get_contents($input));

Note: this solution only works if you're setup to allow fopen access to URLs. If the solution above doesn't work, you'll have to use cURL.

Wednesday, March 31, 2021
answered 7 Months ago

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario:

Related usability ticket:

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
answered 7 Months ago

To save the image to a file, you can use any of these: imagejpeg(), imagepng(), or imagegif(), depending on your desired output format.

To detect the image type, you can just check the file's extension and base yourself on that. However, sometimes people manually change the extension of an image file, thinking that actually changes the image type, so it's always a good idea to check whether imagecreatefrom returned an image resource rather than false.

For a quick way to return just the extension of a file:

$ext = pathinfo($path_to_file, PATHINFO_EXTENSION);

Manual entry on pathinfo()

Wednesday, March 31, 2021
answered 7 Months ago

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
answered 5 Months ago

in c# us the Image.Save Method with these parameters (string Filename , ImageFormat)

Is that all you needed?

// Construct a bitmap from the button image resource.
Bitmap bmp1 = new Bitmap(typeof(Button), "Button.bmp");

// Save the image as a GIF.
bmp1.Save("c:\button.gif", System.Drawing.Imaging.ImageFormat.Gif);
Tuesday, August 3, 2021
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :