Solved

imagecreatefromjpeg failed to open stream error

Posted on 2013-06-26
7
738 Views
Last Modified: 2013-11-16
I am trying to use the imagecreatefromjpeg function to load an image from a url. The image exists and I can get it using the url through the browser, but when I try to load it using tthe function, I get the following error:

PHP Warning:  imagecreatefromjpeg(http://m-test.cabotstain.com/system/galleries/pics/cabot_color-swatches/ss_indian_corn_728x728.jpg): failed to open stream: Operation now in progress in /opt/hpws22/apache-php/htdocs/m-test.cabotstain/paint-chip.php

The following is my core configuration:

PHP Version      5.4.7

Directive      Local Value      Master Value
allow_url_fopen      On      On
allow_url_include      On      On
always_populate_raw_post_data      Off      Off
arg_separator.input      &      &
arg_separator.output      &      &
asp_tags      Off      Off
auto_append_file      no value      no value
auto_globals_jit      On      On
auto_prepend_file      no value      no value
browscap      no value      no value
default_charset      no value      no value
default_mimetype      text/html      text/html
disable_classes      no value      no value
disable_functions      no value      no value
display_errors      On      On
display_startup_errors      Off      Off
doc_root      no value      no value
docref_ext      no value      no value
docref_root      no value      no value
enable_dl      Off      Off
enable_post_data_reading      On      On
error_append_string      no value      no value
error_prepend_string      no value      no value
error_reporting      32759      32759
exit_on_timeout      Off      Off
expose_php      On      On
file_uploads      On      On
highlight.comment      #FF8000      #FF8000
highlight.default      #0000BB      #0000BB
highlight.html      #000000      #000000
highlight.keyword      #007700      #007700
highlight.string      #DD0000      #DD0000
html_errors      On      On
ignore_repeated_errors      Off      Off
ignore_repeated_source      Off      Off
ignore_user_abort      Off      Off
implicit_flush      Off      Off
include_path      .:/opt/php54/php/lib/php      .:/opt/php54/php/lib/php
log_errors      On      On
log_errors_max_len      1024      1024
mail.add_x_header      Off      Off
mail.force_extra_parameters      no value      no value
mail.log      no value      no value
max_execution_time      30      30
max_file_uploads      20      20
max_input_nesting_level      64      64
max_input_time      60      60
max_input_vars      1000      1000
memory_limit      128M      128M
open_basedir      no value      no value
output_buffering      no value      no value
output_handler      no value      no value
post_max_size      8M      8M
precision      12      12
realpath_cache_size      16K      16K
realpath_cache_ttl      120      120
register_argc_argv      On      On
report_memleaks      On      On
report_zend_debug      On      On
request_order      no value      no value
sendmail_from      no value      no value
sendmail_path      /usr/sbin/sendmail -t -i       /usr/sbin/sendmail -t -i
serialize_precision      100      100
short_open_tag      On      On
smtp_port      25      25
sql.safe_mode      Off      Off
track_errors      Off      Off
unserialize_callback_func      no value      no value
upload_max_filesize      2M      2M
upload_tmp_dir      no value      no value
user_dir      no value      no value
user_ini.cache_ttl      300      300
user_ini.filename      .user.ini      .user.ini
variables_order      EGPCS      EGPCS
xmlrpc_error_number      0      0
xmlrpc_errors      Off      Off
zend.detect_unicode      On      On
zend.enable_gc      On      On
zend.multibyte      Off      Off
zend.script_encoding      no value      no value
0
Comment
Question by:Jorge Fraser
  • 3
  • 2
  • 2
7 Comments
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39278515
Try wrapping the URL in quotes:

$myImage = imagecreatefromjpeg("http://m-test.cabotstain.com/system/galleries/pics/cabot_color-swatches/ss_indian_corn_728x728.jpg");

Open in new window

0
 
LVL 1

Author Comment

by:Jorge Fraser
ID: 39278595
The url actually come in in a variable. Here's the snippet:

$color_img = imagecreatefromjpg($color->images[0]->url);
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39278637
NTF, DNF*
http://www.laprbass.com/RAY_temp_pcroadkill.php

<?php // RAY_temp_pcroadkill.php
error_reporting(E_ALL);

$url = 'http://m-test.cabotstain.com/system/galleries/pics/cabot_color-swatches/ss_indian_corn_728x728.jpg';
$img = imageCreateFromJPEG($url);
header('Content-type: image/jpg');
imageJPEG($img);

Open in new window

* No Trouble Found, Did Not Fail
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39278654
I concur - my tests also worked fine :)
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39278692
Try this to be sure your script has the right value in the variables.

var_dump($color->images[0]->url);

Also, is this image on your server or another server (access via fully qualified URL)?  The answer here is interesting...
http://stackoverflow.com/questions/6220125/what-does-the-error-message-operation-now-in-progress-mean
0
 
LVL 1

Accepted Solution

by:
Jorge Fraser earned 0 total points
ID: 39639391
Had to do with our infrastructure setting. OS params tweaked.
0
 
LVL 1

Author Closing Comment

by:Jorge Fraser
ID: 39653026
Own
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now