Bad picture colors

Bad picture colors

am 27.04.2006 18:27:43 von nikos

Hello list

I use the following code to shrink some photos.

$directory='/var/www/html/offroads/tmp/';
$dir=opendir($directory);
while($file=readdir($dir)) {
$dirfile=$directory.$file;
if(is_file($dirfile)) {
copy($dirfile,$directory."sm/sm_".$file);
$imgReal = ImageCreateFromJPEG($dirfile);
$x = ImagesX($imgReal);
$y = ImagesY($imgReal);
$newX=$x*0.1783;
$newY=$y*0.1783;
$img = ImageCreate($newX,$newY);
ImageCopyResized($img, $imgReal, 0, 0, 0, 0, $newX,
$newY, $x, $y);
//$newimg=imagecolorstotal($img);
ImageJPEG($img,$directory."sm/sm_".$file);
clearstatcache();
}
}
closedir($dir);

My problem is that the color results are very bad. How can I take picture
with good colors?

Thank you

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

RE: Bad picture colors

am 27.04.2006 18:40:32 von Dwight Altman

Could it be related to quality in JPEG lossy compression? Can you try PNG
instead?

-----Original Message-----
From: nikos [mailto:nikos@qbit.gr]
Sent: Thursday, April 27, 2006 11:28 AM
To: PHP-mailist (PHP-mailist)
Subject: [PHP-DB] Bad picture colors

Hello list

I use the following code to shrink some photos.

$directory='/var/www/html/offroads/tmp/';
$dir=opendir($directory);
while($file=readdir($dir)) {
$dirfile=$directory.$file;
if(is_file($dirfile)) {
copy($dirfile,$directory."sm/sm_".$file);
$imgReal = ImageCreateFromJPEG($dirfile);
$x = ImagesX($imgReal);
$y = ImagesY($imgReal);
$newX=$x*0.1783;
$newY=$y*0.1783;
$img = ImageCreate($newX,$newY);
ImageCopyResized($img, $imgReal, 0, 0, 0, 0, $newX,
$newY, $x, $y);
//$newimg=imagecolorstotal($img);
ImageJPEG($img,$directory."sm/sm_".$file);
clearstatcache();
}
}
closedir($dir);

My problem is that the color results are very bad. How can I take picture
with good colors?

Thank you

--


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

RE: Bad picture colors

am 27.04.2006 18:48:40 von nikos

Im not sure if browsers can "play" pngs Dwight
Thnak you
_____ =20

=20
ÃáôóÞò Íßêï=F2 - Gatsis Nikos
Web developer
tel.: 2108256721 - 2108256722
fax: 2108256712
email: ngatsis@qbit.gr
http://www.qbit.gr=20

-----Original Message-----
From: Dwight Altman [mailto:dwight@multicam.com]=20
Sent: Thursday, April 27, 2006 7:41 PM
To: 'nikos'; 'PHP-mailist (PHP-mailist)'
Subject: RE: [PHP-DB] Bad picture colors

Could it be related to quality in JPEG lossy compression? Can you try =
PNG
instead?

-----Original Message-----
From: nikos [mailto:nikos@qbit.gr]=20
Sent: Thursday, April 27, 2006 11:28 AM
To: PHP-mailist (PHP-mailist)
Subject: [PHP-DB] Bad picture colors

Hello list

I use the following code to shrink some photos.

$directory=3D'/var/www/html/offroads/tmp/';
$dir=3Dopendir($directory);
while($file=3Dreaddir($dir)) {
$dirfile=3D$directory.$file;
if(is_file($dirfile)) {
copy($dirfile,$directory."sm/sm_".$file);
$imgReal =3D ImageCreateFromJPEG($dirfile);
$x =3D ImagesX($imgReal);
$y =3D ImagesY($imgReal);
$newX=3D$x*0.1783;
$newY=3D$y*0.1783; =09
$img =3D ImageCreate($newX,$newY);
ImageCopyResized($img, $imgReal, 0, 0, 0, 0, $newX,
$newY, $x, $y);
//$newimg=3Dimagecolorstotal($img);
ImageJPEG($img,$directory."sm/sm_".$file);
clearstatcache();
}
}
closedir($dir);

My problem is that the color results are very bad. How can I take =
picture
with good colors?

Thank you

--=20

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

RE: Bad picture colors

am 27.04.2006 18:58:17 von Dwight Altman

My browsers "play" them.
Firefox 1.5.0.2
Internet Explorer 6.0.2900...

-----Original Message-----
From: nikos [mailto:nikos@qbit.gr]=20
Sent: Thursday, April 27, 2006 11:49 AM
To: PHP-mailist (PHP-mailist)
Subject: RE: [PHP-DB] Bad picture colors

Im not sure if browsers can "play" pngs Dwight
Thnak you
_____ =20

=20
ÃáôóÞò Íßêï=F2 - Gatsis Nikos
Web developer
tel.: 2108256721 - 2108256722
fax: 2108256712
email: ngatsis@qbit.gr
http://www.qbit.gr=20

-----Original Message-----
From: Dwight Altman [mailto:dwight@multicam.com]=20
Sent: Thursday, April 27, 2006 7:41 PM
To: 'nikos'; 'PHP-mailist (PHP-mailist)'
Subject: RE: [PHP-DB] Bad picture colors

Could it be related to quality in JPEG lossy compression? Can you try =
PNG
instead?

-----Original Message-----
From: nikos [mailto:nikos@qbit.gr]=20
Sent: Thursday, April 27, 2006 11:28 AM
To: PHP-mailist (PHP-mailist)
Subject: [PHP-DB] Bad picture colors

Hello list

I use the following code to shrink some photos.

$directory=3D'/var/www/html/offroads/tmp/';
$dir=3Dopendir($directory);
while($file=3Dreaddir($dir)) {
$dirfile=3D$directory.$file;
if(is_file($dirfile)) {
copy($dirfile,$directory."sm/sm_".$file);
$imgReal =3D ImageCreateFromJPEG($dirfile);
$x =3D ImagesX($imgReal);
$y =3D ImagesY($imgReal);
$newX=3D$x*0.1783;
$newY=3D$y*0.1783; =09
$img =3D ImageCreate($newX,$newY);
ImageCopyResized($img, $imgReal, 0, 0, 0, 0, $newX,
$newY, $x, $y);
//$newimg=3Dimagecolorstotal($img);
ImageJPEG($img,$directory."sm/sm_".$file);
clearstatcache();
}
}
closedir($dir);

My problem is that the color results are very bad. How can I take =
picture
with good colors?

Thank you

--=20

--=20

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

Re: Bad picture colors

am 27.04.2006 21:49:49 von Martin Alterisio

------=_Part_30520_13982029.1146167389273
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

2006/4/27, nikos :
>
> Hello list
>
> I use the following code to shrink some photos.
>
> $directory=3D'/var/www/html/offroads/tmp/';
> $dir=3Dopendir($directory);
> while($file=3Dreaddir($dir)) {
> $dirfile=3D$directory.$file;
> if(is_file($dirfile)) {
> copy($dirfile,$directory."sm/sm_".$file);
> $imgReal =3D ImageCreateFromJPEG($dirfile);
> $x =3D ImagesX($imgReal);
> $y =3D ImagesY($imgReal);
> $newX=3D$x*0.1783;
> $newY=3D$y*0.1783;
> $img =3D ImageCreate($newX,$newY);
> ImageCopyResized($img, $imgReal, 0, 0, 0, 0,
> $newX,
> $newY, $x, $y);
> //$newimg=3Dimagecolorstotal($img);
> ImageJPEG($img,$directory."sm/sm_".$file);
> clearstatcache();
> }
> }
> closedir($dir);
>
> My problem is that the color results are very bad. How can I take picture
> with good colors?
>
> Thank you
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Try using imagecopyresampled() instead of imagecopyresized(). It uses a mor=
e
precise algorithm which means: more time to complete. But since it seems
you're creating a cache of resized images that won't mather once the resize
its done.

------=_Part_30520_13982029.1146167389273--

RE: Bad picture colors

am 28.04.2006 09:54:46 von nikos gatsis

Martin you really save my ass!!
imagecopyresampled() is what I need.
It is 3 times slower but how cares, I run it in a local server.

Thank you vary much!

_____ =20

=20
ÃáôóÞò Íßêï=F2 - Gatsis Nikos
Web developer
tel.: 2108256721 - 2108256722
fax: 2108256712
email: ngatsis@qbit.gr
http://www.qbit.gr=20

-----Original Message-----
From: Martin Alterisio [mailto:malterisio777@gmail.com]=20
Sent: Thursday, April 27, 2006 10:50 PM
To: nikos
Cc: PHP-mailist (PHP-mailist)
Subject: Re: [PHP-DB] Bad picture colors

2006/4/27, nikos :
>
> Hello list
>
> I use the following code to shrink some photos.
>
> $directory=3D'/var/www/html/offroads/tmp/';
> $dir=3Dopendir($directory);
> while($file=3Dreaddir($dir)) {
> $dirfile=3D$directory.$file;
> if(is_file($dirfile)) {
> copy($dirfile,$directory."sm/sm_".$file);
> $imgReal =3D ImageCreateFromJPEG($dirfile);
> $x =3D ImagesX($imgReal);
> $y =3D ImagesY($imgReal);
> $newX=3D$x*0.1783;
> $newY=3D$y*0.1783;
> $img =3D ImageCreate($newX,$newY);
> ImageCopyResized($img, $imgReal, 0, 0, 0, 0,
> $newX,
> $newY, $x, $y);
> //$newimg=3Dimagecolorstotal($img);
> ImageJPEG($img,$directory."sm/sm_".$file);
> clearstatcache();
> }
> }
> closedir($dir);
>
> My problem is that the color results are very bad. How can I take =
picture
> with good colors?
>
> Thank you
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Try using imagecopyresampled() instead of imagecopyresized(). It uses a =
more
precise algorithm which means: more time to complete. But since it seems
you're creating a cache of resized images that won't mather once the =
resize
its done.

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

RE: Bad picture colors

am 28.04.2006 10:08:34 von nikos

Martin you really save my ass!!
imagecopyresampled() is what I need.
It is 3 times slower but how cares, I run it in a local server.

Thank you vary much!

_____ =20

=20
ÃáôóÞò Íßêï=F2 - Gatsis Nikos
Web developer
tel.: 2108256721 - 2108256722
fax: 2108256712
email: ngatsis@qbit.gr
http://www.qbit.gr=20

-----Original Message-----
From: Martin Alterisio [mailto:malterisio777@gmail.com]=20
Sent: Thursday, April 27, 2006 10:50 PM
To: nikos
Cc: PHP-mailist (PHP-mailist)
Subject: Re: [PHP-DB] Bad picture colors

2006/4/27, nikos :
>
> Hello list
>
> I use the following code to shrink some photos.
>
> $directory=3D'/var/www/html/offroads/tmp/';
> $dir=3Dopendir($directory);
> while($file=3Dreaddir($dir)) {
> $dirfile=3D$directory.$file;
> if(is_file($dirfile)) {
> copy($dirfile,$directory."sm/sm_".$file);
> $imgReal =3D ImageCreateFromJPEG($dirfile);
> $x =3D ImagesX($imgReal);
> $y =3D ImagesY($imgReal);
> $newX=3D$x*0.1783;
> $newY=3D$y*0.1783;
> $img =3D ImageCreate($newX,$newY);
> ImageCopyResized($img, $imgReal, 0, 0, 0, 0,
> $newX,
> $newY, $x, $y);
> //$newimg=3Dimagecolorstotal($img);
> ImageJPEG($img,$directory."sm/sm_".$file);
> clearstatcache();
> }
> }
> closedir($dir);
>
> My problem is that the color results are very bad. How can I take =
picture
> with good colors?
>
> Thank you
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Try using imagecopyresampled() instead of imagecopyresized(). It uses a =
more
precise algorithm which means: more time to complete. But since it seems
you're creating a cache of resized images that won't mather once the =
resize
its done.

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