Connecting Tech Pros Worldwide Forums | Help | Site Map

imagecopyresampled() Help Needed

ralphNOSPAM@primemail.com
Guest
 
Posts: n/a
#1: Sep 27 '05
When I execute this script, nothing displays on my browser. I'm trying
to verify my image is being reduced by 50% before I try to write it to
a file:

// The file
$filename = "/home/public_html/radar2.jpg";
$percent = 0.5;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);
// Output
imagejpeg($image_p, null, 100);


Janwillem Borleffs
Guest
 
Posts: n/a
#2: Sep 27 '05

re: imagecopyresampled() Help Needed


Janwillem Borleffs wrote:[color=blue]
> header("Content-Type: image/jpeg");
> imagejpeg($image_p, null, 100);
>[/color]

That should be:

header("Content-Type: image/jpeg");
imagejpeg($image_p, '', 100);


JW



Janwillem Borleffs
Guest
 
Posts: n/a
#3: Sep 27 '05

re: imagecopyresampled() Help Needed


ralphNOSPAM@primemail.com wrote:[color=blue]
> When I execute this script, nothing displays on my browser. I'm trying
> to verify my image is being reduced by 50% before I try to write it to
> a file:
>[/color]

Two things you can try:

1. Use an empty string as the second parameter (as the manual suggests):

imagejpeg($image_p, '', 100);

2. Send a Content-Type header (combined with suggestion #1):

header("Content-Type: image/jpeg");
imagejpeg($image_p, null, 100);


JW



Tom Scales
Guest
 
Posts: n/a
#4: Sep 27 '05

re: imagecopyresampled() Help Needed



"Janwillem Borleffs" <jw@jwscripts.com> wrote in message
news:43399eff$0$97550$dbd4d001@news.euronet.nl...[color=blue]
> Janwillem Borleffs wrote:[color=green]
>> header("Content-Type: image/jpeg");
>> imagejpeg($image_p, null, 100);
>>[/color]
>
> That should be:
>
> header("Content-Type: image/jpeg");
> imagejpeg($image_p, '', 100);
>
>
> JW
>
>
>[/color]

I just use:

imagejpeg($image_p);

For a browser, there is no need to specify quality. Just let it default.
100 is overkill for a browser anyway.

Tom


chotiwallah
Guest
 
Posts: n/a
#5: Sep 28 '05

re: imagecopyresampled() Help Needed



Tom Scales wrote:[color=blue]
> "Janwillem Borleffs" <jw@jwscripts.com> wrote in message
> news:43399eff$0$97550$dbd4d001@news.euronet.nl...[color=green]
> > Janwillem Borleffs wrote:[color=darkred]
> >> header("Content-Type: image/jpeg");
> >> imagejpeg($image_p, null, 100);
> >>[/color]
> >
> > That should be:
> >
> > header("Content-Type: image/jpeg");
> > imagejpeg($image_p, '', 100);
> >
> >
> > JW
> >
> >
> >[/color]
>
> I just use:
>
> imagejpeg($image_p);
>
> For a browser, there is no need to specify quality. Just let it default.
> 100 is overkill for a browser anyway.
>
> Tom[/color]

another tought: how big are your images? php runs out of memory pretty
quickly if you use truecolor images.

micha

ralphNOSPAM@primemail.com
Guest
 
Posts: n/a
#6: Sep 28 '05

re: imagecopyresampled() Help Needed


On 28 Sep 2005 00:58:43 -0700, "chotiwallah" <chotiwallah@web.de>
wrote:
[color=blue]
>
>Tom Scales wrote:[color=green]
>> "Janwillem Borleffs" <jw@jwscripts.com> wrote in message
>> news:43399eff$0$97550$dbd4d001@news.euronet.nl...[color=darkred]
>> > Janwillem Borleffs wrote:
>> >> header("Content-Type: image/jpeg");
>> >> imagejpeg($image_p, null, 100);
>> >>
>> >
>> > That should be:
>> >
>> > header("Content-Type: image/jpeg");
>> > imagejpeg($image_p, '', 100);
>> >
>> >
>> > JW
>> >
>> >
>> >[/color]
>>
>> I just use:
>>
>> imagejpeg($image_p);
>>
>> For a browser, there is no need to specify quality. Just let it default.
>> 100 is overkill for a browser anyway.
>>
>> Tom[/color]
>
>another tought: how big are your images? php runs out of memory pretty
>quickly if you use truecolor images.
>
>micha[/color]


The files are 25k to 50k so they are not that big. I came across a
class php script called ImageEditor.php and it works great at resizing
images as well as having many other features - so I am using that.

Tom Scales
Guest
 
Posts: n/a
#7: Sep 28 '05

re: imagecopyresampled() Help Needed



"chotiwallah" <chotiwallah@web.de> wrote in message
news:1127894323.027751.119330@o13g2000cwo.googlegr oups.com...[color=blue]
>
> Tom Scales wrote:[color=green]
>> "Janwillem Borleffs" <jw@jwscripts.com> wrote in message
>> news:43399eff$0$97550$dbd4d001@news.euronet.nl...[color=darkred]
>> > Janwillem Borleffs wrote:
>> >> header("Content-Type: image/jpeg");
>> >> imagejpeg($image_p, null, 100);
>> >>
>> >
>> > That should be:
>> >
>> > header("Content-Type: image/jpeg");
>> > imagejpeg($image_p, '', 100);
>> >
>> >
>> > JW
>> >
>> >
>> >[/color]
>>
>> I just use:
>>
>> imagejpeg($image_p);
>>
>> For a browser, there is no need to specify quality. Just let it default.
>> 100 is overkill for a browser anyway.
>>
>> Tom[/color]
>
> another tought: how big are your images? php runs out of memory pretty
> quickly if you use truecolor images.
>
> micha
>[/color]

Really? I use images in the 75-150K range and have no problems. I load 20
per page and resize them dynamically to thumbnails.



Closed Thread