Browse Source

Added some additional logging at the INFO level. Fixed the default Log4J.properties file to only output INFO and above to the console.

master
Drew Short 11 years ago
parent
commit
17688dcb17
  1. 2
      buildWithoutTests.sh
  2. 1
      src/includes/log4j.properties
  3. 2
      src/includes/startCLI.sh
  4. 2
      src/includes/startGUI.sh
  5. 7
      src/main/scala/com/sothr/imagetools/Engine.scala
  6. 3
      src/main/scala/com/sothr/imagetools/image/Image.scala
  7. 9
      src/main/scala/com/sothr/imagetools/image/ImageService.scala

2
buildWithoutTests.sh

@ -0,0 +1,2 @@
#!/bin/bash
mvn -Dmaven.test.skip=true clean jfx:jar

1
src/includes/log4j.properties

@ -2,6 +2,7 @@ log4j.rootLogger=DEBUG, C, DL, IL, EL
# Console Output
log4j.appender.C=org.apache.log4j.ConsoleAppender
log4j.appender.C.Threshold=INFO
log4j.appender.C.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.C.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss} %-5p [%c{3.}] - %m%n

2
src/includes/startCLI.sh

@ -4,7 +4,7 @@ command=""
correct=false
while true; do
read -p "Please enter and commandline arguments you would like to include: " args
command="-Xmx1.5G -cp ${project.name}-${project.version}-jfx.jar:lib/* com.sothr.imagetools.AppCLI $args"
command="-Xmx1500m -cp ${project.name}-${project.version}-jfx.jar:lib/* com.sothr.imagetools.AppCLI $args"
echo "Is \"$command\" accurate? (yes/no)"
select yn in "Yes" "No"; do
case $yn in

2
src/includes/startGUI.sh

@ -1,4 +1,4 @@
#!/bin/bash
echo "Welcome to Image Tools version: ${project.version}"
command="-Xmx1.5G -jar ${project.name}-${project.version}-jfx.jar"
command="-Xmx1500m -jar ${project.name}-${project.version}-jfx.jar"
java $command

7
src/main/scala/com/sothr/imagetools/Engine.scala

@ -18,18 +18,23 @@ class Engine() extends Logging{
debug(s"Looking for images in directory: $directoryPath")
val images:mutable.MutableList[Image] = new mutable.MutableList[Image]()
val directory:File = new File(directoryPath)
var count = 0
if (directory.isDirectory) {
val files = directory.listFiles(imageFilter)
debug(s"Found ${files.length} files that are images in directory: $directoryPath")
info(s"Found ${files.length} files that are images in directory: $directoryPath")
for (file <- files) {
count += 1
if (count % 25 == 0) info(s"Processed ${count}/${files.size}")
if (imageCache.isKeyInCache(file.getAbsolutePath)) {
images += imageCache.get(file.getAbsolutePath).getObjectValue.asInstanceOf[Image]
} else {
val image = ImageService.getImage(file)
if (image != null) {
imageCache.put(new Element(file.getAbsolutePath, image))
images += image
}
}
}
} else {
error(s"Provided path: $directoryPath is not a directory")
}

3
src/main/scala/com/sothr/imagetools/image/Image.scala

@ -2,8 +2,9 @@ package com.sothr.imagetools.image
import com.sothr.imagetools.dto.ImageHashDTO
import com.sothr.imagetools.hash.HashService
import grizzled.slf4j.Logging
class Image(val imagePath:String, val thumbnailPath:String, val imageSize:Tuple2[Int,Int], var hashes:ImageHashDTO = null) {
class Image(val imagePath:String, val thumbnailPath:String, val imageSize:Tuple2[Int,Int], var hashes:ImageHashDTO = null) extends Serializable with Logging{
var imageType:ImageType = ImageType.SingleFrameImage

9
src/main/scala/com/sothr/imagetools/image/ImageService.scala

@ -7,17 +7,24 @@ import java.io.File
import com.sothr.imagetools.image.Image
import com.sothr.imagetools.hash.HashService
import javax.imageio.ImageIO
import java.io.IOException
object ImageService extends Logging {
def getImage(file:File):Image = {
try {
val thumbnailPath = getThumbnailPath(file)
val bufferedImage = ImageIO.read(file)
val hashes = HashService.getImageHashes(bufferedImage, file.getAbsolutePath)
val imageSize = { (bufferedImage.getWidth, bufferedImage.getHeight) }
val image = new Image(file.getAbsolutePath, thumbnailPath, imageSize, hashes)
debug(s"Created image: $image")
image
return image
} catch {
case ioe:IOException => error(s"Error processing ${file.getAbsolutePath}", ioe)
case ex:Exception => error(s"Error processing ${file.getAbsolutePath}", ex)
}
null
}
def getThumbnailPath(file:File):String = {

Loading…
Cancel
Save