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.

49 lines
1.7 KiB

  1. package com.sothr.imagetools
  2. import com.sothr.imagetools.image.{SimilarImages, ImageFilter, Image}
  3. import com.sothr.imagetools.util.DirectoryFilter
  4. import scala.collection.mutable
  5. import java.io.File
  6. import grizzled.slf4j.Logging
  7. /**
  8. * Created by drew on 1/26/14.
  9. */
  10. abstract class Engine extends Logging{
  11. val imageFilter:ImageFilter = new ImageFilter()
  12. val imageCache = AppConfig.cacheManager.getCache("images")
  13. def getAllImageFiles(directoryPath:String, recursive:Boolean=false, recursiveDepth:Int=500):List[File] = {
  14. val fileList = new mutable.MutableList[File]()
  15. if (directoryPath != null && directoryPath != "") {
  16. val directory:File = new File(directoryPath)
  17. val imageFilter = new ImageFilter
  18. if (directory.isDirectory) {
  19. val files = directory.listFiles(imageFilter)
  20. if (files != null) {
  21. fileList ++= files
  22. info(s"Found ${files.length} files that are images in directory: $directoryPath")
  23. if (recursive) {
  24. val directoryFilter = new DirectoryFilter
  25. val directories = directory.listFiles(directoryFilter)
  26. for (directory <- directories) {
  27. fileList ++= getAllImageFiles(directory.getAbsolutePath, recursive, recursiveDepth-1)
  28. }
  29. }
  30. }
  31. }
  32. }
  33. fileList.toList
  34. }
  35. /**
  36. * Get all images for a directory with hashes
  37. */
  38. def getImagesForDirectory(directoryPath:String, recursive:Boolean=false, recursiveDepth:Int=500):List[Image];
  39. /**
  40. * Get all similar images for a directory with hashes
  41. */
  42. def getSimilarImagesForDirectory(directoryPath:String, recursive:Boolean=false, recursiveDepth:Int=500):List[SimilarImages];
  43. }