469,336 Members | 5,643 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

imagecreatefromjpeg not working

hopefully this is an easy one to solve and I'm just missing something
little...

basically, I had a nice little website running with php, apache,
etc... that uses imagecreatefromjpeg to create thumbnails of larger
pictures.

recently, I upgraded my system from suse 8.2 to suse 9.0, so I assume
my php/apache rpms were upgraded in the process...

Unfortunately, now, imagecreatefromjpeg no longer works on pictures
taken with 1 of my 2 cameras - All of the ones with a Sony p30 work
just fine, whereas if I run the function on pictures taken with a
cannon powershot s400, execution of the PHP script stops. Nothing in
the logs, nothing output to the screen, etc...

Here is a snippet of code that I use:
$size = getimagesize($picturePath);

$width = $size[0] * $x / 100;
$height = $size[1] * $y / 100;
$im = @imagecreatefromjpeg($picturePath);
$newim = imagecreatetruecolor($width,$height);
ImageCopyResized($newim,$im,0,0,0,0,$width,$height ,ImageSX($im),ImageSY($im));

If I put an echo right before and right after the
$im=@imagecreatefromjpeg line, the first echo prints out, the second
does not - so php stops parsing, executing the document.

Again, this worked in the past, and I can't figure out why it wouldn't
now. Here is some info from my setup:

php 4.3.3

'./configure' '--prefix=/usr/share' '--datadir=/usr/share/php'
'--bindir=/usr/bin' '--libdir=/usr/share' '--includedir=/usr/include'
'--sysconfdir=/etc' '--with-_lib=lib' '--with-config-file-path=/etc'
'--with-exec-dir=/usr/lib/php/bin' '--disable-debug' '--enable-bcmath'
'--enable-calendar' '--enable-ctype' '--enable-dbase'
'--enable-discard-path' '--enable-exif' '--enable-filepro'
'--enable-force-cgi-redirect' '--enable-ftp' '--enable-gd-imgstrttf'
'--enable-gd-native-ttf' '--enable-inline-optimization'
'--enable-magic-quotes' '--enable-mbstr-enc-trans' '--enable-mbstring'
'--enable-mbregex' '--enable-memory-limit' '--enable-safe-mode'
'--enable-shmop' '--enable-sigchild' '--enable-sysvsem'
'--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid'
'--enable-versioning' '--enable-wddx' '--enable-yp' '--with-bz2'
'--with-dom=/usr/include/libxml2' '--with-ftp' '--with-gdbm'
'--with-gettext' '--with-gmp' '--with-imap=yes' '--with-iodbc'
'--with-jpeg-dir=/usr' '--with-ldap=yes' '--with-mcal=/usr'
'--with-mcrypt' '--with-mhash' '--with-mysql=/usr' '--with-ndbm'
'--with-pgsql=/usr' '--with-png-dir=/usr' '--with-readline'
'--with-snmp' '--with-t1lib' '--with-tiff-dir=/usr' '--with-ttf'
'--with-freetype-dir=yes' '--with-xml' '--with-xpm-dir=/usr/X11R6'
'--with-zlib=yes' '--with-qtdom=/usr/lib/qt3' '--with-gd'
'--with-openssl' '--with-curl'
'--with-swf=/usr/src/packages/BUILD/swf/dist/' '--with-imap-ssl'
'--enable-xslt' '--with-xslt-sablot' '--with-iconv' '--with-mm'
'--with-apxs=/usr/sbin/apxs' 'i586-suse-linux'

GD Support enabled
GD Version bundled (2.0.15 compatible)
FreeType Support enabled
FreeType Linkage with freetype
T1Lib Support enabled
GIF Read Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

Any help would be amazing - I've been banging my head on this for
hours.

Thanks,
mike.
Jul 17 '05 #1
4 21089
One thought: Are the two files you're trying the same size? If one is
significantly larger, it could either a) be larger than POST_MAX_FILE_SIZE
or whatever it is in php.ini or b) it could be large enough that it will
cause the script to timeout.

Mike wrote:
hopefully this is an easy one to solve and I'm just missing something
little...

basically, I had a nice little website running with php, apache,
etc... that uses imagecreatefromjpeg to create thumbnails of larger
pictures.

recently, I upgraded my system from suse 8.2 to suse 9.0, so I assume
my php/apache rpms were upgraded in the process...

Unfortunately, now, imagecreatefromjpeg no longer works on pictures
taken with 1 of my 2 cameras - All of the ones with a Sony p30 work
just fine, whereas if I run the function on pictures taken with a
cannon powershot s400, execution of the PHP script stops. Nothing in
the logs, nothing output to the screen, etc...

<snip>
Jul 17 '05 #2
Its a thought, but I'm pretty sure it isn't correct for 2 reasons:

1) The script always worked relatively quickly in the past - it takes
about 10-15 seconds to process 30 pictures... and the script is dying
in about .5 seconds now...

2) I'm not posting pictures - the php page is actually iterating over
files in a directory that I choose, so it wouldn't hit the
post_max_file_size.

thanks though.
mike.

"Agelmar" <if**********@comcast.net> wrote in message news:<bt************@ID-30799.news.uni-berlin.de>...
One thought: Are the two files you're trying the same size? If one is
significantly larger, it could either a) be larger than POST_MAX_FILE_SIZE
or whatever it is in php.ini or b) it could be large enough that it will
cause the script to timeout.

Mike wrote:
hopefully this is an easy one to solve and I'm just missing something
little...

basically, I had a nice little website running with php, apache,
etc... that uses imagecreatefromjpeg to create thumbnails of larger
pictures.

recently, I upgraded my system from suse 8.2 to suse 9.0, so I assume
my php/apache rpms were upgraded in the process...

Unfortunately, now, imagecreatefromjpeg no longer works on pictures
taken with 1 of my 2 cameras - All of the ones with a Sony p30 work
just fine, whereas if I run the function on pictures taken with a
cannon powershot s400, execution of the PHP script stops. Nothing in
the logs, nothing output to the screen, etc...

<snip>

Jul 17 '05 #3
Hmm... have you tried writing a separate script that just tries to open one
of the "evil" jpeg files, and on that one, don't shove an @ in front of
imagecreatefromjpeg() (so you can see what the error message is)?
Mike wrote:
Its a thought, but I'm pretty sure it isn't correct for 2 reasons:

1) The script always worked relatively quickly in the past - it takes
about 10-15 seconds to process 30 pictures... and the script is dying
in about .5 seconds now...

2) I'm not posting pictures - the php page is actually iterating over
files in a directory that I choose, so it wouldn't hit the
post_max_file_size.

thanks though.
mike.

"Agelmar" <if**********@comcast.net> wrote in message
news:<bt************@ID-30799.news.uni-berlin.de>...
One thought: Are the two files you're trying the same size? If one is
significantly larger, it could either a) be larger than
POST_MAX_FILE_SIZE
or whatever it is in php.ini or b) it could be large enough that it
will
cause the script to timeout.

Mike wrote:
hopefully this is an easy one to solve and I'm just missing
something
little...

basically, I had a nice little website running with php, apache,
etc... that uses imagecreatefromjpeg to create thumbnails of larger
pictures.

recently, I upgraded my system from suse 8.2 to suse 9.0, so I
assume
my php/apache rpms were upgraded in the process...

Unfortunately, now, imagecreatefromjpeg no longer works on pictures
taken with 1 of my 2 cameras - All of the ones with a Sony p30 work
just fine, whereas if I run the function on pictures taken with a
cannon powershot s400, execution of the PHP script stops. Nothing
in
the logs, nothing output to the screen, etc...

<snip>

Jul 17 '05 #4
Thank you - a brilliant idea... when I did that and and printed out
the return value from imagecreatefromjpeg(), I got the following:

Fatal error: Allowed memory size of 8388608 bytes exhausted at
(null):0 (tried to allocate 9088 bytes) in...

So I went to my php.ini file and upped the max memory and now
everything works great. That also explains why my old camera (1.3
megapixels) worked and my new one (4 megapixels) didn't.

thanks again,
mike.

"Agelmar" <if**********@comcast.net> wrote in message news:<bt************@ID-30799.news.uni-berlin.de>...
Hmm... have you tried writing a separate script that just tries to open one
of the "evil" jpeg files, and on that one, don't shove an @ in front of
imagecreatefromjpeg() (so you can see what the error message is)?
Mike wrote:
Its a thought, but I'm pretty sure it isn't correct for 2 reasons:

1) The script always worked relatively quickly in the past - it takes
about 10-15 seconds to process 30 pictures... and the script is dying
in about .5 seconds now...

2) I'm not posting pictures - the php page is actually iterating over
files in a directory that I choose, so it wouldn't hit the
post_max_file_size.

thanks though.
mike.

"Agelmar" <if**********@comcast.net> wrote in message
news:<bt************@ID-30799.news.uni-berlin.de>...
One thought: Are the two files you're trying the same size? If one is
significantly larger, it could either a) be larger than
POST_MAX_FILE_SIZE
or whatever it is in php.ini or b) it could be large enough that it
will
cause the script to timeout.

Mike wrote:
hopefully this is an easy one to solve and I'm just missing
something
little...

basically, I had a nice little website running with php, apache,
etc... that uses imagecreatefromjpeg to create thumbnails of larger
pictures.

recently, I upgraded my system from suse 8.2 to suse 9.0, so I
assume
my php/apache rpms were upgraded in the process...

Unfortunately, now, imagecreatefromjpeg no longer works on pictures
taken with 1 of my 2 cameras - All of the ones with a Sony p30 work
just fine, whereas if I run the function on pictures taken with a
cannon powershot s400, execution of the PHP script stops. Nothing
in
the logs, nothing output to the screen, etc...
<snip>

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Simon Stewart | last post: by
1 post views Thread by Olivier | last post: by
5 posts views Thread by steve park | last post: by
6 posts views Thread by comp.lang.php | last post: by
5 posts views Thread by Areric | last post: by
4 posts views Thread by jeffsnox | last post: by
1 post views Thread by tim.landgraf | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.