ImageProc - Linux/Windows quick image processing designed for internal company use
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

52 lines
1.6 KiB

  1. <?php
  2. $time_start = microtime(true);
  3. include_once("functions.inc.php");
  4. include_once("config.inc.php");
  5. //$img = new Imagick('/path/to/file');
  6. //autorotate($img);
  7. //$img->stripImage(); // if you want to get rid of all EXIF data
  8. //$img->writeImage();
  9. $progVersion="v2.0.1-PHP";
  10. $phpVersion=phpversion();
  11. $imagickVersion=imagick::getVersion();
  12. $rawDir="raw/";
  13. $outDir="resized/";
  14. echo "ImageProc ".$progVersion."\nPHP ".$phpVersion."\n".$imagickVersion['versionString']."\n\n\n";
  15. $dateInput=readline("Current Date (press enter for ".date('mdy')."): ");
  16. $startNumInput=readline("Starting Number: ");
  17. if (empty($dateInput)) {
  18. $dateInput=date('mdy');
  19. }
  20. if (empty($startNumInput)) {
  21. $startNumInput="1";
  22. }
  23. echo "\n";
  24. foreach(glob($rawDir.'*.{jpg,JPG,jpeg,JPEG}',GLOB_BRACE) as $filename){
  25. $outputName=basename($filename);
  26. $outImgFile=sprintf("%s/%s-%04d.jpg",$outDir, $dateInput, $startNumInput);
  27. echo "#";
  28. $img=new Imagick($filename);
  29. $iccProfiles = $img->getImageProfiles("icc", true);
  30. autorotate($img);
  31. $img->stripImage();
  32. if(!empty($profiles)) {
  33. $img->profileImage("icc", $iccProfiles['icc']);
  34. }
  35. // This is kinda slow sometimes, so we'll try using scaleImage instead
  36. //$img->resizeImage($imgWidth, $imgHeight, imagick::FILTER_CATROM, 1);
  37. $img->setImageDepth(8);
  38. $img->scaleImage($imgWidth, $imgHeight, FALSE);
  39. $img->setImageCompression(Imagick::COMPRESSION_JPEG);
  40. $img->setImageCompressionQuality($imgQuality);
  41. $img->writeImage($outImgFile);
  42. $img->destroy();
  43. $startNumInput++;
  44. }
  45. echo "\n\nTotal Runtime: ".ceil((microtime(true) - $time_start))." seconds";
  46. echo "\n";
  47. readline("");
  48. ?>