RE: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :(

2006-12-27 Thread Steven Macintyre
> imagecopyresampled might help you... I use that and it works
> without
> problems.
> 

Hi Peter,

" I have done some searching via google and some answers say change
copyimageresampled to copyimageresized etc"

I have tried your suggestion with the same results ... that is what I was
using first :(

S

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :(

2006-12-27 Thread Jochem Maas
Steven Macintyre wrote:
> Hi All,
> 
> I have done some searching via google and some answers say change
> copyimageresampled to copyimageresized etc 

which should be the correct; use copyimageresampled()

> 
> I have tried all fixes ... to no avail
> 
> 
> I have one image here 1280 x 960 (150 dpi) 24 depth

DPI is completely irrelevant.

the '24 depth' sounds like your using a PNG as input rather
that a JPEG (which your function expects)

your not making sure that the new width & height are always
integers. use intval() or ceil() or floor() (depending on your
your and the context)... I have no idea what happens if you pass
floats (or non-numeric data) in the relevant arguments of image*()
functinons but I'm guessing it *could* lead to unexplained weirdness
of some sort.

read the man page for imagejpeg():

http://php.net/manual/en/function.imagejpeg.php

take note of the third argument, personally I always set it to 100,
anything less and clients have a tendency to start complaining about image
quality.


> 
> When using the following it pixelates ... 
> 
> function createthumb($name,$filename,$new_w,$new_h)
> {
>   $system=explode(".",$name);
>   $src_img=imagecreatefromjpeg($name);
>   $old_x=imageSX($src_img);
>   $old_y=imageSY($src_img);
>   if ($old_x > $old_y)
>   {
>   $thumb_w=$new_w;
>   $thumb_h=$old_y*($new_h/$old_x);
>   }
>   if ($old_x < $old_y)
>   {
>   $thumb_w=$old_x*($new_w/$old_y);
>   $thumb_h=$new_h;
>   }
>   if ($old_x == $old_y)
>   {
>   $thumb_w=$new_w;
>   $thumb_h=$new_h;
>   }
>   $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
>   
> imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);

try: imagecopyresampled();

>   imagejpeg($dst_img,$filename);
>   imagedestroy($dst_img);
>   imagedestroy($src_img);
> }
> 
> Which I am of course calling with
> createthumb($add,'../pics/'.$largeval,350,263);
> 
> Now ... afaik my new sizes are proportional to the big ones ... but it
> pixelates :(
> 
> However,
> 
> Using an image 1600 x 1200 (96 dpi) 24 depth it works and there is no
> pixilation
> 
> Can someone perhaps assist now?
> 
> 
> 
> Kind Regards,
> 
> 
> Steven Macintyre
> http://steven.macintyre.name
> --
> 
> http://www.friends4friends.co.za
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :(

2006-12-27 Thread Peter Lauri
Hi,

imagecopyresampled might help you... I use that and it works without
problems.

/Peter

-Original Message-
From: Steven Macintyre [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 27, 2006 10:17 AM
To: php-general@lists.php.net
Subject: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :(

Hi All,

I have done some searching via google and some answers say change
copyimageresampled to copyimageresized etc 

I have tried all fixes ... to no avail


I have one image here 1280 x 960 (150 dpi) 24 depth

When using the following it pixelates ... 

function createthumb($name,$filename,$new_w,$new_h)
{
$system=explode(".",$name);
$src_img=imagecreatefromjpeg($name);
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y)
{
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y)
{
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y)
{
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);

imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
imagejpeg($dst_img,$filename);
imagedestroy($dst_img);
imagedestroy($src_img);
}

Which I am of course calling with
createthumb($add,'../pics/'.$largeval,350,263);

Now ... afaik my new sizes are proportional to the big ones ... but it
pixelates :(

However,

Using an image 1600 x 1200 (96 dpi) 24 depth it works and there is no
pixilation

Can someone perhaps assist now?


  
Kind Regards,


Steven Macintyre
http://steven.macintyre.name
--

http://www.friends4friends.co.za

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php