Class: P3libImage

Inherits:
Object
  • Object
show all
Defined in:
lib/refx/engine/p3lib/p3lib_image.rb

Overview

library for all helper image classes

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.convertImgToFiletype(inImage, outImage, type) ⇒ Object

TODO TEST



46
47
48
49
50
# File 'lib/refx/engine/p3lib/p3lib_image.rb', line 46

def self.convertImgToFiletype(inImage,outImage,type)
  cmd = "#{self.p3imgutils_path}/p3convfiletype -i '#{inImage}' -o '#{outImage}' -t #{type}"
  P3libLogger::log("convertingh #{inImage} to #{outImage} of type #{type}")
  system(cmd)
end

.p3imgutils_pathObject



9
10
11
12
13
# File 'lib/refx/engine/p3lib/p3lib_image.rb', line 9

def self.p3imgutils_path
  p3imgutils_path = File.expand_path('../../p3imgutils', __FILE__)
#    p p3imgutils_path
  return p3imgutils_path
end

.resizeBitmap(img, pixWidth, pixHeight) ⇒ Object



19
20
21
22
23
# File 'lib/refx/engine/p3lib/p3lib_image.rb', line 19

def self.resizeBitmap(img,pixWidth,pixHeight)
  cmd = "#{self.p3imgutils_path}/p3scale -w#{pixWidth} -h#{pixHeight} -i '#{img}' -o '#{img}'"
  P3libLogger::log("resizing cmd:",cmd)
  system(cmd)
end

.resizeBitmapByWidth(img, pixWidth) ⇒ Object



31
32
33
34
35
# File 'lib/refx/engine/p3lib/p3lib_image.rb', line 31

def self.resizeBitmapByWidth(img,pixWidth)
  cmd = "#{self.p3imgutils_path}/p3scale -w#{pixWidth} -h0 -i '#{img}' -o '#{img}'"
  P3libLogger::log("resizing cmd:",cmd)
  system(cmd)
end

.resizeBitmapWithOutputType(imgIN, imgOUT, pixWidth, pixHeight, type) ⇒ Object



25
26
27
28
29
# File 'lib/refx/engine/p3lib/p3lib_image.rb', line 25

def self.resizeBitmapWithOutputType(imgIN,imgOUT,pixWidth,pixHeight,type)
  cmd = "#{self.p3imgutils_path}/p3scale -w#{pixWidth} -h#{pixHeight} -i '#{imgIN}' -o '#{imgOUT}' -t #{type}"
  P3libLogger::log("resizing  with type  cmd:",cmd)
  system(cmd)
end

.trimAlphaFromImage(inImage, outImage) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/refx/engine/p3lib/p3lib_image.rb', line 37

def self.trimAlphaFromImage(inImage,outImage)
  cmd = "#{self.p3imgutils_path}/p3trimalpha -i '#{inImage}' -o '#{outImage}'"

  P3libLogger::log("trimming alpha to :",outImage)
  P3libLogger::log("trimming alpha using :",cmd)
  system(cmd)
end

Instance Method Details

#getXYRatio(original_size, newWidth, newHeight) ⇒ Object



15
16
17
# File 'lib/refx/engine/p3lib/p3lib_image.rb', line 15

def getXYRatio(original_size,newWidth, newHeight)
  return newWidth.to_f / original_size.width.to_f, newHeight.to_f / original_size.height.to_f
end