Connecting Tech Pros Worldwide Forums | Help | Site Map

ImageCreateFromJPEG() accepts horizontal images only??

jn
Guest
 
Posts: n/a
#1: Jul 17 '05
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?





jn
Guest
 
Posts: n/a
#2: Jul 17 '05

re: ImageCreateFromJPEG() accepts horizontal images only??


"jn" <jsumner1@cfl.rr.com> wrote in message
news:Aketb.16587$w66.310868@twister.tampabay.rr.co m...[color=blue]
> 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[/color]
larger[color=blue]
> than width) images, it fails to create a resource.
>
> What the hell is it doing?
>[/color]

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;
}



jn
Guest
 
Posts: n/a
#3: Jul 17 '05

re: ImageCreateFromJPEG() accepts horizontal images only??


"jn" <jsumner1@cfl.rr.com> wrote in message
news:yxetb.16588$w66.312913@twister.tampabay.rr.co m...[color=blue]
> "jn" <jsumner1@cfl.rr.com> wrote in message
> news:Aketb.16587$w66.310868@twister.tampabay.rr.co m...[color=green]
> > 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[/color]
> larger[color=green]
> > than width) images, it fails to create a resource.
> >
> > What the hell is it doing?
> >[/color]
>
> 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;
> }
>[/color]

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


Randell D.
Guest
 
Posts: n/a
#4: Jul 17 '05

re: ImageCreateFromJPEG() accepts horizontal images only??


jn wrote:[color=blue]
> "jn" <jsumner1@cfl.rr.com> wrote in message
> news:yxetb.16588$w66.312913@twister.tampabay.rr.co m...
>[color=green]
>>"jn" <jsumner1@cfl.rr.com> wrote in message
>>news:Aketb.16587$w66.310868@twister.tampabay.rr. com...
>>[color=darkred]
>>>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[/color]
>>
>>larger
>>[color=darkred]
>>>than width) images, it fails to create a resource.
>>>
>>>What the hell is it doing?
>>>[/color]
>>
>>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;
>>}
>>[/color]
>
>
> PHP is telling me that they aren't valid JPEGs...that's the problem. :(
>
>[/color]

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
jn
Guest
 
Posts: n/a
#5: Jul 17 '05

re: ImageCreateFromJPEG() accepts horizontal images only??


"Randell D." <please.post.and.share@news.group.com> wrote in message
news:0sYtb.406842$6C4.166786@pd7tw1no...[color=blue]
> jn wrote:[color=green]
> > "jn" <jsumner1@cfl.rr.com> wrote in message
> > news:yxetb.16588$w66.312913@twister.tampabay.rr.co m...
> >[color=darkred]
> >>"jn" <jsumner1@cfl.rr.com> wrote in message
> >>news:Aketb.16587$w66.310868@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;
> >>}
> >>[/color]
> >
> >
> > PHP is telling me that they aren't valid JPEGs...that's the problem. :(
> >
> >[/color]
>
> 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[/color]

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.


Closed Thread