note 45457 deleted from function.imagejpeg by cmb
| From: | cmb@php.net | Date: | Tue, 04 Oct 2016 15:17:55 +0000 |
| Subject: | note 45457 deleted from function.imagejpeg by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206748@lists.php.net to get a copy of this message | ||
Note Submitter: arjini at gmail dot com
----
Converting a directory of PNG images into jpegs is as easy as:
<?php
$d = dir('./');
while(false !== ($e = $d->read())){
if(strpos($e,'.png')){
$r = imagecreatefrompng('./'.$e);
imagejpeg($r,str_replace('.png','.jpg',$e),75);
}
}
?>
Don't let anybody convince you otherwise. Put that in the folder that the images are in and run
it. I tried for 2 hours to get photoshop to do it, to no avail. PHP to the rescue!