By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,870 Members | 2,484 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,870 IT Pros & Developers. It's quick & easy.

ImageCreateFromJPEG() accepts horizontal images only??

P: n/a
jn
I'm working with images from a Kodak 2MP camera.

It looks like the function will only create a resource if I give it
horiznotal pictures from this camera....if I give it vertical (height larger
than width) images, it fails to create a resource.

What the hell is it doing?
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
jn
"jn" <js******@cfl.rr.com> wrote in message
news:Ak********************@twister.tampabay.rr.co m...
I'm working with images from a Kodak 2MP camera.

It looks like the function will only create a resource if I give it
horiznotal pictures from this camera....if I give it vertical (height larger than width) images, it fails to create a resource.

What the hell is it doing?


It works on all the images on my Windows machine, but only works on
horizontal ones when it runs on the Linux server.

Here's the function:

function resize ($filename, $destination, $size, $quality) {
$origImage = imagecreatefromjpeg($filename);
$origWidth = imagesx($origImage);
$origHeight = imagesy($origImage);
$factor = $origHeight/$origWidth;
$newWidth = $size;
$newHeight = $size * $factor;
$newImage = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($newImage, $origImage, 0, 0, 0, 0, $newWidth,
$newHeight, $origWidth, $origHeight);
imagejpeg($newImage, $destination);
return $newHeight;
}

Jul 17 '05 #2

P: n/a
jn
"jn" <js******@cfl.rr.com> wrote in message
news:yx********************@twister.tampabay.rr.co m...
"jn" <js******@cfl.rr.com> wrote in message
news:Ak********************@twister.tampabay.rr.co m...
I'm working with images from a Kodak 2MP camera.

It looks like the function will only create a resource if I give it
horiznotal pictures from this camera....if I give it vertical (height

larger
than width) images, it fails to create a resource.

What the hell is it doing?


It works on all the images on my Windows machine, but only works on
horizontal ones when it runs on the Linux server.

Here's the function:

function resize ($filename, $destination, $size, $quality) {
$origImage = imagecreatefromjpeg($filename);
$origWidth = imagesx($origImage);
$origHeight = imagesy($origImage);
$factor = $origHeight/$origWidth;
$newWidth = $size;
$newHeight = $size * $factor;
$newImage = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($newImage, $origImage, 0, 0, 0, 0, $newWidth,
$newHeight, $origWidth, $origHeight);
imagejpeg($newImage, $destination);
return $newHeight;
}


PHP is telling me that they aren't valid JPEGs...that's the problem. :(
Jul 17 '05 #3

P: n/a
jn wrote:
"jn" <js******@cfl.rr.com> wrote in message
news:yx********************@twister.tampabay.rr.co m...
"jn" <js******@cfl.rr.com> wrote in message
news:Ak********************@twister.tampabay.rr. com...
I'm working with images from a Kodak 2MP camera.

It looks like the function will only create a resource if I give it
horiznotal pictures from this camera....if I give it vertical (height


larger
than width) images, it fails to create a resource.

What the hell is it doing?


It works on all the images on my Windows machine, but only works on
horizontal ones when it runs on the Linux server.

Here's the function:

function resize ($filename, $destination, $size, $quality) {
$origImage = imagecreatefromjpeg($filename);
$origWidth = imagesx($origImage);
$origHeight = imagesy($origImage);
$factor = $origHeight/$origWidth;
$newWidth = $size;
$newHeight = $size * $factor;
$newImage = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($newImage, $origImage, 0, 0, 0, 0, $newWidth,
$newHeight, $origWidth, $origHeight);
imagejpeg($newImage, $destination);
return $newHeight;
}

PHP is telling me that they aren't valid JPEGs...that's the problem. :(


The reason why PHP is telling you that they are not valid JPEGs I
believe has to do with thumbnails - I believe (perhaps someone in this
newsgroup will know otherwise) that jpegs can contain a small thumbnail
in the same file as the full-sized image. I think its a standard... and
I believe some digital cameras break this standard in order to create
smaller file types... I have a Sony Mavica camera that creates images on
to a floppy diskette that I bought in 19977 and it wworks fine so I know
not all camera's will give you the problem.

Since I have yet to encounter the problem, I've not been able to test a
work around - but one idea I had was to resave the image using the
gd-library and then see if I could manipulate it...

I don't know if it would owrk... in addition... I think I'll recognise
the problem if I encounter problems with width like you had.

I hope the above is some help...

laters
randelld
Jul 17 '05 #4

P: n/a
jn
"Randell D." <pl*******************@news.group.com> wrote in message
news:0sYtb.406842$6C4.166786@pd7tw1no...
jn wrote:
"jn" <js******@cfl.rr.com> wrote in message
news:yx********************@twister.tampabay.rr.co m...
"jn" <js******@cfl.rr.com> wrote in message
news:Ak********************@twister.tampabay.rr. com...

I'm working with images from a Kodak 2MP camera.

It looks like the function will only create a resource if I give it
horiznotal pictures from this camera....if I give it vertical (height

larger

than width) images, it fails to create a resource.

What the hell is it doing?
It works on all the images on my Windows machine, but only works on
horizontal ones when it runs on the Linux server.

Here's the function:

function resize ($filename, $destination, $size, $quality) {
$origImage = imagecreatefromjpeg($filename);
$origWidth = imagesx($origImage);
$origHeight = imagesy($origImage);
$factor = $origHeight/$origWidth;
$newWidth = $size;
$newHeight = $size * $factor;
$newImage = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($newImage, $origImage, 0, 0, 0, 0, $newWidth,
$newHeight, $origWidth, $origHeight);
imagejpeg($newImage, $destination);
return $newHeight;
}

PHP is telling me that they aren't valid JPEGs...that's the problem. :(


The reason why PHP is telling you that they are not valid JPEGs I
believe has to do with thumbnails - I believe (perhaps someone in this
newsgroup will know otherwise) that jpegs can contain a small thumbnail
in the same file as the full-sized image. I think its a standard... and
I believe some digital cameras break this standard in order to create
smaller file types... I have a Sony Mavica camera that creates images on
to a floppy diskette that I bought in 19977 and it wworks fine so I know
not all camera's will give you the problem.

Since I have yet to encounter the problem, I've not been able to test a
work around - but one idea I had was to resave the image using the
gd-library and then see if I could manipulate it...

I don't know if it would owrk... in addition... I think I'll recognise
the problem if I encounter problems with width like you had.

I hope the above is some help...

laters
randelld


I tried resaving the image in Photoshop, and it still wouldn't work. And I'm
not sure how I would get GD to resave it without using ImageCreateFromJPEG()
anyway.

I'm now trying to get ImageMagick to work on my server so I don't have to
worry about GD. Thanks for the help though.
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.