Jump to content

Stop imagecreatefromjpeg Error From Being Thrown


unemployment

Recommended Posts

I'm in the process of converting images from external websites references to images stored in my amazon S3 account.  I'm running a script to do the conversion for the images I need, however the script continues to break with this error message:

E_WARNING: imagecreatefromjpeg(http://www.site.org/Ansichtskarten.images/I/AK04659a.jpg): failed to open stream: Connection timed out

Is there anyway I can have the script just continue running even if there is an error? Restarting the script is frustrating and counterproductive.

Script:

 

<?php
ini_set('memory_limit','2048M');
ini_set('max_execution_time', 30000000);
ini_set("user_agent", 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
ini_set('gd.jpeg_ignore_warning', 1);
$cron = true;
include('init.inc.php');

$query = 'SELECT * FROM city_images WHERE city_id > 0 ORDER BY city_id';
$city_images	= sql::q($query);
//var_dump($cities); die;

while ($row = sql::f_assoc($city_images)) {
	
	//var_dump($row);
	$city_id =  $row['city_id'];
	$image = image::resize_upload_amazon_new($row['image'], $row['city_id']);
	
	if(!is_array($image)){
		$sql = "INSERT INTO `city_images_new` (`city_id`, `image`)
				VALUES ('{$city_id}', '{$image}')";
			
		sql::q($sql);
	}
	//var_dump($image); die;
}
//die;
echo PHP_EOL . "Images converted succesfully"; die;

?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.