Browse Source

Added image service to handle getting image data, converting image data, and special processing of image data. Also added some Logging mixin's to classes

master
Drew Short 11 years ago
parent
commit
b04be2e73b
  1. 5
      pom.xml
  2. 5
      src/main/scala/com/sothr/imagetools/dto/ImageHashDTO.scala
  3. 20
      src/main/scala/com/sothr/imagetools/hash/HashService.scala
  4. 14
      src/main/scala/com/sothr/imagetools/image/ImageService.scala

5
pom.xml

@ -75,6 +75,11 @@
<artifactId>scala-library</artifactId> <artifactId>scala-library</artifactId>
<version>${lib.scala-library.version}</version> <version>${lib.scala-library.version}</version>
</dependency> </dependency>
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>[0.4, 0.5)</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

5
src/main/scala/com/sothr/imagetools/dto/ImageHashDTO.scala

@ -6,4 +6,9 @@ class ImageHashDTO(val ahash:Long, val dhash:Long, val phash:Long) {
def getDhash():Long = this.dhash def getDhash():Long = this.dhash
def getPhash():Long = this.phash def getPhash():Long = this.phash
override def toString():String = {
return s"""ahash: $ahash
dhash: $dhash
phash: $phash""".stripMargin
}
} }

20
src/main/scala/com/sothr/imagetools/hash/HashService.scala

@ -1,12 +1,20 @@
package com.sothr.imagetools.hash package com.sothr.imagetools.hash
import grizzled.slf4j.Logging
import com.sothr.imagetools.dto.ImageHashDTO import com.sothr.imagetools.dto.ImageHashDTO
import com.sothr.imagetools.image.Image
import com.sothr.imagetools.util.{PropertiesEnum, PropertiesService} import com.sothr.imagetools.util.{PropertiesEnum, PropertiesService}
object HashService {
/**
* A service that exposes the ability to construct perceptive hashes from an
* image which can be used to find a perceptual difference between two or more
* images
*/
object HashService extends Logging {
def getImageHashes(imagePath:String):ImageHashDTO = {
debug(s"Creating hashes for $imagePath")
def getImageHashes(image:Image):ImageHashDTO = {
var ahash:Long = 0L var ahash:Long = 0L
var dhash:Long = 0L var dhash:Long = 0L
var phash:Long = 0L var phash:Long = 0L
@ -23,7 +31,11 @@ object HashService {
if (PropertiesService.get(PropertiesEnum.UseAhash.toString) == "true") { if (PropertiesService.get(PropertiesEnum.UseAhash.toString) == "true") {
phash = getPhash(imageData) phash = getPhash(imageData)
} }
return new ImageHashDTO(ahash, dhash, phash)
val hashes = new ImageHashDTO(ahash, dhash, phash)
debug(s"Generated hashes: $hashes")
return hashes
} }
def getAhash(imageData:Array[Array[Int]]):Long = { def getAhash(imageData:Array[Array[Int]]):Long = {

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

@ -0,0 +1,14 @@
package com.sothr.imagetools
import grizzled.slf4j.Logging
object ImageService extends Logging {
/**
* Get the raw data for an image
*/
def getImageData(path:String):Array[Array[Int]] = {
return null
}
}
Loading…
Cancel
Save