0

I need some help. I'm very new to cURL. I got a script working that would create a feed from a wordpress blog (with magpie XML parser). I also got an image resize script to resize the images for me. It works locally but because my web hosting has allow_url_fopen() disabled I've been told I need to use cURL but I can't get anything to work.

Here's the code BEFORE I tried to get cURL working:

<?php $url = $_GET['imagesrc']; // Set a maximum height and width $width = 200; $height = 200; // Content type // Get new dimensions list($width_orig, $height_orig) = getimagesize($url); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($url); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output header('Content-Type: image/jpeg'); return(imagejpeg($image_p, null, 100)); ?> 

1 Answer 1

0

Download image file to local machine and then use it in imagecreatefromjpeg($filePointer);. Code to download file is as follows.

/** * Initialize the cURL session */ $ch = curl_init(); /** * Set the URL of the page or file to download. */ curl_setopt($ch, CURLOPT_URL, ‘your_URL’); /** * Create a new file */ $fp = fopen(‘img.jpg’, ‘w’); /** * Ask cURL to write the contents to a file */ curl_setopt($ch, CURLOPT_FILE, $fp); /** * Execute the cURL session */ curl_exec ($ch); /** * Close cURL session and file */ curl_close ($ch); fclose($fp); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.