module Pngdefry

Constants

VERSION

Public Class Methods

_defry(p1, p2) click to toggle source
VALUE method_pngdefry_defry(VALUE self, VALUE input, VALUE output) {
  char *filename = StringValueCStr(input);
  char *outputFilename = StringValueCStr(output);
  int result = process(filename, outputFilename, NULL, NULL);
  return INT2FIX(result);
}
defry(input, output) click to toggle source
# File lib/pngdefry.rb, line 6
def self.defry(input, output)
  # Ensure the output directory exists
  FileUtils.mkdir_p(File.dirname(output))

  # Defry in C
  _defry(input, output)
end
dimensions(p1) click to toggle source
VALUE method_pngdefry_dimensions(VALUE self, VALUE input) {
  char *filename = StringValueCStr(input);
  unsigned int width = 0;
  unsigned int height = 0;
  int result = process(filename, NULL, &width, &height);

  VALUE array = rb_ary_new();
  rb_ary_store(array, 0, INT2FIX(width));
  rb_ary_store(array, 1, INT2FIX(height));
  return array;
}