Small update to preserve ICC profile

master 2.0.1
Brie Bruns 2020-04-01 12:48:09 -06:00
parent 6ab95c99fc
commit e55c8f932a
2 changed files with 9 additions and 2 deletions

Binary file not shown.

View File

@ -7,12 +7,13 @@ include_once("config.inc.php");
//autorotate($img); //autorotate($img);
//$img->stripImage(); // if you want to get rid of all EXIF data //$img->stripImage(); // if you want to get rid of all EXIF data
//$img->writeImage(); //$img->writeImage();
$progVersion="v2.0-PHP"; $progVersion="v2.0.1-PHP";
$phpVersion=phpversion(); $phpVersion=phpversion();
$imagickVersion=imagick::getVersion();
$rawDir="raw/"; $rawDir="raw/";
$outDir="resized/"; $outDir="resized/";
echo "ImageProc ".$progVersion." - PHP ".$phpVersion."\n\n\n"; echo "ImageProc ".$progVersion."\nPHP ".$phpVersion."\n".$imagickVersion['versionString']."\n\n\n";
$dateInput=readline("Current Date (press enter for ".date('mdy')."): "); $dateInput=readline("Current Date (press enter for ".date('mdy')."): ");
$startNumInput=readline("Starting Number: "); $startNumInput=readline("Starting Number: ");
@ -29,11 +30,17 @@ foreach(glob($rawDir.'*.{jpg,JPG,jpeg,JPEG}',GLOB_BRACE) as $filename){
$outImgFile=sprintf("%s/%s-%04d.jpg",$outDir, $dateInput, $startNumInput); $outImgFile=sprintf("%s/%s-%04d.jpg",$outDir, $dateInput, $startNumInput);
echo "#"; echo "#";
$img=new Imagick($filename); $img=new Imagick($filename);
$iccProfiles = $img->getImageProfiles("icc", true);
autorotate($img); autorotate($img);
$img->stripImage(); $img->stripImage();
if(!empty($profiles)) {
$img->profileImage("icc", $iccProfiles['icc']);
}
// This is kinda slow sometimes, so we'll try using scaleImage instead // This is kinda slow sometimes, so we'll try using scaleImage instead
//$img->resizeImage($imgWidth, $imgHeight, imagick::FILTER_CATROM, 1); //$img->resizeImage($imgWidth, $imgHeight, imagick::FILTER_CATROM, 1);
$img->setImageDepth(8);
$img->scaleImage($imgWidth, $imgHeight, FALSE); $img->scaleImage($imgWidth, $imgHeight, FALSE);
$img->setImageCompression(Imagick::COMPRESSION_JPEG);
$img->setImageCompressionQuality($imgQuality); $img->setImageCompressionQuality($imgQuality);
$img->writeImage($outImgFile); $img->writeImage($outImgFile);
$img->destroy(); $img->destroy();