note 99774 added to function.imagecreatefromjpeg
| From: | condigital at gmail dot com | Date: | Mon, 06 Sep 2010 00:54:34 +0000 |
| Subject: | note 99774 added to function.imagecreatefromjpeg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172325@lists.php.net to get a copy of this message | ||
how to compress all JPG images in a directory To a 50% JPG Compressed ..?
This is the Solution.. It is a Excellent output quality
<?
$dir="."; // Ej: images . is the current directory
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if ($file != "." && $file != "..")
{
$file=explode(".",$file);
if(stristr($file[1], 'jpg') == TRUE) // If is a jpg Image
{
$infile= $file[0].".".$file[1];
$img = imagecreatefromjpeg($infile); // create image
if(!is_dir("compressed") )
{mkdir("optimizadas",7777);} // Make Directory '/compressed' to
put the compressed Files there
$cont++;
if (imagejpeg($img,'compressed/'.$infile,50)) //Put the file in to the compressed
dir
{ print "$cont\t $infile\n";}
else
{print "$cont\t $infile ----> Error ..! \n";}
}
}
}
}
if ($cont =='')
{print"\n\n\t\tNot Files Founds...!";}
?>
Please Excuse my English.. I From Colombia :)
----
Server IP: 190.90.160.68
Probable Submitter: 186.81.11.67 (proxied: 186.81.11.67)
----
Manual Page -- http://www.php.net/manual/en/function.imagecreatefromjpeg.php
Edit -- https://master.php.net/note/edit/99774
Del: integrated -- https://master.php.net/note/delete/99774/integrated
Del: useless -- https://master.php.net/note/delete/99774/useless
Del: bad code -- https://master.php.net/note/delete/99774/bad+code
Del: spam -- https://master.php.net/note/delete/99774/spam
Del: non-english -- https://master.php.net/note/delete/99774/non-english
Del: in docs -- https://master.php.net/note/delete/99774/in+docs
Del: other reasons-- https://master.php.net/note/delete/99774
Reject -- https://master.php.net/note/reject/99774
Search -- https://master.php.net/manage/user-notes.php